| Index: third_party/grpc/src/core/surface/event_string.c
|
| diff --git a/third_party/tcmalloc/vendor/src/base/thread_lister.c b/third_party/grpc/src/core/surface/event_string.c
|
| similarity index 56%
|
| copy from third_party/tcmalloc/vendor/src/base/thread_lister.c
|
| copy to third_party/grpc/src/core/surface/event_string.c
|
| index bc180dba7a9f2ba3b8261009c8af85f0b1d4a023..33cd4a43aa0393e4379b7c812b9cc47ae5c38fb3 100644
|
| --- a/third_party/tcmalloc/vendor/src/base/thread_lister.c
|
| +++ b/third_party/grpc/src/core/surface/event_string.c
|
| @@ -1,4 +1,6 @@
|
| -/* Copyright (c) 2005-2007, Google Inc.
|
| +/*
|
| + *
|
| + * Copyright 2015, Google Inc.
|
| * All rights reserved.
|
| *
|
| * Redistribution and use in source and binary forms, with or without
|
| @@ -27,51 +29,53 @@
|
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| *
|
| - * ---
|
| - * Author: Markus Gutschke
|
| */
|
|
|
| -#include "config.h"
|
| -#include <stdio.h> /* needed for NULL on some powerpc platforms (?!) */
|
| -#ifdef HAVE_SYS_PRCTL
|
| -# include <sys/prctl.h>
|
| -#endif
|
| -#include "base/thread_lister.h"
|
| -#include "base/linuxthreads.h"
|
| -/* Include other thread listers here that define THREADS macro
|
| - * only when they can provide a good implementation.
|
| - */
|
| +#include "src/core/surface/event_string.h"
|
|
|
| -#ifndef THREADS
|
| +#include <stdio.h>
|
|
|
| -/* Default trivial thread lister for single-threaded applications,
|
| - * or if the multi-threading code has not been ported, yet.
|
| - */
|
| +#include "src/core/support/string.h"
|
| +#include <grpc/byte_buffer.h>
|
| +#include <grpc/support/string_util.h>
|
|
|
| -int ListAllProcessThreads(void *parameter,
|
| - ListAllProcessThreadsCallBack callback, ...) {
|
| - int rc;
|
| - va_list ap;
|
| - pid_t pid;
|
| -
|
| -#ifdef HAVE_SYS_PRCTL
|
| - int dumpable = prctl(PR_GET_DUMPABLE, 0);
|
| - if (!dumpable)
|
| - prctl(PR_SET_DUMPABLE, 1);
|
| -#endif
|
| - va_start(ap, callback);
|
| - pid = getpid();
|
| - rc = callback(parameter, 1, &pid, ap);
|
| - va_end(ap);
|
| -#ifdef HAVE_SYS_PRCTL
|
| - if (!dumpable)
|
| - prctl(PR_SET_DUMPABLE, 0);
|
| -#endif
|
| - return rc;
|
| +static void addhdr(gpr_strvec *buf, grpc_event *ev) {
|
| + char *tmp;
|
| + gpr_asprintf(&tmp, "tag:%p", ev->tag);
|
| + gpr_strvec_add(buf, tmp);
|
| }
|
|
|
| -int ResumeAllProcessThreads(int num_threads, pid_t *thread_pids) {
|
| - return 1;
|
| +static const char *errstr(int success) { return success ? "OK" : "ERROR"; }
|
| +
|
| +static void adderr(gpr_strvec *buf, int success) {
|
| + char *tmp;
|
| + gpr_asprintf(&tmp, " %s", errstr(success));
|
| + gpr_strvec_add(buf, tmp);
|
| }
|
|
|
| -#endif /* ifndef THREADS */
|
| +char *grpc_event_string(grpc_event *ev) {
|
| + char *out;
|
| + gpr_strvec buf;
|
| +
|
| + if (ev == NULL) return gpr_strdup("null");
|
| +
|
| + gpr_strvec_init(&buf);
|
| +
|
| + switch (ev->type) {
|
| + case GRPC_QUEUE_TIMEOUT:
|
| + gpr_strvec_add(&buf, gpr_strdup("QUEUE_TIMEOUT"));
|
| + break;
|
| + case GRPC_QUEUE_SHUTDOWN:
|
| + gpr_strvec_add(&buf, gpr_strdup("QUEUE_SHUTDOWN"));
|
| + break;
|
| + case GRPC_OP_COMPLETE:
|
| + gpr_strvec_add(&buf, gpr_strdup("OP_COMPLETE: "));
|
| + addhdr(&buf, ev);
|
| + adderr(&buf, ev->success);
|
| + break;
|
| + }
|
| +
|
| + out = gpr_strvec_flatten(&buf, NULL);
|
| + gpr_strvec_destroy(&buf);
|
| + return out;
|
| +}
|
|
|