aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/php/ext
diff options
context:
space:
mode:
authorGravatar murgatroid99 <mlumish@google.com>2015-03-25 11:33:05 -0700
committerGravatar murgatroid99 <mlumish@google.com>2015-03-25 11:33:05 -0700
commitc1da8f20ea050eb11f9169791aa3a789d38b6dd5 (patch)
tree900d62072b2c03cb5ac34e1ec198eac49db9de57 /src/php/ext
parent685e4d958a2da154e01b415ef4ecb3378556d9ac (diff)
Made necessary changes to get interop tests working
Diffstat (limited to 'src/php/ext')
-rw-r--r--src/php/ext/grpc/byte_buffer.c5
-rw-r--r--src/php/ext/grpc/call.c21
2 files changed, 23 insertions, 3 deletions
diff --git a/src/php/ext/grpc/byte_buffer.c b/src/php/ext/grpc/byte_buffer.c
index 1ced1bf3f0..9f122d6da6 100644
--- a/src/php/ext/grpc/byte_buffer.c
+++ b/src/php/ext/grpc/byte_buffer.c
@@ -57,6 +57,11 @@ 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) {
+ *out_string = NULL;
+ *out_length = 0;
+ return;
+ }
size_t length = grpc_byte_buffer_length(buffer);
char *string = ecalloc(length + 1, sizeof(char));
size_t offset = 0;
diff --git a/src/php/ext/grpc/call.c b/src/php/ext/grpc/call.c
index d0e324e2cc..ba1b2a407d 100644
--- a/src/php/ext/grpc/call.c
+++ b/src/php/ext/grpc/call.c
@@ -448,8 +448,12 @@ PHP_METHOD(Call, start_batch) {
break;
case GRPC_OP_RECV_MESSAGE:
byte_buffer_to_string(message, &message_str, &message_len);
- add_property_stringl(result, "message", message_str, message_len,
- false);
+ if (message_str == NULL) {
+ add_property_null(result, "message");
+ } else {
+ add_property_stringl(result, "message", message_str, message_len,
+ false);
+ }
break;
case GRPC_OP_RECV_STATUS_ON_CLIENT:
MAKE_STD_ZVAL(recv_status);
@@ -478,9 +482,20 @@ cleanup:
RETURN_DESTROY_ZVAL(result);
}
+/**
+ * Cancel the call. This will cause the call to end with STATUS_CANCELLED if it
+ * has not already ended with another status.
+ */
+PHP_METHOD(Call, cancel) {
+ wrapped_grpc_call *call =
+ (wrapped_grpc_call *)zend_object_store_get_object(getThis() TSRMLS_CC);
+ grpc_call_cancel(call->wrapped);
+}
+
static zend_function_entry call_methods[] = {
PHP_ME(Call, __construct, NULL, ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
- PHP_ME(Call, start_batch, NULL, ZEND_ACC_PUBLIC) PHP_FE_END};
+ PHP_ME(Call, start_batch, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Call, cancel, NULL, ZEND_ACC_PUBLIC) PHP_FE_END};
void grpc_init_call(TSRMLS_D) {
zend_class_entry ce;