diff options
author | murgatroid99 <mlumish@google.com> | 2015-03-04 12:14:53 -0800 |
---|---|---|
committer | murgatroid99 <mlumish@google.com> | 2015-03-04 12:14:53 -0800 |
commit | 8b87e84b999450432b791c84be9d7b3932b9b51d (patch) | |
tree | 8566cfa65deb22a459a7bce8ebc8e06faacf48f1 /src/php/ext | |
parent | e7460e87d37ad2ff7d829db1731c981c50555d9b (diff) |
Switched to new secure server API
Diffstat (limited to 'src/php/ext')
-rw-r--r-- | src/php/ext/grpc/server.c | 42 |
1 files changed, 13 insertions, 29 deletions
diff --git a/src/php/ext/grpc/server.c b/src/php/ext/grpc/server.c index 32cc19775c..00d08c6ecf 100644 --- a/src/php/ext/grpc/server.c +++ b/src/php/ext/grpc/server.c @@ -96,9 +96,6 @@ PHP_METHOD(Server, __construct) { zval *queue_obj; zval *args_array = NULL; grpc_channel_args args; - HashTable *array_hash; - zval **creds_obj = NULL; - wrapped_grpc_server_credentials *creds = NULL; /* "O|a" == 1 Object, 1 optional array */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|a", &queue_obj, grpc_ce_completion_queue, &args_array) == FAILURE) { @@ -114,28 +111,8 @@ PHP_METHOD(Server, __construct) { if (args_array == NULL) { server->wrapped = grpc_server_create(queue->wrapped, NULL); } else { - array_hash = Z_ARRVAL_P(args_array); - if (zend_hash_find(array_hash, "credentials", sizeof("credentials"), - (void **)&creds_obj) == SUCCESS) { - if (zend_get_class_entry(*creds_obj TSRMLS_CC) != - grpc_ce_server_credentials) { - zend_throw_exception(spl_ce_InvalidArgumentException, - "credentials must be a ServerCredentials object", - 1 TSRMLS_CC); - return; - } - creds = (wrapped_grpc_server_credentials *)zend_object_store_get_object( - *creds_obj TSRMLS_CC); - zend_hash_del(array_hash, "credentials", sizeof("credentials")); - } php_grpc_read_args_array(args_array, &args); - if (creds == NULL) { - server->wrapped = grpc_server_create(queue->wrapped, &args); - } else { - gpr_log(GPR_DEBUG, "Initialized secure server"); - server->wrapped = - grpc_secure_server_create(creds->wrapped, queue->wrapped, &args); - } + server->wrapped = grpc_server_create(queue->wrapped, &args); efree(args.args); } } @@ -187,14 +164,21 @@ PHP_METHOD(Server, add_secure_http2_port) { (wrapped_grpc_server *)zend_object_store_get_object(getThis() TSRMLS_CC); const char *addr; int addr_len; - /* "s" == 1 string */ - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &addr, &addr_len) == + zval *creds_obj; + /* "sO" == 1 string, 1 object */ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &addr, &addr_len, + &creds_obj, grpc_ce_server_credentials) == FAILURE) { - zend_throw_exception(spl_ce_InvalidArgumentException, - "add_http2_port expects a string", 1 TSRMLS_CC); + zend_throw_exception( + spl_ce_InvalidArgumentException, + "add_http2_port expects a string and a ServerCredentials", 1 TSRMLS_CC); return; } - RETURN_LONG(grpc_server_add_secure_http2_port(server->wrapped, addr)); + wrapped_grpc_server_credentials *creds = + (wrapped_grpc_server_credentials *)zend_object_store_get_object( + creds_obj TSRMLS_CC); + RETURN_LONG(grpc_server_add_secure_http2_port(server->wrapped, addr, + creds->wrapped)); } /** |