|
|
@ -89,8 +89,6 @@ PHP_METHOD(Server, __construct) { |
|
|
|
if (args_array == NULL) { |
|
|
|
if (args_array == NULL) { |
|
|
|
server->wrapped = grpc_server_create(NULL, NULL); |
|
|
|
server->wrapped = grpc_server_create(NULL, NULL); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
//TODO(thinkerou): deal it if key of array is long, crash now on php7
|
|
|
|
|
|
|
|
// and update unit test case
|
|
|
|
|
|
|
|
php_grpc_read_args_array(args_array, &args TSRMLS_CC); |
|
|
|
php_grpc_read_args_array(args_array, &args TSRMLS_CC); |
|
|
|
server->wrapped = grpc_server_create(&args, NULL); |
|
|
|
server->wrapped = grpc_server_create(&args, NULL); |
|
|
|
efree(args.args); |
|
|
|
efree(args.args); |
|
|
@ -118,8 +116,8 @@ PHP_METHOD(Server, requestCall) { |
|
|
|
grpc_call_details_init(&details); |
|
|
|
grpc_call_details_init(&details); |
|
|
|
grpc_metadata_array_init(&metadata); |
|
|
|
grpc_metadata_array_init(&metadata); |
|
|
|
error_code = |
|
|
|
error_code = |
|
|
|
grpc_server_request_call(server->wrapped, &call, &details, &metadata, |
|
|
|
grpc_server_request_call(server->wrapped, &call, &details, &metadata, |
|
|
|
completion_queue, completion_queue, NULL); |
|
|
|
completion_queue, completion_queue, NULL); |
|
|
|
if (error_code != GRPC_CALL_OK) { |
|
|
|
if (error_code != GRPC_CALL_OK) { |
|
|
|
zend_throw_exception(spl_ce_LogicException, "request_call failed", |
|
|
|
zend_throw_exception(spl_ce_LogicException, "request_call failed", |
|
|
|
(long)error_code TSRMLS_CC); |
|
|
|
(long)error_code TSRMLS_CC); |
|
|
@ -140,25 +138,12 @@ PHP_METHOD(Server, requestCall) { |
|
|
|
php_grpc_add_property_string(result, "host", host_text, true); |
|
|
|
php_grpc_add_property_string(result, "host", host_text, true); |
|
|
|
gpr_free(method_text); |
|
|
|
gpr_free(method_text); |
|
|
|
gpr_free(host_text); |
|
|
|
gpr_free(host_text); |
|
|
|
#if PHP_MAJOR_VERSION < 7 |
|
|
|
php_grpc_add_property_zval(result, "call", |
|
|
|
add_property_zval(result, "call", grpc_php_wrap_call(call, true TSRMLS_CC)); |
|
|
|
grpc_php_wrap_call(call, true TSRMLS_CC)); |
|
|
|
add_property_zval(result, "absolute_deadline", |
|
|
|
php_grpc_add_property_zval(result, "absolute_deadline", |
|
|
|
grpc_php_wrap_timeval(details.deadline TSRMLS_CC)); |
|
|
|
grpc_php_wrap_timeval(details.deadline TSRMLS_CC)); |
|
|
|
add_property_zval(result, "metadata", grpc_parse_metadata_array(&metadata |
|
|
|
php_grpc_add_property_zval(result, "metadata", |
|
|
|
TSRMLS_CC)); |
|
|
|
grpc_parse_metadata_array(&metadata TSRMLS_CC)); |
|
|
|
#else |
|
|
|
|
|
|
|
zval zv_call; |
|
|
|
|
|
|
|
zval zv_timeval; |
|
|
|
|
|
|
|
zval zv_md; |
|
|
|
|
|
|
|
//TODO(thinkerou): why use zval* to unit test error?
|
|
|
|
|
|
|
|
zv_call = *grpc_php_wrap_call(call, true); |
|
|
|
|
|
|
|
zv_timeval = *grpc_php_wrap_timeval(details.deadline); |
|
|
|
|
|
|
|
zv_md = *grpc_parse_metadata_array(&metadata); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
add_property_zval(result, "call", &zv_call); |
|
|
|
|
|
|
|
add_property_zval(result, "absolute_deadline", &zv_timeval); |
|
|
|
|
|
|
|
add_property_zval(result, "metadata", &zv_md); |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cleanup: |
|
|
|
cleanup: |
|
|
|
grpc_call_details_destroy(&details); |
|
|
|
grpc_call_details_destroy(&details); |
|
|
@ -202,9 +187,9 @@ PHP_METHOD(Server, addSecureHttp2Port) { |
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sO", &addr, &addr_len, |
|
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sO", &addr, &addr_len, |
|
|
|
&creds_obj, grpc_ce_server_credentials) == |
|
|
|
&creds_obj, grpc_ce_server_credentials) == |
|
|
|
FAILURE) { |
|
|
|
FAILURE) { |
|
|
|
zend_throw_exception( |
|
|
|
zend_throw_exception(spl_ce_InvalidArgumentException, |
|
|
|
spl_ce_InvalidArgumentException, |
|
|
|
"add_http2_port expects a string and a " |
|
|
|
"add_http2_port expects a string and a ServerCredentials", 1 TSRMLS_CC); |
|
|
|
"ServerCredentials", 1 TSRMLS_CC); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
wrapped_grpc_server_credentials *creds = |
|
|
|
wrapped_grpc_server_credentials *creds = |
|
|
|