Lines Matching +full:persist +full:- +full:credentials
9 * http://www.apache.org/licenses/LICENSE-2.0
48 grpc_channel_destroy(channel->wrapped); in free_grpc_channel_wrapper()
49 channel->wrapped = NULL; in free_grpc_channel_wrapper()
51 free(channel->target); in free_grpc_channel_wrapper()
52 free(channel->args_hashstr); in free_grpc_channel_wrapper()
53 free(channel->creds_hashstr); in free_grpc_channel_wrapper()
54 free(channel->key); in free_grpc_channel_wrapper()
55 channel->target = NULL; in free_grpc_channel_wrapper()
56 channel->args_hashstr = NULL; in free_grpc_channel_wrapper()
57 channel->creds_hashstr = NULL; in free_grpc_channel_wrapper()
58 channel->key = NULL; in free_grpc_channel_wrapper()
62 gpr_mu_lock(&wrapper->mu); in php_grpc_channel_ref()
63 wrapper->ref_count += 1; in php_grpc_channel_ref()
64 gpr_mu_unlock(&wrapper->mu); in php_grpc_channel_ref()
68 gpr_mu_lock(&wrapper->mu); in php_grpc_channel_unref()
69 wrapper->ref_count -= 1; in php_grpc_channel_unref()
70 if (wrapper->ref_count == 0) { in php_grpc_channel_unref()
72 gpr_mu_unlock(&wrapper->mu); in php_grpc_channel_unref()
77 gpr_mu_unlock(&wrapper->mu); in php_grpc_channel_unref()
84 if (p->wrapper != NULL) {
85 php_grpc_channel_unref(p->wrapper);
86 p->wrapper = NULL;
95 zend_object_std_init(&intern->std, class_type TSRMLS_CC); in PHP_GRPC_FREE_WRAPPED_FUNC_END()
96 object_properties_init(&intern->std, class_type); in PHP_GRPC_FREE_WRAPPED_FUNC_END()
110 args->num_args = zend_hash_num_elements(array_hash); in php_grpc_read_args_array()
111 args->args = ecalloc(args->num_args, sizeof(grpc_arg)); in php_grpc_read_args_array()
124 args->args[args_index].key = key; in php_grpc_read_args_array()
127 args->args[args_index].value.integer = (int)Z_LVAL_P(data); in php_grpc_read_args_array()
128 args->args[args_index].type = GRPC_ARG_INTEGER; in php_grpc_read_args_array()
131 args->args[args_index].value.string = Z_STRVAL_P(data); in php_grpc_read_args_array()
132 args->args[args_index].type = GRPC_ARG_STRING; in php_grpc_read_args_array()
163 channel_persistent_le_t* le = rsrc->ptr; in php_grpc_persistent_list_delete_unused_channel()
165 if (strcmp(le->channel->target, target) == 0) { in php_grpc_persistent_list_delete_unused_channel()
167 if (le->channel->ref_count == 1) { in php_grpc_persistent_list_delete_unused_channel()
168 php_grpc_delete_persistent_list_entry(le->channel->key, in php_grpc_persistent_list_delete_unused_channel()
169 strlen(le->channel->key) in php_grpc_persistent_list_delete_unused_channel()
171 target_bound_status->current_count -= 1; in php_grpc_persistent_list_delete_unused_channel()
172 if (target_bound_status->current_count < target_bound_status->upper_bound) { in php_grpc_persistent_list_delete_unused_channel()
190 if (bound == -1) { in update_and_get_target_upper_bound()
194 target_bound_status->upper_bound = bound; in update_and_get_target_upper_bound()
197 target_bound_status->current_count = 0; in update_and_get_target_upper_bound()
207 target_bound_status = (target_bound_le_t *)rsrc->ptr; in update_and_get_target_upper_bound()
208 if (bound != -1) { in update_and_get_target_upper_bound()
209 target_bound_status->upper_bound = bound; in update_and_get_target_upper_bound()
221 channel->wrapper->wrapped = grpc_insecure_channel_create(target, &args, in create_channel()
224 channel->wrapper->wrapped = in create_channel()
225 grpc_secure_channel_create(creds->wrapped, target, &args, NULL); in create_channel()
228 php_grpc_channel_ref(channel->wrapper); in create_channel()
243 if (target_bound_status->current_count >= in create_and_add_channel_to_persistent_list()
244 target_bound_status->upper_bound) { in create_and_add_channel_to_persistent_list()
248 // do not persist this one. in create_and_add_channel_to_persistent_list()
253 target_bound_status->upper_bound, in create_and_add_channel_to_persistent_list()
254 target_bound_status->current_count); in create_and_add_channel_to_persistent_list()
267 target_bound_status->current_count += 1; in create_and_add_channel_to_persistent_list()
269 le->channel = channel->wrapper; in create_and_add_channel_to_persistent_list()
275 php_grpc_channel_ref(channel->wrapper); in create_and_add_channel_to_persistent_list()
286 * If the $args array contains a "credentials" key mapping to a
288 * credentials.
310 int target_upper_bound = -1; in PHP_METHOD()
320 if (php_grpc_zend_hash_find(array_hash, "credentials", sizeof("credentials"), in PHP_METHOD()
324 php_grpc_zend_hash_del(array_hash, "credentials", sizeof("credentials")); in PHP_METHOD()
328 "credentials must be a ChannelCredentials object", in PHP_METHOD()
334 php_grpc_zend_hash_del(array_hash, "credentials", sizeof("credentials")); in PHP_METHOD()
367 // 2. hash value of the channel args array (excluding "credentials" in PHP_METHOD()
381 if (creds != NULL && creds->hashstr != NULL) { in PHP_METHOD()
382 key_len += strlen(creds->hashstr); in PHP_METHOD()
387 if (creds != NULL && creds->hashstr != NULL) { in PHP_METHOD()
388 strcat(key, creds->hashstr); in PHP_METHOD()
390 channel->wrapper = malloc(sizeof(grpc_channel_wrapper)); in PHP_METHOD()
391 channel->wrapper->ref_count = 0; in PHP_METHOD()
392 channel->wrapper->key = key; in PHP_METHOD()
393 channel->wrapper->target = strdup(target); in PHP_METHOD()
394 channel->wrapper->args_hashstr = strdup(sha1str); in PHP_METHOD()
395 channel->wrapper->creds_hashstr = NULL; in PHP_METHOD()
396 if (creds != NULL && creds->hashstr != NULL) { in PHP_METHOD()
397 php_grpc_int creds_hashstr_len = strlen(creds->hashstr); in PHP_METHOD()
399 strcpy(channel_creds_hashstr, creds->hashstr); in PHP_METHOD()
400 channel->wrapper->creds_hashstr = channel_creds_hashstr; in PHP_METHOD()
403 gpr_mu_init(&channel->wrapper->mu); in PHP_METHOD()
405 if (force_new || (creds != NULL && creds->has_call_creds)) { in PHP_METHOD()
407 // object, there is no way we can tell them apart. Do NOT persist in PHP_METHOD()
416 channel_persistent_le_t *le = (channel_persistent_le_t *)rsrc->ptr; in PHP_METHOD()
417 if (strcmp(target, le->channel->target) != 0 || in PHP_METHOD()
418 strcmp(sha1str, le->channel->args_hashstr) != 0 || in PHP_METHOD()
419 (creds != NULL && creds->hashstr != NULL && in PHP_METHOD()
420 strcmp(creds->hashstr, le->channel->creds_hashstr) != 0)) { in PHP_METHOD()
426 free_grpc_channel_wrapper(channel->wrapper, false); in PHP_METHOD()
427 gpr_mu_destroy(&channel->wrapper->mu); in PHP_METHOD()
428 free(channel->wrapper); in PHP_METHOD()
429 channel->wrapper = NULL; in PHP_METHOD()
430 channel->wrapper = le->channel; in PHP_METHOD()
432 php_grpc_channel_ref(channel->wrapper); in PHP_METHOD()
445 if (channel->wrapper == NULL) { in PHP_METHOD()
451 gpr_mu_lock(&channel->wrapper->mu); in PHP_METHOD()
452 char *target = grpc_channel_get_target(channel->wrapper->wrapped); in PHP_METHOD()
453 gpr_mu_unlock(&channel->wrapper->mu); in PHP_METHOD()
466 if (channel->wrapper == NULL) { in PHP_METHOD()
472 gpr_mu_lock(&channel->wrapper->mu); in PHP_METHOD()
479 gpr_mu_unlock(&channel->wrapper->mu); in PHP_METHOD()
482 int state = grpc_channel_check_connectivity_state(channel->wrapper->wrapped, in PHP_METHOD()
484 gpr_mu_unlock(&channel->wrapper->mu); in PHP_METHOD()
498 if (channel->wrapper == NULL) { in PHP_METHOD()
504 gpr_mu_lock(&channel->wrapper->mu); in PHP_METHOD()
515 gpr_mu_unlock(&channel->wrapper->mu); in PHP_METHOD()
521 grpc_channel_watch_connectivity_state(channel->wrapper->wrapped, in PHP_METHOD()
523 deadline->wrapped, completion_queue, in PHP_METHOD()
528 gpr_mu_unlock(&channel->wrapper->mu); in PHP_METHOD()
539 if (channel->wrapper != NULL) { in PHP_METHOD()
540 php_grpc_channel_unref(channel->wrapper); in PHP_METHOD()
541 channel->wrapper = NULL; in PHP_METHOD()
561 channel_persistent_le_t *le = (channel_persistent_le_t *)rsrc->ptr; in php_grpc_channel_plink_dtor()
565 if (le->channel != NULL) { in php_grpc_channel_plink_dtor()
566 php_grpc_channel_unref(le->channel); in php_grpc_channel_plink_dtor()
567 le->channel = NULL; in php_grpc_channel_plink_dtor()
576 target_bound_le_t *le = (target_bound_le_t *) rsrc->ptr; in php_grpc_target_bound_dtor()
621 sizeof("target"), channel->wrapper->target, true); in PHP_METHOD()
624 update_and_get_target_upper_bound(channel->wrapper->target, -1); in PHP_METHOD()
626 sizeof("target_upper_bound"), target_bound_status->upper_bound); in PHP_METHOD()
628 sizeof("target_current_size"), target_bound_status->current_count); in PHP_METHOD()
631 sizeof("key"), channel->wrapper->key, true); in PHP_METHOD()
634 sizeof("ref_count"), channel->wrapper->ref_count); in PHP_METHOD()
637 grpc_channel_check_connectivity_state(channel->wrapper->wrapped, (int)0); in PHP_METHOD()
646 sizeof("is_valid"), (channel->wrapper == NULL)); in PHP_METHOD()
662 channel_persistent_le_t* le = rsrc->ptr; in PHP_METHOD()
668 sizeof("target"), le->channel->target, true); in PHP_METHOD()
671 update_and_get_target_upper_bound(le->channel->target, -1); in PHP_METHOD()
673 sizeof("target_upper_bound"), target_bound_status->upper_bound); in PHP_METHOD()
675 sizeof("target_current_size"), target_bound_status->current_count); in PHP_METHOD()
678 sizeof("key"), le->channel->key, true); in PHP_METHOD()
681 sizeof("ref_count"), le->channel->ref_count); in PHP_METHOD()
684 grpc_channel_check_connectivity_state(le->channel->wrapped, (int)0); in PHP_METHOD()
691 add_assoc_zval(return_value, le->channel->key, ret_arr); in PHP_METHOD()
762 // Register the target->upper_bound map. in GRPC_STARTUP_FUNCTION()