diff options
Diffstat (limited to 'src/php/ext')
-rw-r--r-- | src/php/ext/grpc/byte_buffer.c | 20 | ||||
-rw-r--r-- | src/php/ext/grpc/channel.c | 2 | ||||
-rw-r--r-- | src/php/ext/grpc/php_grpc.c | 2 | ||||
-rw-r--r-- | src/php/ext/grpc/server.c | 1 |
4 files changed, 11 insertions, 14 deletions
diff --git a/src/php/ext/grpc/byte_buffer.c b/src/php/ext/grpc/byte_buffer.c index 7a726de5db..3be1429f13 100644 --- a/src/php/ext/grpc/byte_buffer.c +++ b/src/php/ext/grpc/byte_buffer.c @@ -58,22 +58,20 @@ grpc_byte_buffer *string_to_byte_buffer(char *string, size_t length) { void byte_buffer_to_string(grpc_byte_buffer *buffer, char **out_string, size_t *out_length) { - if (buffer == NULL) { + grpc_byte_buffer_reader reader; + if (buffer == NULL || !grpc_byte_buffer_reader_init(&reader, buffer)) { + /* TODO(dgq): distinguish between the error cases. */ *out_string = NULL; *out_length = 0; return; } - size_t length = grpc_byte_buffer_length(buffer); + + gpr_slice slice = grpc_byte_buffer_reader_readall(&reader); + size_t length = GPR_SLICE_LENGTH(slice); char *string = ecalloc(length + 1, sizeof(char)); - size_t offset = 0; - grpc_byte_buffer_reader reader; - grpc_byte_buffer_reader_init(&reader, buffer); - gpr_slice next; - while (grpc_byte_buffer_reader_next(&reader, &next) != 0) { - memcpy(string + offset, GPR_SLICE_START_PTR(next), GPR_SLICE_LENGTH(next)); - offset += GPR_SLICE_LENGTH(next); - gpr_slice_unref(next); - } + memcpy(string, GPR_SLICE_START_PTR(slice), length); + gpr_slice_unref(slice); + *out_string = string; *out_length = length; } diff --git a/src/php/ext/grpc/channel.c b/src/php/ext/grpc/channel.c index 9f0431908f..8d94c59683 100644 --- a/src/php/ext/grpc/channel.c +++ b/src/php/ext/grpc/channel.c @@ -48,7 +48,6 @@ #include <stdbool.h> #include <grpc/grpc.h> -#include <grpc/support/log.h> #include <grpc/grpc_security.h> #include "completion_queue.h" @@ -172,7 +171,6 @@ PHP_METHOD(Channel, __construct) { if (creds == NULL) { channel->wrapped = grpc_insecure_channel_create(target, &args, NULL); } else { - gpr_log(GPR_DEBUG, "Initialized secure channel"); channel->wrapped = grpc_secure_channel_create(creds->wrapped, target, &args, NULL); } diff --git a/src/php/ext/grpc/php_grpc.c b/src/php/ext/grpc/php_grpc.c index f4cb5b28cc..449ba3cd47 100644 --- a/src/php/ext/grpc/php_grpc.c +++ b/src/php/ext/grpc/php_grpc.c @@ -248,6 +248,8 @@ PHP_MSHUTDOWN_FUNCTION(grpc) { /* uncomment this line if you have INI entries UNREGISTER_INI_ENTRIES(); */ + // WARNING: This function IS being called by PHP when the extension + // is unloaded but the logs were somehow suppressed. grpc_shutdown_timeval(TSRMLS_C); grpc_php_shutdown_completion_queue(TSRMLS_C); grpc_shutdown(); diff --git a/src/php/ext/grpc/server.c b/src/php/ext/grpc/server.c index 6df2e4f978..c13e7cd1f9 100644 --- a/src/php/ext/grpc/server.c +++ b/src/php/ext/grpc/server.c @@ -48,7 +48,6 @@ #include <stdbool.h> #include <grpc/grpc.h> -#include <grpc/support/log.h> #include <grpc/grpc_security.h> #include "completion_queue.h" |