aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/php/ext/grpc/channel.c59
-rw-r--r--src/php/ext/grpc/channel.h1
-rw-r--r--src/php/tests/unit_tests/CallCredentials2Test.php3
-rw-r--r--src/php/tests/unit_tests/CallCredentialsTest.php3
-rw-r--r--src/php/tests/unit_tests/CallTest.php3
-rw-r--r--src/php/tests/unit_tests/ChannelTest.php8
-rw-r--r--src/php/tests/unit_tests/EndToEndTest.php3
-rw-r--r--src/php/tests/unit_tests/PersistentChannelTest.php115
-rw-r--r--src/php/tests/unit_tests/SecureEndToEndTest.php3
-rw-r--r--src/php/tests/unit_tests/ServerTest.php3
-rw-r--r--src/php/tests/unit_tests/TimevalTest.php3
11 files changed, 0 insertions, 204 deletions
diff --git a/src/php/ext/grpc/channel.c b/src/php/ext/grpc/channel.c
index f3a03ace09..35adf6b342 100644
--- a/src/php/ext/grpc/channel.c
+++ b/src/php/ext/grpc/channel.c
@@ -193,7 +193,6 @@ void create_and_add_channel_to_persistent_list(
create_channel(channel, target, args, creds);
le->channel = channel->wrapper;
- le->ref_count = 1;
new_rsrc.ptr = le;
gpr_mu_lock(&global_persistent_list_mu);
PHP_GRPC_PERSISTENT_LIST_UPDATE(&grpc_persistent_list, key, key_len,
@@ -342,7 +341,6 @@ PHP_METHOD(Channel, __construct) {
free(channel->wrapper->target);
free(channel->wrapper->args_hashstr);
free(channel->wrapper);
- le->ref_count += 1;
channel->wrapper = le->channel;
channel->wrapper->ref_count += 1;
}
@@ -534,53 +532,6 @@ static void php_grpc_channel_plink_dtor(php_grpc_zend_resource *rsrc
}
}
-/**
- * Clean all channels in the persistent.
- * @return void
- */
-PHP_METHOD(Channel, cleanPersistentList) {
- zend_hash_clean(&grpc_persistent_list);
-}
-
-/**
- * Return an array of persistent list.
- * @return array
- */
-PHP_METHOD(Channel, getPersistentList) {
- array_init(return_value);
- zval *data;
- PHP_GRPC_HASH_FOREACH_VAL_START(&grpc_persistent_list, data)
- php_grpc_zend_resource *rsrc =
- (php_grpc_zend_resource*) PHP_GRPC_HASH_VALPTR_TO_VAL(data)
- if (rsrc == NULL) {
- break;
- }
- channel_persistent_le_t* le = rsrc->ptr;
- zval* ret_arr;
- PHP_GRPC_MAKE_STD_ZVAL(ret_arr);
- array_init(ret_arr);
- // Info about the target
- PHP_GRPC_ADD_STRING_TO_ARRAY(ret_arr, "target",
- sizeof("target"), le->channel->target, true);
- // Info about key
- PHP_GRPC_ADD_STRING_TO_ARRAY(ret_arr, "key",
- sizeof("key"), le->channel->key, true);
- // Info about persistent channel ref_count
- PHP_GRPC_ADD_LONG_TO_ARRAY(ret_arr, "ref_count",
- sizeof("ref_count"), le->ref_count);
- // Info about connectivity status
- int state =
- grpc_channel_check_connectivity_state(le->channel->wrapped, (int)0);
- // It should be set to 'true' in PHP 5.6.33
- PHP_GRPC_ADD_LONG_TO_ARRAY(ret_arr, "connectivity_status",
- sizeof("connectivity_status"), state);
- // Info about the channel is closed or not
- PHP_GRPC_ADD_BOOL_TO_ARRAY(ret_arr, "is_valid",
- sizeof("is_valid"), le->channel->is_valid);
- add_assoc_zval(return_value, le->channel->target, ret_arr);
- PHP_GRPC_HASH_FOREACH_END()
-}
-
ZEND_BEGIN_ARG_INFO_EX(arginfo_construct, 0, 0, 2)
ZEND_ARG_INFO(0, target)
ZEND_ARG_INFO(0, args)
@@ -601,12 +552,6 @@ ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_close, 0, 0, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_cleanPersistentList, 0, 0, 0)
-ZEND_END_ARG_INFO()
-
-ZEND_BEGIN_ARG_INFO_EX(arginfo_getPersistentList, 0, 0, 0)
-ZEND_END_ARG_INFO()
-
static zend_function_entry channel_methods[] = {
PHP_ME(Channel, __construct, arginfo_construct,
ZEND_ACC_PUBLIC | ZEND_ACC_CTOR)
@@ -618,10 +563,6 @@ static zend_function_entry channel_methods[] = {
ZEND_ACC_PUBLIC)
PHP_ME(Channel, close, arginfo_close,
ZEND_ACC_PUBLIC)
- PHP_ME(Channel, cleanPersistentList, arginfo_cleanPersistentList,
- ZEND_ACC_PUBLIC)
- PHP_ME(Channel, getPersistentList, arginfo_getPersistentList,
- ZEND_ACC_PUBLIC)
PHP_FE_END
};
diff --git a/src/php/ext/grpc/channel.h b/src/php/ext/grpc/channel.h
index 807880534e..86bfdea51a 100644
--- a/src/php/ext/grpc/channel.h
+++ b/src/php/ext/grpc/channel.h
@@ -84,7 +84,6 @@ void php_grpc_delete_persistent_list_entry(char *key, php_grpc_int key_len
typedef struct _channel_persistent_le {
grpc_channel_wrapper *channel;
- size_t ref_count;
} channel_persistent_le_t;
diff --git a/src/php/tests/unit_tests/CallCredentials2Test.php b/src/php/tests/unit_tests/CallCredentials2Test.php
index a462bfff56..1c7e0c0ff6 100644
--- a/src/php/tests/unit_tests/CallCredentials2Test.php
+++ b/src/php/tests/unit_tests/CallCredentials2Test.php
@@ -46,9 +46,6 @@ class CallCredentials2Test extends PHPUnit_Framework_TestCase
{
unset($this->channel);
unset($this->server);
- $channel_clean_persistent =
- new Grpc\Channel('localhost:50010', []);
- $channel_clean_persistent->cleanPersistentList();
}
public function callbackFunc($context)
diff --git a/src/php/tests/unit_tests/CallCredentialsTest.php b/src/php/tests/unit_tests/CallCredentialsTest.php
index 31046e6395..4b5721d76a 100644
--- a/src/php/tests/unit_tests/CallCredentialsTest.php
+++ b/src/php/tests/unit_tests/CallCredentialsTest.php
@@ -52,9 +52,6 @@ class CallCredentialsTest extends PHPUnit_Framework_TestCase
{
unset($this->channel);
unset($this->server);
- $channel_clean_persistent =
- new Grpc\Channel('localhost:50010', []);
- $channel_clean_persistent->cleanPersistentList();
}
public function callbackFunc($context)
diff --git a/src/php/tests/unit_tests/CallTest.php b/src/php/tests/unit_tests/CallTest.php
index 38c36ed19a..c5e1890a98 100644
--- a/src/php/tests/unit_tests/CallTest.php
+++ b/src/php/tests/unit_tests/CallTest.php
@@ -38,9 +38,6 @@ class CallTest extends PHPUnit_Framework_TestCase
public function tearDown()
{
$this->channel->close();
- $channel_clean_persistent =
- new Grpc\Channel('localhost:50010', []);
- $channel_clean_persistent->cleanPersistentList();
}
public function testConstructor()
diff --git a/src/php/tests/unit_tests/ChannelTest.php b/src/php/tests/unit_tests/ChannelTest.php
index 63d4193a8b..5baff1fbd9 100644
--- a/src/php/tests/unit_tests/ChannelTest.php
+++ b/src/php/tests/unit_tests/ChannelTest.php
@@ -28,9 +28,6 @@ class ChannelTest extends PHPUnit_Framework_TestCase
if (!empty($this->channel)) {
$this->channel->close();
}
- $channel_clean_persistent =
- new Grpc\Channel('localhost:50010', []);
- $channel_clean_persistent->cleanPersistentList();
}
public function testInsecureCredentials()
@@ -383,11 +380,6 @@ class ChannelTest extends PHPUnit_Framework_TestCase
// close channel1
$this->channel1->close();
- // channel2 is now in SHUTDOWN state
- $state = $this->channel2->getConnectivityState();
- $this->assertEquals(GRPC\CHANNEL_FATAL_FAILURE, $state);
-
- // calling it again will result in an exception because the
// channel is already closed
$state = $this->channel2->getConnectivityState();
}
diff --git a/src/php/tests/unit_tests/EndToEndTest.php b/src/php/tests/unit_tests/EndToEndTest.php
index 71a56d2b6e..b54f1d87c9 100644
--- a/src/php/tests/unit_tests/EndToEndTest.php
+++ b/src/php/tests/unit_tests/EndToEndTest.php
@@ -29,9 +29,6 @@ class EndToEndTest extends PHPUnit_Framework_TestCase
public function tearDown()
{
$this->channel->close();
- $channel_clean_persistent =
- new Grpc\Channel('localhost:50010', []);
- $channel_clean_persistent->cleanPersistentList();
}
public function testSimpleRequestBody()
diff --git a/src/php/tests/unit_tests/PersistentChannelTest.php b/src/php/tests/unit_tests/PersistentChannelTest.php
deleted file mode 100644
index 171780a137..0000000000
--- a/src/php/tests/unit_tests/PersistentChannelTest.php
+++ /dev/null
@@ -1,115 +0,0 @@
-<?php
-/*
- *
- * Copyright 2015 gRPC authors.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-class PersistentListTest extends PHPUnit_Framework_TestCase
-{
- public function setUp()
- {
- }
-
- public function tearDown()
- {
- $channel_clean_persistent =
- new Grpc\Channel('localhost:50010', []);
- $channel_clean_persistent->cleanPersistentList();
- }
-
- public function waitUntilNotIdle($channel) {
- for ($i = 0; $i < 10; $i++) {
- $now = Grpc\Timeval::now();
- $deadline = $now->add(new Grpc\Timeval(1000));
- if ($channel->watchConnectivityState(GRPC\CHANNEL_IDLE,
- $deadline)) {
- return true;
- }
- }
- $this->assertTrue(false);
- }
-
- public function assertConnecting($state) {
- $this->assertTrue($state == GRPC\CHANNEL_CONNECTING ||
- $state == GRPC\CHANNEL_TRANSIENT_FAILURE);
- }
-
- public function testPersistentChennelCreateOneChannel()
- {
- $this->channel1 = new Grpc\Channel('localhost:1', []);
- $plist = $this->channel1->getPersistentList();
- $this->assertEquals($plist['localhost:1']['target'], 'localhost:1');
- $this->assertArrayHasKey('localhost:1', $plist);
- $this->assertEquals($plist['localhost:1']['ref_count'], 1);
- $this->assertEquals($plist['localhost:1']['connectivity_status'],
- GRPC\CHANNEL_IDLE);
- $this->assertEquals($plist['localhost:1']['is_valid'], 1);
- $this->channel1->close();
- }
-
- public function testPersistentChennelStatusChange()
- {
- $this->channel1 = new Grpc\Channel('localhost:1', []);
- $plist = $this->channel1->getPersistentList();
- $this->assertEquals($plist['localhost:1']['connectivity_status'],
- GRPC\CHANNEL_IDLE);
- $this->assertEquals($plist['localhost:1']['is_valid'], 1);
- $state = $this->channel1->getConnectivityState(true);
-
- $this->waitUntilNotIdle($this->channel1);
- $plist = $this->channel1->getPersistentList();
- $this->assertConnecting($plist['localhost:1']['connectivity_status']);
- $this->assertEquals($plist['localhost:1']['is_valid'], 1);
-
- $this->channel1->close();
- }
-
- public function testPersistentChennelCloseChannel()
- {
- $this->channel1 = new Grpc\Channel('localhost:1', []);
- $plist = $this->channel1->getPersistentList();
- $this->assertEquals($plist['localhost:1']['ref_count'], 1);
- $this->channel1->close();
- $plist = $this->channel1->getPersistentList();
- $this->assertArrayNotHasKey('localhost:1', $plist);
- }
-
- public function testPersistentChannelSameHost()
- {
- $this->channel1 = new Grpc\Channel('localhost:1', []);
- $this->channel2 = new Grpc\Channel('localhost:1', []);
- //ref_count should be 2
- $plist = $this->channel1->getPersistentList();
- $this->assertArrayHasKey('localhost:1', $plist);
- $this->assertEquals($plist['localhost:1']['ref_count'], 2);
- $this->channel1->close();
- $this->channel2->close();
- }
-
- public function testPersistentChannelDifferentHost()
- {
- $this->channel1 = new Grpc\Channel('localhost:1', []);
- $this->channel2 = new Grpc\Channel('localhost:2', []);
- $plist = $this->channel1->getPersistentList();
- $this->assertArrayHasKey('localhost:1', $plist);
- $this->assertArrayHasKey('localhost:2', $plist);
- $this->assertEquals($plist['localhost:1']['ref_count'], 1);
- $this->assertEquals($plist['localhost:2']['ref_count'], 1);
- $this->channel1->close();
- $this->channel2->close();
- }
-
-}
diff --git a/src/php/tests/unit_tests/SecureEndToEndTest.php b/src/php/tests/unit_tests/SecureEndToEndTest.php
index e358abe2d2..dff4e878ea 100644
--- a/src/php/tests/unit_tests/SecureEndToEndTest.php
+++ b/src/php/tests/unit_tests/SecureEndToEndTest.php
@@ -44,9 +44,6 @@ class SecureEndToEndTest extends PHPUnit_Framework_TestCase
public function tearDown()
{
$this->channel->close();
- $channel_clean_persistent =
- new Grpc\Channel('localhost:50010', []);
- $channel_clean_persistent->cleanPersistentList();
}
public function testSimpleRequestBody()
diff --git a/src/php/tests/unit_tests/ServerTest.php b/src/php/tests/unit_tests/ServerTest.php
index d18feecefe..fee9f1e644 100644
--- a/src/php/tests/unit_tests/ServerTest.php
+++ b/src/php/tests/unit_tests/ServerTest.php
@@ -27,9 +27,6 @@ class ServerTest extends PHPUnit_Framework_TestCase
public function tearDown()
{
unset($this->server);
- $channel_clean_persistent =
- new Grpc\Channel('localhost:50010', []);
- $channel_clean_persistent->cleanPersistentList();
}
public function testConstructorWithNull()
diff --git a/src/php/tests/unit_tests/TimevalTest.php b/src/php/tests/unit_tests/TimevalTest.php
index be023adace..bc307ef7f1 100644
--- a/src/php/tests/unit_tests/TimevalTest.php
+++ b/src/php/tests/unit_tests/TimevalTest.php
@@ -25,9 +25,6 @@ class TimevalTest extends PHPUnit_Framework_TestCase
public function tearDown()
{
unset($this->time);
- $channel_clean_persistent =
- new Grpc\Channel('localhost:50010', []);
- $channel_clean_persistent->cleanPersistentList();
}
public function testConstructorWithInt()