Selaa lähdekoodia

Merge pull request #12108 from stanley-cheung/php-fix-windows-issue

PHP: Fix a few Windows/MacOS/ZTS issues for 1.4.3
Stanley Cheung 8 vuotta sitten
vanhempi
commit
18d4ad6469

+ 3 - 2
package.xml

@@ -22,8 +22,9 @@
  </stability>
  <license>BSD</license>
  <notes>
-- Fixed hang bug when fork() was used #11814
-- Channel are now by default persistent #11878
+- Fixed a Windows installation issue #12108
+- Fixed a MacOS mutex segfault #12109
+- Fixed a ZTS compilation issue #12109
  </notes>
  <contents>
   <dir baseinstalldir="/" name="/">

+ 4 - 3
src/php/ext/grpc/channel.c

@@ -173,7 +173,7 @@ void create_and_add_channel_to_persistent_list(
     grpc_channel_args args,
     wrapped_grpc_channel_credentials *creds,
     char *key,
-    php_grpc_int key_len) {
+    php_grpc_int key_len TSRMLS_DC) {
   php_grpc_zend_resource new_rsrc;
   channel_persistent_le_t *le;
   // this links each persistent list entry to a destructor
@@ -308,7 +308,7 @@ PHP_METHOD(Channel, __construct) {
   } else if (!(PHP_GRPC_PERSISTENT_LIST_FIND(&EG(persistent_list), key,
                                              key_len, rsrc))) {
     create_and_add_channel_to_persistent_list(
-        channel, target, args, creds, key, key_len);
+        channel, target, args, creds, key, key_len TSRMLS_CC);
   } else {
     // Found a previously stored channel in the persistent list
     channel_persistent_le_t *le = (channel_persistent_le_t *)rsrc->ptr;
@@ -318,7 +318,7 @@ PHP_METHOD(Channel, __construct) {
          strcmp(creds->hashstr, le->channel->creds_hashstr) != 0)) {
       // somehow hash collision
       create_and_add_channel_to_persistent_list(
-          channel, target, args, creds, key, key_len);
+          channel, target, args, creds, key, key_len TSRMLS_CC);
     } else {
       channel->wrapper = le->channel;
     }
@@ -511,6 +511,7 @@ GRPC_STARTUP_FUNCTION(channel) {
   INIT_CLASS_ENTRY(ce, "Grpc\\Channel", channel_methods);
   ce.create_object = create_wrapped_grpc_channel;
   grpc_ce_channel = zend_register_internal_class(&ce TSRMLS_CC);
+  gpr_mu_init(&global_persistent_list_mu);
   le_plink = zend_register_list_destructors_ex(
       NULL, php_grpc_channel_plink_dtor, "Persistent Channel", module_number);
   PHP_GRPC_INIT_HANDLER(wrapped_grpc_channel, channel_ce_handlers);

+ 2 - 1
src/php/ext/grpc/channel_credentials.c

@@ -165,7 +165,7 @@ PHP_METHOD(ChannelCredentials, createSsl) {
   }
 
   php_grpc_int hashkey_len = root_certs_length + cert_chain_length;
-  char hashkey[hashkey_len];
+  char *hashkey = emalloc(hashkey_len);
   if (root_certs_length > 0) {
     strcpy(hashkey, pem_root_certs);
   }
@@ -181,6 +181,7 @@ PHP_METHOD(ChannelCredentials, createSsl) {
       pem_key_cert_pair.private_key == NULL ? NULL : &pem_key_cert_pair, NULL);
   zval *creds_object = grpc_php_wrap_channel_credentials(creds, hashstr, false
                                                          TSRMLS_CC);
+  efree(hashkey);
   RETURN_DESTROY_ZVAL(creds_object);
 }
 

+ 3 - 2
templates/package.xml.template

@@ -24,8 +24,9 @@
    </stability>
    <license>BSD</license>
    <notes>
-  - Fixed hang bug when fork() was used #11814
-  - Channel are now by default persistent #11878
+  - Fixed a Windows installation issue #12108
+  - Fixed a MacOS mutex segfault #12109
+  - Fixed a ZTS compilation issue #12109
    </notes>
    <contents>
     <dir baseinstalldir="/" name="/">