summaryrefslogtreecommitdiff
path: root/php
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2017-01-30 13:45:21 -0800
committerMark Spruiell <mes@zeroc.com>2017-01-30 13:45:21 -0800
commit61270a10f980933cf582edb766f10c8ac6d86e8a (patch)
tree45ab4a7c2986954054fce613bc3c8f7967e7951e /php
parentFix slice2cpp build failure (diff)
downloadice-61270a10f980933cf582edb766f10c8ac6d86e8a.tar.bz2
ice-61270a10f980933cf582edb766f10c8ac6d86e8a.tar.xz
ice-61270a10f980933cf582edb766f10c8ac6d86e8a.zip
merging IceBridge into master
Diffstat (limited to 'php')
-rw-r--r--php/src/php5/Connection.cpp35
-rw-r--r--php/src/php5/Util.cpp4
-rw-r--r--php/src/php7/Connection.cpp57
-rw-r--r--php/src/php7/Util.cpp4
-rw-r--r--php/test/Ice/acm/Client.php52
-rw-r--r--php/test/Ice/acm/Test.ice3
-rw-r--r--php/test/Ice/binding/Client.php23
7 files changed, 153 insertions, 25 deletions
diff --git a/php/src/php5/Connection.cpp b/php/src/php5/Connection.cpp
index 1d85343ed37..68827e63243 100644
--- a/php/src/php5/Connection.cpp
+++ b/php/src/php5/Connection.cpp
@@ -78,15 +78,22 @@ ZEND_METHOD(Ice_Connection, close)
Ice::ConnectionPtr _this = Wrapper<Ice::ConnectionPtr>::value(getThis() TSRMLS_CC);
assert(_this);
- zend_bool b;
- if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, const_cast<char*>("b"), &b TSRMLS_CC) != SUCCESS)
+ zval* mode;
+ if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, const_cast<char*>("z"), &mode TSRMLS_CC) != SUCCESS)
{
RETURN_NULL();
}
+ if(Z_TYPE_P(mode) != IS_LONG)
+ {
+ invalidArgument("value for 'mode' argument must be an enumerator of ConnectionClose" TSRMLS_CC);
+ RETURN_NULL();
+ }
+ Ice::ConnectionClose cc = static_cast<Ice::ConnectionClose>(Z_LVAL_P(mode));
+
try
{
- _this->close(b ? true : false);
+ _this->close(cc);
}
catch(const IceUtil::Exception& ex)
{
@@ -140,6 +147,27 @@ ZEND_METHOD(Ice_Connection, flushBatchRequests)
}
}
+ZEND_METHOD(Ice_Connection, heartbeat)
+{
+ if(ZEND_NUM_ARGS() > 0)
+ {
+ WRONG_PARAM_COUNT;
+ }
+
+ Ice::ConnectionPtr _this = Wrapper<Ice::ConnectionPtr>::value(getThis() TSRMLS_CC);
+ assert(_this);
+
+ try
+ {
+ _this->heartbeat();
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ throwException(ex TSRMLS_CC);
+ RETURN_NULL();
+ }
+}
+
ZEND_METHOD(Ice_Connection, setACM)
{
Ice::ConnectionPtr _this = Wrapper<Ice::ConnectionPtr>::value(getThis() TSRMLS_CC);
@@ -411,6 +439,7 @@ static zend_function_entry _connectionClassMethods[] =
ZEND_ME(Ice_Connection, close, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, getEndpoint, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, flushBatchRequests, ICE_NULLPTR, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_Connection, heartbeat, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, setACM, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, getACM, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, type, ICE_NULLPTR, ZEND_ACC_PUBLIC)
diff --git a/php/src/php5/Util.cpp b/php/src/php5/Util.cpp
index 24374f91049..1f3ea98fb8e 100644
--- a/php/src/php5/Util.cpp
+++ b/php/src/php5/Util.cpp
@@ -618,6 +618,10 @@ convertLocalException(const Ice::LocalException& ex, zval* zex TSRMLS_DC)
{
setStringMember(zex, "reason", e.reason TSRMLS_CC);
}
+ catch(const Ice::ConnectionManuallyClosedException& e)
+ {
+ add_property_bool(zex, "graceful", e.graceful ? 1 : 0);
+ }
catch(const Ice::LocalException&)
{
//
diff --git a/php/src/php7/Connection.cpp b/php/src/php7/Connection.cpp
index 2d598fc7da9..57c0b197767 100644
--- a/php/src/php7/Connection.cpp
+++ b/php/src/php7/Connection.cpp
@@ -78,15 +78,22 @@ ZEND_METHOD(Ice_Connection, close)
Ice::ConnectionPtr _this = Wrapper<Ice::ConnectionPtr>::value(getThis());
assert(_this);
- zend_bool b;
- if(zend_parse_parameters(ZEND_NUM_ARGS(), const_cast<char*>("b"), &b) != SUCCESS)
+ zval* mode;
+ if(zend_parse_parameters(ZEND_NUM_ARGS(), const_cast<char*>("z"), &mode) != SUCCESS)
{
RETURN_NULL();
}
+ if(Z_TYPE_P(mode) != IS_LONG)
+ {
+ invalidArgument("value for 'mode' argument must be an enumerator of ConnectionClose");
+ RETURN_NULL();
+ }
+ Ice::ConnectionClose cc = static_cast<Ice::ConnectionClose>(Z_LVAL_P(mode));
+
try
{
- _this->close(b ? true : false);
+ _this->close(cc);
}
catch(const IceUtil::Exception& ex)
{
@@ -140,6 +147,27 @@ ZEND_METHOD(Ice_Connection, flushBatchRequests)
}
}
+ZEND_METHOD(Ice_Connection, heartbeat)
+{
+ if(ZEND_NUM_ARGS() > 0)
+ {
+ WRONG_PARAM_COUNT;
+ }
+
+ Ice::ConnectionPtr _this = Wrapper<Ice::ConnectionPtr>::value(getThis());
+ assert(_this);
+
+ try
+ {
+ _this->heartbeat();
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ throwException(ex);
+ RETURN_NULL();
+ }
+}
+
ZEND_METHOD(Ice_Connection, setACM)
{
Ice::ConnectionPtr _this = Wrapper<Ice::ConnectionPtr>::value(getThis());
@@ -331,6 +359,27 @@ ZEND_METHOD(Ice_Connection, setBufferSize)
}
}
+ZEND_METHOD(Ice_Connection, throwException)
+{
+ if(ZEND_NUM_ARGS() > 0)
+ {
+ WRONG_PARAM_COUNT;
+ }
+
+ Ice::ConnectionPtr _this = Wrapper<Ice::ConnectionPtr>::value(getThis());
+ assert(_this);
+
+ try
+ {
+ _this->throwException();
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ throwException(ex);
+ RETURN_NULL();
+ }
+}
+
#ifdef _WIN32
extern "C"
#endif
@@ -406,6 +455,7 @@ static zend_function_entry _connectionClassMethods[] =
ZEND_ME(Ice_Connection, close, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, getEndpoint, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, flushBatchRequests, ICE_NULLPTR, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_Connection, heartbeat, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, setACM, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, getACM, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, type, ICE_NULLPTR, ZEND_ACC_PUBLIC)
@@ -413,6 +463,7 @@ static zend_function_entry _connectionClassMethods[] =
ZEND_ME(Ice_Connection, toString, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, getInfo, ICE_NULLPTR, ZEND_ACC_PUBLIC)
ZEND_ME(Ice_Connection, setBufferSize, ICE_NULLPTR, ZEND_ACC_PUBLIC)
+ ZEND_ME(Ice_Connection, throwException, ICE_NULLPTR, ZEND_ACC_PUBLIC)
{0, 0, 0}
};
diff --git a/php/src/php7/Util.cpp b/php/src/php7/Util.cpp
index 0399c940cb1..bb38b45066a 100644
--- a/php/src/php7/Util.cpp
+++ b/php/src/php7/Util.cpp
@@ -565,6 +565,10 @@ convertLocalException(const Ice::LocalException& ex, zval* zex)
{
setStringMember(zex, "reason", e.reason);
}
+ catch(const Ice::ConnectionManuallyClosedException& e)
+ {
+ add_property_bool(zex, "graceful", e.graceful ? 1 : 0);
+ }
catch(const Ice::LocalException&)
{
//
diff --git a/php/test/Ice/acm/Client.php b/php/test/Ice/acm/Client.php
index 387cf2b1d4e..b1b3a0bbd84 100644
--- a/php/test/Ice/acm/Client.php
+++ b/php/test/Ice/acm/Client.php
@@ -30,16 +30,13 @@ function test($b)
}
}
-function allTests($communicator)
+function testSetACM($communicator, $com)
{
global $NS;
echo "testing setACM/getACM... ";
flush();
- $ref = "communicator:default -p 12010";
- $com = $communicator->stringToProxy($ref)->ice_uncheckedCast("::Test::RemoteCommunicator");
-
$adapter = $com->createObjectAdapter(-1, -1, -1);
$initData = $NS ? eval("return new Ice\\InitializationData;") : new Ice_InitializationData;
@@ -83,21 +80,60 @@ function allTests($communicator)
test($acm->close == $CloseOnInvocationAndIdle);
test($acm->heartbeat == $HeartbeatAlways);
- $proxy->waitForHeartbeat(2);
+ $proxy->startHeartbeatCount();
+ $proxy->waitForHeartbeatCount(2);
$adapter->deactivate();
$testCommunicator->destroy();
echo "ok\n";
+}
+
+function testHeartbeatManual($communicator, $com)
+{
+ global $NS;
- echo "shutting down... ";
+ echo "testing manual heartbeats... ";
flush();
- $com->shutdown();
+
+ $adapter = $com->createObjectAdapter(10, -1, 0);
+
+ $initData = $NS ? eval("return new Ice\\InitializationData;") : new Ice_InitializationData;
+ $initData->properties = $communicator->getProperties()->clone();
+ $initData->properties->setProperty("Ice.ACM.Timeout", "10");
+ $initData->properties->setProperty("Ice.ACM.Client.Timeout", "10");
+ $initData->properties->setProperty("Ice.ACM.Client.Close", "0");
+ $initData->properties->setProperty("Ice.ACM.Client.Heartbeat", "0");
+ $testCommunicator = $NS ? eval("return Ice\\initialize(\$initData);") : Ice_initialize($initData);
+ $proxy = $testCommunicator->stringToProxy($adapter->getTestIntf()->ice_toString())->ice_uncheckedCast(
+ "::Test::TestIntf");
+ $con = $proxy->ice_getConnection();
+
+ $proxy->startHeartbeatCount();
+ $con->heartbeat();
+ $con->heartbeat();
+ $con->heartbeat();
+ $con->heartbeat();
+ $con->heartbeat();
+ $proxy->waitForHeartbeatCount(5);
+
+ $adapter->deactivate();
+ $testCommunicator->destroy();
echo "ok\n";
}
+function allTests($communicator)
+{
+ $ref = "communicator:default -p 12010";
+ $com = $communicator->stringToProxy($ref)->ice_uncheckedCast("::Test::RemoteCommunicator");
+
+ testSetACM($communicator, $com);
+ testHeartbeatManual($communicator, $com);
+
+ $com->shutdown();
+}
+
$communicator = $NS ? eval("return Ice\\initialize(\$argv);") :
eval("return Ice_initialize(\$argv);");
-
allTests($communicator);
$communicator->destroy();
diff --git a/php/test/Ice/acm/Test.ice b/php/test/Ice/acm/Test.ice
index 5ab98180dd3..d78abd6eb0f 100644
--- a/php/test/Ice/acm/Test.ice
+++ b/php/test/Ice/acm/Test.ice
@@ -17,7 +17,8 @@ interface TestIntf
void sleep(int seconds);
void sleepAndHold(int seconds);
void interruptSleep();
- void waitForHeartbeat(int count);
+ void startHeartbeatCount();
+ void waitForHeartbeatCount(int count);
};
interface RemoteObjectAdapter
diff --git a/php/test/Ice/binding/Client.php b/php/test/Ice/binding/Client.php
index 378981ce357..291188e5e2c 100644
--- a/php/test/Ice/binding/Client.php
+++ b/php/test/Ice/binding/Client.php
@@ -61,6 +61,9 @@ function allTests($communicator)
$random = $NS ? constant("Ice\\EndpointSelectionType::Random") : constant("Ice_EndpointSelectionType::Random");
$ordered = $NS ? constant("Ice\\EndpointSelectionType::Ordered") : constant("Ice_EndpointSelectionType::Ordered");
+ $closeGracefullyAndWait =
+ $NS ? constant("Ice\\ConnectionClose::CloseGracefullyAndWait") :
+ constant("Ice_ConnectionClose::CloseGracefullyAndWait");
$ref = "communicator:default -p 12010";
$com = $communicator->stringToProxy($ref)->ice_uncheckedCast("::Test::RemoteCommunicator");
@@ -130,7 +133,7 @@ function allTests($communicator)
{
unset($names[$key]);
}
- $test1->ice_getConnection()->close(false);
+ $test1->ice_getConnection()->close($closeGracefullyAndWait);
}
//
@@ -151,7 +154,7 @@ function allTests($communicator)
foreach($adapters as $p)
{
- $p->getTestIntf()->ice_getConnection()->close(false);
+ $p->getTestIntf()->ice_getConnection()->close($closeGracefullyAndWait);
}
}
@@ -179,7 +182,7 @@ function allTests($communicator)
{
unset($names[$key]);
}
- $test1->ice_getConnection()->close(false);
+ $test1->ice_getConnection()->close($closeGracefullyAndWait);
}
//
@@ -213,7 +216,7 @@ function allTests($communicator)
{
unset($names[$key]);
}
- $test->ice_getConnection()->close(false);
+ $test->ice_getConnection()->close($closeGracefullyAndWait);
}
$test = $test->ice_endpointSelection($random)->ice_uncheckedCast("::Test::TestIntf");
@@ -227,7 +230,7 @@ function allTests($communicator)
{
unset($names[$key]);
}
- $test->ice_getConnection()->close(false);
+ $test->ice_getConnection()->close($closeGracefullyAndWait);
}
deactivate($com, $adapters);
@@ -285,11 +288,11 @@ function allTests($communicator)
$adapters[] = $com->createObjectAdapter("Adapter36", $endpoints[2]->toString());
for($i = 0; $i < $nRetry && $test->getAdapterName() == "Adapter36"; $i++);
test($i == $nRetry);
- $test->ice_getConnection()->close(false);
+ $test->ice_getConnection()->close($closeGracefullyAndWait);
$adapters[] = $com->createObjectAdapter("Adapter35", $endpoints[1]->toString());
for($i = 0; $i < $nRetry && $test->getAdapterName() == "Adapter35"; $i++);
test($i == $nRetry);
- $test->ice_getConnection()->close(false);
+ $test->ice_getConnection()->close($closeGracefullyAndWait);
$adapters[] = $com->createObjectAdapter("Adapter34", $endpoints[0]->toString());
for($i = 0; $i < $nRetry && $test->getAdapterName() == "Adapter34"; $i++);
test($i == $nRetry);
@@ -475,7 +478,7 @@ function allTests($communicator)
for($i = 0; $i < 5; $i++)
{
test($test->getAdapterName() == "Adapter82");
- $test->ice_getConnection()->close(false);
+ $test->ice_getConnection()->close($closeGracefullyAndWait);
}
$testSecure = $test->ice_secure(true)->ice_uncheckedCast("::Test::TestIntf");
@@ -491,7 +494,7 @@ function allTests($communicator)
for($i = 0; $i < 5; $i++)
{
test($test->getAdapterName() == "Adapter81");
- $test->ice_getConnection()->close(false);
+ $test->ice_getConnection()->close($closeGracefullyAndWait);
}
$endpts = $test->ice_getEndpoints();
@@ -500,7 +503,7 @@ function allTests($communicator)
for($i = 0; $i < 5; $i++)
{
test($test->getAdapterName() == "Adapter83");
- $test->ice_getConnection()->close(false);
+ $test->ice_getConnection()->close($closeGracefullyAndWait);
}
$com->deactivateObjectAdapter($adapters[0]);