PHP_GRPC_FREE_STD_ZVAL(inner_array);
}
efree(str_key);
-#if PHP_MAJOR_VERSION >= 7
efree(str_val);
-#endif
}
return array;
}
grpc_status_code status;
grpc_slice recv_status_details = grpc_empty_slice();
grpc_slice send_status_details = grpc_empty_slice();
- grpc_byte_buffer *message;
+ grpc_byte_buffer *message = NULL;
int cancelled;
grpc_call_error error;
- #if PHP_MAJOR_VERSION < 7
- char *message_str;
- size_t message_len;
- #else
zend_string* zmessage = NULL;
- #endif // PHP_MAJOR_VERSION < 7
grpc_metadata_array_init(&metadata);
grpc_metadata_array_init(&trailing_metadata);
goto cleanup;
}
+ // c-core may call rand(). If we don't call srand() here, all the
+ // random numbers being returned would be the same.
+ gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME);
+ srand(now.tv_nsec);
+
array_hash = Z_ARRVAL_P(array);
char *key = NULL;
}
grpc_completion_queue_pluck(completion_queue, call->wrapped,
gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
-#if PHP_MAJOR_VERSION >= 7
zval *recv_md;
-#endif
for (int i = 0; i < op_num; i++) {
switch(ops[i].op) {
case GRPC_OP_SEND_INITIAL_METADATA:
add_property_bool(result, "send_status", true);
break;
case GRPC_OP_RECV_INITIAL_METADATA:
-#if PHP_MAJOR_VERSION < 7
- array = grpc_parse_metadata_array(&recv_metadata TSRMLS_CC);
- add_property_zval(result, "metadata", array);
-#else
recv_md = grpc_parse_metadata_array(&recv_metadata);
add_property_zval(result, "metadata", recv_md);
zval_ptr_dtor(recv_md);
PHP_GRPC_FREE_STD_ZVAL(recv_md);
-#endif
PHP_GRPC_DELREF(array);
break;
case GRPC_OP_RECV_MESSAGE:
-#if PHP_MAJOR_VERSION < 7
- byte_buffer_to_string(message, &message_str, &message_len);
-#else
zmessage = byte_buffer_to_zend_string(message);
-#endif // PHP_MAJOR_VERSION < 7
-#if PHP_MAJOR_VERSION < 7
- if (message_str == NULL) {
-#else
if (zmessage == NULL) {
-#endif // PHP_MAJOR_VERSION < 7
add_property_null(result, "message");
} else {
-#if PHP_MAJOR_VERSION < 7
- php_grpc_add_property_stringl(result, "message", message_str,
- message_len, false);
-#else
zval zmessage_val;
ZVAL_NEW_STR(&zmessage_val, zmessage);
add_property_zval(result, "message", &zmessage_val);
zval_ptr_dtor(&zmessage_val);
-#endif // PHP_MAJOR_VERSION < 7
}
break;
case GRPC_OP_RECV_STATUS_ON_CLIENT:
PHP_GRPC_MAKE_STD_ZVAL(recv_status);
object_init(recv_status);
-#if PHP_MAJOR_VERSION < 7
- array = grpc_parse_metadata_array(&recv_trailing_metadata TSRMLS_CC);
- add_property_zval(recv_status, "metadata", array);
-#else
recv_md = grpc_parse_metadata_array(&recv_trailing_metadata);
add_property_zval(recv_status, "metadata", recv_md);
zval_ptr_dtor(recv_md);
PHP_GRPC_FREE_STD_ZVAL(recv_md);
-#endif
PHP_GRPC_DELREF(array);
add_property_long(recv_status, "code", status);
char *status_details_text = grpc_slice_to_c_string(recv_status_details);
true);
gpr_free(status_details_text);
add_property_zval(result, "status", recv_status);
-#if PHP_MAJOR_VERSION >= 7
zval_ptr_dtor(recv_status);
-#endif
PHP_GRPC_DELREF(recv_status);
PHP_GRPC_FREE_STD_ZVAL(recv_status);
break;
}
if (ops[i].op == GRPC_OP_RECV_MESSAGE) {
grpc_byte_buffer_destroy(message);
- #if PHP_MAJOR_VERSION < 7
- PHP_GRPC_FREE_STD_ZVAL(message_str);
- #endif // PHP_MAJOR_VERSION < 7
}
}
RETURN_DESTROY_ZVAL(result);