Patch dbus-timeout.diff for DBus Bug #66504
Patch version 2014-01-17 07:29 UTC
Return to Bug #66504 |
Download this patch
Patch Revisions:
Developer: pavlonion@gmail.com
Index: php_dbus.h
===================================================================
--- php_dbus.h (1)
+++ php_dbus.h (2)
@@ -38,6 +38,8 @@
PHP_METHOD(Dbus, requestName);
PHP_METHOD(Dbus, registerObject);
PHP_METHOD(Dbus, createProxy);
+PHP_METHOD(Dbus, setTimeout);
+PHP_METHOD(Dbus, getTimeout);
PHP_METHOD(DbusObject, __construct);
PHP_METHOD(DbusObject, __call);
Index: dbus.c
===================================================================
--- dbus.c (1)
+++ dbus.c (2)
@@ -57,6 +57,8 @@
PHP_ME(Dbus, requestName, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Dbus, registerObject, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Dbus, createProxy, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Dbus, setTimeout, NULL, ZEND_ACC_PUBLIC)
+ PHP_ME(Dbus, getTimeout, NULL, ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
@@ -180,6 +182,7 @@
DBusConnection *con;
int useIntrospection;
HashTable objects; /* A hash with all the registered objects that can be called */
+ int timeout;
};
struct _php_dbus_object_obj {
@@ -469,6 +472,8 @@
zend_declare_class_constant_long(dbus_ce_dbus, "BUS_SESSION", sizeof("BUS_SESSION")-1, DBUS_BUS_SESSION TSRMLS_CC);
zend_declare_class_constant_long(dbus_ce_dbus, "BUS_SYSTEM", sizeof("BUS_SYSTEM")-1, DBUS_BUS_SYSTEM TSRMLS_CC);
+ zend_declare_class_constant_long(dbus_ce_dbus, "TIMEOUT_INFINITE", sizeof("TIMEOUT_INFINITE")-1, DBUS_TIMEOUT_INFINITE TSRMLS_CC);
+ zend_declare_class_constant_long(dbus_ce_dbus, "TIMEOUT_USE_DEFAULT", sizeof("TIMEOUT_USE_DEFAULT")-1, DBUS_TIMEOUT_USE_DEFAULT TSRMLS_CC);
INIT_CLASS_ENTRY(ce_dbus_object, "DbusObject", dbus_funcs_dbus_object);
ce_dbus_object.create_object = dbus_object_new_dbus_object;
@@ -1005,6 +1010,7 @@
dbusobj->con = con;
dbusobj->useIntrospection = introspect;
zend_hash_init(&dbusobj->objects, 16, NULL, dbus_registered_object_dtor, 0);
+ dbusobj->timeout = DBUS_TIMEOUT_USE_DEFAULT;
return 1;
}
@@ -1047,7 +1053,7 @@
dbus_message_iter_init_append(msg, &iter);
dbus_message_iter_append_basic(&iter, DBUS_TYPE_BOOLEAN, &bool_false);
- if (!dbus_connection_send_with_reply(dbus->con, msg, &pending, -1)) {
+ if (!dbus_connection_send_with_reply(dbus->con, msg, &pending, dbus->timeout)) {
dbus_message_unref(msg);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Out of memory.");
}
@@ -1144,6 +1150,38 @@
}
/* }}} */
+/* {{{ proto Dbus::setTimeout(int msec)
+ Set timeout for DbusObject calls
+*/
+PHP_METHOD(Dbus, setTimeout)
+{
+ zval *object = getThis();
+ php_dbus_obj *dbus;
+ int msec;
+
+ dbus_set_error_handling(EH_THROW, NULL TSRMLS_CC);
+ if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &msec))
+ {
+ dbus = (php_dbus_obj *) zend_object_store_get_object(object TSRMLS_CC);
+ Z_ADDREF_P(object);
+ dbus->timeout = msec;
+ }
+ dbus_set_error_handling(EH_NORMAL, NULL TSRMLS_CC);
+}
+/* }}} */
+
+/* {{{ proto Dbus::getTimeout()
+ Timeout for DbusObject calls
+*/
+PHP_METHOD(Dbus, getTimeout)
+{
+ zval *object = getThis();
+ php_dbus_obj *dbus = (php_dbus_obj *) zend_object_store_get_object(object TSRMLS_CC);
+ Z_ADDREF_P(object);
+ RETURN_LONG(dbus->timeout);
+}
+/* }}} */
+
static void php_dbus_accept_incoming_signal(DBusMessage *msg, zval **return_value TSRMLS_DC)
{
php_dbus_signal_obj *signalobj;
@@ -1958,7 +1996,7 @@
php_dbus_append_parameters(msg, data, dbus_object->introspect_xml ? php_dbus_find_method_node(dbus_object->introspect_xml->children, name) : NULL, PHP_DBUS_CALL_FUNCTION TSRMLS_CC);
/* send message and get a handle for a reply */
- if (!dbus_connection_send_with_reply(dbus_object->dbus->con, msg, &pending, -1)) {
+ if (!dbus_connection_send_with_reply(dbus_object->dbus->con, msg, &pending, dbus_object->dbus->timeout)) {
dbus_message_unref(msg);
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Out of memory.");
}
|