aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/ext/resolver/dns/native/dns_resolver.c2
-rw-r--r--src/core/ext/transport/chttp2/transport/frame_rst_stream.c2
-rwxr-xr-xsrc/php/bin/generate_proto_php.sh22
-rw-r--r--src/php/ext/grpc/call.c2
-rw-r--r--src/php/ext/grpc/call_credentials.c10
-rw-r--r--src/php/ext/grpc/channel_credentials.c12
-rw-r--r--src/php/ext/grpc/php7_wrapper.h12
-rw-r--r--src/php/ext/grpc/php_grpc.h4
-rw-r--r--src/php/ext/grpc/server_credentials.c4
-rw-r--r--src/php/ext/grpc/timeval.c42
-rw-r--r--src/php/lib/Grpc/BaseStub.php6
-rw-r--r--src/proto/grpc/testing/control.proto10
12 files changed, 65 insertions, 63 deletions
diff --git a/src/core/ext/resolver/dns/native/dns_resolver.c b/src/core/ext/resolver/dns/native/dns_resolver.c
index bb2b012507..655d9dc586 100644
--- a/src/core/ext/resolver/dns/native/dns_resolver.c
+++ b/src/core/ext/resolver/dns/native/dns_resolver.c
@@ -189,7 +189,7 @@ static void dns_on_resolved(grpc_exec_ctx *exec_ctx, void *arg,
gpr_timespec next_try = gpr_backoff_step(&r->backoff_state, now);
gpr_timespec timeout = gpr_time_sub(next_try, now);
const char *msg = grpc_error_string(error);
- gpr_log(GPR_DEBUG, "dns resolution failed: %s", msg);
+ gpr_log(GPR_INFO, "dns resolution failed (will retry): %s", msg);
grpc_error_free_string(msg);
GPR_ASSERT(!r->have_retry_timer);
r->have_retry_timer = true;
diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.c b/src/core/ext/transport/chttp2/transport/frame_rst_stream.c
index b4c5ed769b..20043f5fbf 100644
--- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.c
+++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.c
@@ -109,7 +109,7 @@ grpc_error *grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx *exec_ctx,
(((uint32_t)p->reason_bytes[2]) << 8) |
(((uint32_t)p->reason_bytes[3]));
grpc_error *error = GRPC_ERROR_NONE;
- if (reason != GRPC_CHTTP2_NO_ERROR) {
+ if (reason != GRPC_CHTTP2_NO_ERROR || s->header_frames_received < 2) {
error = grpc_error_set_int(GRPC_ERROR_CREATE("RST_STREAM"),
GRPC_ERROR_INT_HTTP2_ERROR, (intptr_t)reason);
grpc_status_code status_code = grpc_chttp2_http2_error_to_grpc_status(
diff --git a/src/php/bin/generate_proto_php.sh b/src/php/bin/generate_proto_php.sh
index c558bc5769..416fa9df97 100755
--- a/src/php/bin/generate_proto_php.sh
+++ b/src/php/bin/generate_proto_php.sh
@@ -39,10 +39,13 @@ protoc --proto_path=src/proto/math \
# replace the Empty message with EmptyMessage
# because Empty is a PHP reserved word
-sed -i 's/message Empty/message EmptyMessage/g' \
- src/proto/grpc/testing/empty.proto
-sed -i 's/grpc\.testing\.Empty/grpc\.testing\.EmptyMessage/g' \
- src/proto/grpc/testing/test.proto
+output_file=$(mktemp)
+sed 's/message Empty/message EmptyMessage/g' \
+ src/proto/grpc/testing/empty.proto > $output_file
+mv $output_file ./src/proto/grpc/testing/empty.proto
+sed 's/grpc\.testing\.Empty/grpc\.testing\.EmptyMessage/g' \
+ src/proto/grpc/testing/test.proto > $output_file
+mv $output_file ./src/proto/grpc/testing/test.proto
protoc --proto_path=. \
--php_out=src/php/tests/interop \
@@ -53,7 +56,10 @@ protoc --proto_path=. \
src/proto/grpc/testing/test.proto
# change it back
-sed -i 's/message EmptyMessage/message Empty/g' \
- src/proto/grpc/testing/empty.proto
-sed -i 's/grpc\.testing\.EmptyMessage/grpc\.testing\.Empty/g' \
- src/proto/grpc/testing/test.proto
+sed 's/message EmptyMessage/message Empty/g' \
+ src/proto/grpc/testing/empty.proto > $output_file
+mv $output_file ./src/proto/grpc/testing/empty.proto
+sed 's/grpc\.testing\.EmptyMessage/grpc\.testing\.Empty/g' \
+ src/proto/grpc/testing/test.proto > $output_file
+mv $output_file ./src/proto/grpc/testing/test.proto
+
diff --git a/src/php/ext/grpc/call.c b/src/php/ext/grpc/call.c
index 3a49ea8708..64b1137c2a 100644
--- a/src/php/ext/grpc/call.c
+++ b/src/php/ext/grpc/call.c
@@ -478,6 +478,7 @@ PHP_METHOD(Call, startBatch) {
true);
add_property_zval(result, "status", recv_status);
PHP_GRPC_DELREF(recv_status);
+ PHP_GRPC_FREE_STD_ZVAL(recv_status);
break;
case GRPC_OP_RECV_CLOSE_ON_SERVER:
add_property_bool(result, "cancelled", cancelled);
@@ -501,6 +502,7 @@ cleanup:
}
if (ops[i].op == GRPC_OP_RECV_MESSAGE) {
grpc_byte_buffer_destroy(message);
+ PHP_GRPC_FREE_STD_ZVAL(message_str);
}
}
RETURN_DESTROY_ZVAL(result);
diff --git a/src/php/ext/grpc/call_credentials.c b/src/php/ext/grpc/call_credentials.c
index 3aafc3a19b..043817facd 100644
--- a/src/php/ext/grpc/call_credentials.c
+++ b/src/php/ext/grpc/call_credentials.c
@@ -111,9 +111,7 @@ PHP_METHOD(CallCredentials, createComposite) {
grpc_call_credentials *creds =
grpc_composite_call_credentials_create(cred1->wrapped, cred2->wrapped,
NULL);
- zval *creds_object;
- PHP_GRPC_MAKE_STD_ZVAL(creds_object);
- creds_object = grpc_php_wrap_call_credentials(creds TSRMLS_CC);
+ zval *creds_object = grpc_php_wrap_call_credentials(creds TSRMLS_CC);
RETURN_DESTROY_ZVAL(creds_object);
}
@@ -155,9 +153,7 @@ PHP_METHOD(CallCredentials, createFromPlugin) {
grpc_call_credentials *creds =
grpc_metadata_credentials_create_from_plugin(plugin, NULL);
- zval *creds_object;
- PHP_GRPC_MAKE_STD_ZVAL(creds_object);
- creds_object = grpc_php_wrap_call_credentials(creds TSRMLS_CC);
+ zval *creds_object = grpc_php_wrap_call_credentials(creds TSRMLS_CC);
RETURN_DESTROY_ZVAL(creds_object);
}
@@ -211,6 +207,8 @@ void plugin_destroy_state(void *ptr) {
plugin_state *state = (plugin_state *)ptr;
efree(state->fci);
efree(state->fci_cache);
+ PHP_GRPC_FREE_STD_ZVAL(state->fci->params);
+ PHP_GRPC_FREE_STD_ZVAL(state->fci->retval);
efree(state);
}
diff --git a/src/php/ext/grpc/channel_credentials.c b/src/php/ext/grpc/channel_credentials.c
index a32c4a4ea2..36a8223b88 100644
--- a/src/php/ext/grpc/channel_credentials.c
+++ b/src/php/ext/grpc/channel_credentials.c
@@ -121,9 +121,7 @@ PHP_METHOD(ChannelCredentials, setDefaultRootsPem) {
*/
PHP_METHOD(ChannelCredentials, createDefault) {
grpc_channel_credentials *creds = grpc_google_default_credentials_create();
- zval *creds_object;
- PHP_GRPC_MAKE_STD_ZVAL(creds_object);
- creds_object = grpc_php_wrap_channel_credentials(creds TSRMLS_CC);
+ zval *creds_object = grpc_php_wrap_channel_credentials(creds TSRMLS_CC);
RETURN_DESTROY_ZVAL(creds_object);
}
@@ -160,9 +158,7 @@ PHP_METHOD(ChannelCredentials, createSsl) {
grpc_channel_credentials *creds = grpc_ssl_credentials_create(
pem_root_certs,
pem_key_cert_pair.private_key == NULL ? NULL : &pem_key_cert_pair, NULL);
- zval *creds_object;
- PHP_GRPC_MAKE_STD_ZVAL(creds_object);
- creds_object = grpc_php_wrap_channel_credentials(creds TSRMLS_CC);
+ zval *creds_object = grpc_php_wrap_channel_credentials(creds TSRMLS_CC);
RETURN_DESTROY_ZVAL(creds_object);
}
@@ -191,9 +187,7 @@ PHP_METHOD(ChannelCredentials, createComposite) {
grpc_channel_credentials *creds =
grpc_composite_channel_credentials_create(cred1->wrapped, cred2->wrapped,
NULL);
- zval *creds_object;
- PHP_GRPC_MAKE_STD_ZVAL(creds_object);
- creds_object = grpc_php_wrap_channel_credentials(creds TSRMLS_CC);
+ zval *creds_object = grpc_php_wrap_channel_credentials(creds TSRMLS_CC);
RETURN_DESTROY_ZVAL(creds_object);
}
diff --git a/src/php/ext/grpc/php7_wrapper.h b/src/php/ext/grpc/php7_wrapper.h
index 1d7824113f..72e982d6fc 100644
--- a/src/php/ext/grpc/php7_wrapper.h
+++ b/src/php/ext/grpc/php7_wrapper.h
@@ -50,8 +50,13 @@
#define PHP_GRPC_RETURN_STRING(val, dup) RETURN_STRING(val, dup)
#define PHP_GRPC_MAKE_STD_ZVAL(pzv) MAKE_STD_ZVAL(pzv)
+#define PHP_GRPC_FREE_STD_ZVAL(pzv)
#define PHP_GRPC_DELREF(zv) Z_DELREF_P(zv)
+#define RETURN_DESTROY_ZVAL(val) \
+ RETURN_ZVAL(val, false /* Don't execute copy constructor */, \
+ true /* Dealloc original before returning */)
+
#define PHP_GRPC_WRAP_OBJECT_START(name) \
typedef struct name { \
zend_object std;
@@ -144,8 +149,15 @@ static inline int php_grpc_zend_hash_find(HashTable *ht, char *key, int len,
#define PHP_GRPC_RETURN_STRING(val, dup) RETURN_STRING(val)
#define PHP_GRPC_MAKE_STD_ZVAL(pzv) \
pzv = (zval *)emalloc(sizeof(zval));
+#define PHP_GRPC_FREE_STD_ZVAL(pzv) efree(pzv);
#define PHP_GRPC_DELREF(zv)
+#define RETURN_DESTROY_ZVAL(val) \
+ RETVAL_ZVAL(val, false /* Don't execute copy constructor */, \
+ true /* Dealloc original before returning */); \
+ efree(val); \
+ return
+
#define PHP_GRPC_WRAP_OBJECT_START(name) \
typedef struct name {
#define PHP_GRPC_WRAP_OBJECT_END(name) \
diff --git a/src/php/ext/grpc/php_grpc.h b/src/php/ext/grpc/php_grpc.h
index e57a06545e..13083b0bc7 100644
--- a/src/php/ext/grpc/php_grpc.h
+++ b/src/php/ext/grpc/php_grpc.h
@@ -61,10 +61,6 @@ extern zend_module_entry grpc_module_entry;
#include "grpc/grpc.h"
-#define RETURN_DESTROY_ZVAL(val) \
- RETURN_ZVAL(val, false /* Don't execute copy constructor */, \
- true /* Dealloc original before returning */)
-
/* These are all function declarations */
/* Code that runs at module initialization */
PHP_MINIT_FUNCTION(grpc);
diff --git a/src/php/ext/grpc/server_credentials.c b/src/php/ext/grpc/server_credentials.c
index 1610c8ebb0..3e39fee246 100644
--- a/src/php/ext/grpc/server_credentials.c
+++ b/src/php/ext/grpc/server_credentials.c
@@ -113,9 +113,7 @@ PHP_METHOD(ServerCredentials, createSsl) {
grpc_server_credentials *creds = grpc_ssl_server_credentials_create_ex(
pem_root_certs, &pem_key_cert_pair, 1,
GRPC_SSL_DONT_REQUEST_CLIENT_CERTIFICATE, NULL);
- zval *creds_object;
- PHP_GRPC_MAKE_STD_ZVAL(creds_object);
- creds_object = grpc_php_wrap_server_credentials(creds TSRMLS_CC);
+ zval *creds_object = grpc_php_wrap_server_credentials(creds TSRMLS_CC);
RETURN_DESTROY_ZVAL(creds_object);
}
diff --git a/src/php/ext/grpc/timeval.c b/src/php/ext/grpc/timeval.c
index 945231b47f..7ada915aad 100644
--- a/src/php/ext/grpc/timeval.c
+++ b/src/php/ext/grpc/timeval.c
@@ -115,11 +115,9 @@ PHP_METHOD(Timeval, add) {
}
wrapped_grpc_timeval *self = Z_WRAPPED_GRPC_TIMEVAL_P(getThis());
wrapped_grpc_timeval *other = Z_WRAPPED_GRPC_TIMEVAL_P(other_obj);
- zval *sum;
- PHP_GRPC_MAKE_STD_ZVAL(sum);
- sum =
- grpc_php_wrap_timeval(gpr_time_add(self->wrapped, other->wrapped)
- TSRMLS_CC);
+ zval *sum =
+ grpc_php_wrap_timeval(gpr_time_add(self->wrapped, other->wrapped)
+ TSRMLS_CC);
RETURN_DESTROY_ZVAL(sum);
}
@@ -141,11 +139,9 @@ PHP_METHOD(Timeval, subtract) {
}
wrapped_grpc_timeval *self = Z_WRAPPED_GRPC_TIMEVAL_P(getThis());
wrapped_grpc_timeval *other = Z_WRAPPED_GRPC_TIMEVAL_P(other_obj);
- zval *diff;
- PHP_GRPC_MAKE_STD_ZVAL(diff);
- diff =
- grpc_php_wrap_timeval(gpr_time_sub(self->wrapped, other->wrapped)
- TSRMLS_CC);
+ zval *diff =
+ grpc_php_wrap_timeval(gpr_time_sub(self->wrapped, other->wrapped)
+ TSRMLS_CC);
RETURN_DESTROY_ZVAL(diff);
}
@@ -206,9 +202,7 @@ PHP_METHOD(Timeval, similar) {
* @return Timeval The current time
*/
PHP_METHOD(Timeval, now) {
- zval *now;
- PHP_GRPC_MAKE_STD_ZVAL(now);
- now = grpc_php_wrap_timeval(gpr_now(GPR_CLOCK_REALTIME) TSRMLS_CC);
+ zval *now = grpc_php_wrap_timeval(gpr_now(GPR_CLOCK_REALTIME) TSRMLS_CC);
RETURN_DESTROY_ZVAL(now);
}
@@ -217,13 +211,9 @@ PHP_METHOD(Timeval, now) {
* @return Timeval Zero length time interval
*/
PHP_METHOD(Timeval, zero) {
- zval *grpc_php_timeval_zero;
- PHP_GRPC_MAKE_STD_ZVAL(grpc_php_timeval_zero);
- grpc_php_timeval_zero =
- grpc_php_wrap_timeval(gpr_time_0(GPR_CLOCK_REALTIME) TSRMLS_CC);
- RETURN_ZVAL(grpc_php_timeval_zero,
- false, /* Copy original before returning? */
- true /* Destroy original before returning */);
+ zval *grpc_php_timeval_zero =
+ grpc_php_wrap_timeval(gpr_time_0(GPR_CLOCK_REALTIME) TSRMLS_CC);
+ RETURN_DESTROY_ZVAL(grpc_php_timeval_zero);
}
/**
@@ -231,10 +221,8 @@ PHP_METHOD(Timeval, zero) {
* @return Timeval Infinite future time value
*/
PHP_METHOD(Timeval, infFuture) {
- zval *grpc_php_timeval_inf_future;
- PHP_GRPC_MAKE_STD_ZVAL(grpc_php_timeval_inf_future);
- grpc_php_timeval_inf_future =
- grpc_php_wrap_timeval(gpr_inf_future(GPR_CLOCK_REALTIME) TSRMLS_CC);
+ zval *grpc_php_timeval_inf_future =
+ grpc_php_wrap_timeval(gpr_inf_future(GPR_CLOCK_REALTIME) TSRMLS_CC);
RETURN_DESTROY_ZVAL(grpc_php_timeval_inf_future);
}
@@ -243,10 +231,8 @@ PHP_METHOD(Timeval, infFuture) {
* @return Timeval Infinite past time value
*/
PHP_METHOD(Timeval, infPast) {
- zval *grpc_php_timeval_inf_past;
- PHP_GRPC_MAKE_STD_ZVAL(grpc_php_timeval_inf_past);
- grpc_php_timeval_inf_past =
- grpc_php_wrap_timeval(gpr_inf_past(GPR_CLOCK_REALTIME) TSRMLS_CC);
+ zval *grpc_php_timeval_inf_past =
+ grpc_php_wrap_timeval(gpr_inf_past(GPR_CLOCK_REALTIME) TSRMLS_CC);
RETURN_DESTROY_ZVAL(grpc_php_timeval_inf_past);
}
diff --git a/src/php/lib/Grpc/BaseStub.php b/src/php/lib/Grpc/BaseStub.php
index aec60af094..a9e77b9396 100644
--- a/src/php/lib/Grpc/BaseStub.php
+++ b/src/php/lib/Grpc/BaseStub.php
@@ -271,7 +271,7 @@ class BaseStub
* @return ClientStreamingSurfaceActiveCall The active call object
*/
public function _clientStreamRequest($method,
- callable $deserialize,
+ $deserialize,
array $metadata = [],
array $options = [])
{
@@ -307,7 +307,7 @@ class BaseStub
*/
public function _serverStreamRequest($method,
$argument,
- callable $deserialize,
+ $deserialize,
array $metadata = [],
array $options = [])
{
@@ -340,7 +340,7 @@ class BaseStub
* @return BidiStreamingSurfaceActiveCall The active call object
*/
public function _bidiRequest($method,
- callable $deserialize,
+ $deserialize,
array $metadata = [],
array $options = [])
{
diff --git a/src/proto/grpc/testing/control.proto b/src/proto/grpc/testing/control.proto
index be387cf786..529313cfb1 100644
--- a/src/proto/grpc/testing/control.proto
+++ b/src/proto/grpc/testing/control.proto
@@ -78,6 +78,14 @@ message SecurityParams {
string server_host_override = 2;
}
+message ChannelArg {
+ string name = 1;
+ oneof value {
+ string str_value = 2;
+ int32 int_value = 3;
+ }
+}
+
message ClientConfig {
// List of targets to connect to. At least one target needs to be specified.
repeated string server_targets = 1;
@@ -103,6 +111,8 @@ message ClientConfig {
// If we use an OTHER_CLIENT client_type, this string gives more detail
string other_client_api = 15;
+
+ repeated ChannelArg channel_args = 16;
}
message ClientStatus { ClientStats stats = 1; }