php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #67623
Patch gearman-ssl.patch revision 2014-07-17 07:24 UTC by chjgcn at gmail dot com
revision 2014-07-15 12:59 UTC by chjgcn at gmail dot com

Patch gearman-ssl.patch for gearman Bug #67623

Patch version 2014-07-17 07:24 UTC

Return to Bug #67623 | Download this patch
This patch renders other patches obsolete

Obsolete patches:

Patch Revisions:

Developer: chjgcn@gmail.com

--- php_gearman.c	2013-08-29 13:03:54.000000000 +0800
+++ php_gearman.c	2014-07-17 14:57:14.578545921 +0800
@@ -378,6 +378,21 @@
 	ZEND_ARG_INFO(0, timeout)
 ZEND_END_ARG_INFO()
 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_gearman_client_set_ssl, 0, 0, 5)
+	ZEND_ARG_INFO(0, client_object)
+	ZEND_ARG_INFO(0, ssl)
+	ZEND_ARG_INFO(0, ca_file)
+	ZEND_ARG_INFO(0, certificate)
+	ZEND_ARG_INFO(0, key_file)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_oo_gearman_client_set_ssl, 0, 0, 4)
+	ZEND_ARG_INFO(0, ssl)
+	ZEND_ARG_INFO(0, ca_file)
+	ZEND_ARG_INFO(0, certificate)
+	ZEND_ARG_INFO(0, key_file)
+ZEND_END_ARG_INFO()
+
 ZEND_BEGIN_ARG_INFO_EX(arginfo_gearman_client_add_server, 0, 0, 3)
 	ZEND_ARG_INFO(0, client_object)
 	ZEND_ARG_INFO(0, host)
@@ -835,6 +850,21 @@
 	ZEND_ARG_INFO(0, timeout)
 ZEND_END_ARG_INFO()
 
+ZEND_BEGIN_ARG_INFO_EX(arginfo_gearman_worker_set_ssl, 0, 0, 5)
+	ZEND_ARG_INFO(0, worker_object)
+	ZEND_ARG_INFO(0, ssl)
+	ZEND_ARG_INFO(0, ca_file)
+	ZEND_ARG_INFO(0, certificate)
+	ZEND_ARG_INFO(0, key_file)
+ZEND_END_ARG_INFO()
+
+ZEND_BEGIN_ARG_INFO_EX(arginfo_oo_gearman_worker_set_ssl, 0, 0, 4)
+	ZEND_ARG_INFO(0, ssl)
+	ZEND_ARG_INFO(0, ca_file)
+	ZEND_ARG_INFO(0, certificate)
+	ZEND_ARG_INFO(0, key_file)
+ZEND_END_ARG_INFO()
+
 ZEND_BEGIN_ARG_INFO_EX(arginfo_gearman_worker_set_id, 0, 0, 2)
 	ZEND_ARG_INFO(0, worker_object)
 	ZEND_ARG_INFO(0, id)
@@ -1889,6 +1919,41 @@
 }
 /* }}} */
 
+/* {{{ proto void gearman_client_set_ssl(object client, constant timeout, constant ca_file,
+										 constant certificate, constant key_file)
+   Set SSL for a client structure. */
+PHP_FUNCTION(gearman_client_set_ssl) {
+	zval *zobj;
+	gearman_client_obj *obj;
+	bool ssl = false;
+	char *ca_file = NULL;
+	char *certificate = NULL;
+	char *key_file = NULL;
+	int ca_file_len = 0;
+	int certificate_len = 0;
+	int key_file_len = 0;
+
+	GEARMAN_ZPMP(RETURN_NULL(), "b|sss", &zobj, gearman_client_ce,
+				&ssl,
+				&ca_file, &ca_file_len,
+				&certificate, &certificate_len,
+				&key_file, &key_file_len)
+
+	if (ca_file == NULL) {
+		cfg_get_string("gearman.ssl_ca_file", &ca_file);
+	}
+	if (certificate == NULL) {
+		cfg_get_string("gearman.ssl_certificate", &certificate);
+	}
+	if (key_file == NULL) {
+		cfg_get_string("gearman.ssl_key_file", &key_file);
+	}
+
+	gearman_client_set_ssl(&(obj->client), ssl, ca_file, certificate, key_file);
+	RETURN_TRUE;
+}
+/* }}} */
+
 /* {{{ proto bool gearman_client_add_server(object client [, string host [, int port]])
    Add a job server to a client. This goes into a list of servers than can be used to run tasks. No socket I/O happens here, it is just added to a list. */
 PHP_FUNCTION(gearman_client_add_server) {
@@ -1908,10 +1973,6 @@
 		RETURN_FALSE;
 	}
 
-	if (!gearman_client_set_server_option(&(obj->client), "exceptions", (sizeof("exceptions") - 1))) {
-	    GEARMAN_EXCEPTION("Failed to set exception option", 0);
-	}
-
 	RETURN_TRUE;
 }
 /* }}} */
@@ -1934,10 +1995,6 @@
 		RETURN_FALSE;
 	}
 
-	if (!gearman_client_set_server_option(&(obj->client), "exceptions", (sizeof("exceptions") - 1))) {
-	    GEARMAN_EXCEPTION("Failed to set exception option", 0);
-	}
-
 	RETURN_TRUE;
 }
 /* }}} */
@@ -3055,6 +3112,12 @@
 	obj->zexception_fn= zexception_fn;
 	Z_ADDREF_P(zexception_fn);
 
+	if (!gearman_client_has_option(&(obj->client), GEARMAN_CLIENT_EXCEPTION)) {
+		if (!gearman_client_set_server_option(&(obj->client), "exceptions", (sizeof("exceptions") - 1))) {
+			GEARMAN_EXCEPTION("Failed to set exception option", 0);
+		}
+	}
+
 	/* set the callback for php */
 	gearman_client_set_exception_fn(&(obj->client), _php_task_exception_fn);
 
@@ -3348,6 +3411,41 @@
 }
 /* }}} */
 
+/* {{{ proto void gearman_worker_set_ssl(object worker, constant timeout, constant ca_file,
+										 constant certificate, constant key_file)
+   Set SSL for a worker structure. */
+PHP_FUNCTION(gearman_worker_set_ssl) {
+	zval *zobj;
+	gearman_worker_obj *obj;
+	bool ssl = false;
+	char *ca_file = NULL;
+	char *certificate = NULL;
+	char *key_file = NULL;
+	int ca_file_len = 0;
+	int certificate_len = 0;
+	int key_file_len = 0;
+
+	GEARMAN_ZPMP(RETURN_NULL(), "b|sss", &zobj, gearman_worker_ce,
+				 &ssl,
+				 &ca_file, &ca_file_len,
+				 &certificate, &certificate_len,
+				 &key_file, &key_file_len)
+
+	if (ca_file == NULL) {
+		cfg_get_string("gearman.ssl_ca_file", &ca_file);
+	}
+	if (certificate == NULL) {
+		cfg_get_string("gearman.ssl_certificate", &certificate);
+	}
+	if (key_file == NULL) {
+		cfg_get_string("gearman.ssl_key_file", &key_file);
+	}
+
+	gearman_worker_set_ssl(&(obj->worker), ssl, ca_file, certificate, key_file);
+	RETURN_TRUE;
+}
+/* }}} */
+
 /* {{{ proto void gearman_worker_set_id(object worker, string id)
    Set id for a worker structure. */
 PHP_FUNCTION(gearman_worker_set_id) {
@@ -3385,10 +3483,6 @@
 		RETURN_FALSE;
 	}
 
-	if (! gearman_worker_set_server_option(&(obj->worker), "exceptions", (sizeof("exceptions") - 1))) {
-		GEARMAN_EXCEPTION("Failed to set exception option", 0);
-	}
-
 	RETURN_TRUE;
 }
 /* }}} */
@@ -3411,10 +3505,6 @@
 		RETURN_FALSE;
 	}
 
-	if (! gearman_worker_set_server_option(&(obj->worker), "exceptions", (sizeof("exceptions") - 1))) {
-		GEARMAN_EXCEPTION("Failed to set exception option", 0);
-	}
-
 	RETURN_TRUE;
 }
 /* }}} */
@@ -4107,6 +4197,7 @@
 	PHP_FE(gearman_client_remove_options, arginfo_gearman_client_remove_options)
 	PHP_FE(gearman_client_timeout, arginfo_gearman_client_timeout)
 	PHP_FE(gearman_client_set_timeout, arginfo_gearman_client_set_timeout)
+	PHP_FE(gearman_client_set_ssl, arginfo_gearman_client_set_ssl)
 	PHP_FE(gearman_client_context, arginfo_gearman_client_context)
 	PHP_FE(gearman_client_set_context, arginfo_gearman_client_set_context)
 #if jluedke_0
@@ -4184,6 +4275,7 @@
 	PHP_FE(gearman_worker_remove_options, arginfo_gearman_worker_remove_options)
 	PHP_FE(gearman_worker_timeout, arginfo_gearman_worker_timeout)
 	PHP_FE(gearman_worker_set_timeout, arginfo_gearman_worker_set_timeout)
+	PHP_FE(gearman_worker_set_ssl, arginfo_gearman_worker_set_ssl)
 	PHP_FE(gearman_worker_set_id, arginfo_gearman_worker_set_id)
 #if jluedke_0
 	PHP_FE(gearman_worker_context, arginfo_gearman_worker_context)
@@ -4274,6 +4366,7 @@
 	__PHP_ME_MAPPING(removeOptions, gearman_client_remove_options, arginfo_oo_gearman_client_remove_options, 0)
 	__PHP_ME_MAPPING(timeout, gearman_client_timeout, arginfo_oo_gearman_client_timeout, 0)
 	__PHP_ME_MAPPING(setTimeout, gearman_client_set_timeout, arginfo_oo_gearman_client_set_timeout, 0)
+	__PHP_ME_MAPPING(setSSL, gearman_client_set_ssl, arginfo_oo_gearman_client_set_ssl, 0)
 	__PHP_ME_MAPPING(context, gearman_client_context, arginfo_oo_gearman_client_context, 0)
 	__PHP_ME_MAPPING(setContext, gearman_client_set_context, arginfo_oo_gearman_client_set_context, 0)
 #if jluedke_0
@@ -4357,6 +4450,7 @@
 	__PHP_ME_MAPPING(removeOptions, gearman_worker_remove_options, arginfo_oo_gearman_worker_remove_options, 0)
 	__PHP_ME_MAPPING(timeout, gearman_worker_timeout, arginfo_oo_gearman_worker_timeout, 0)
 	__PHP_ME_MAPPING(setTimeout, gearman_worker_set_timeout, arginfo_oo_gearman_worker_set_timeout, 0)
+	__PHP_ME_MAPPING(setSSL, gearman_worker_set_ssl, arginfo_oo_gearman_worker_set_ssl, 0)
 	__PHP_ME_MAPPING(setId, gearman_worker_set_id, arginfo_oo_gearman_worker_set_id, 0)
 #if jluedke_0
 	__PHP_ME_MAPPING(context, gearman_worker_context, arginfo_oo_gearman_worker_context, 0)
@@ -4894,6 +4988,15 @@
 	REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_FREE_TASKS",
 		GEARMAN_CLIENT_FREE_TASKS,
 		CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_GENERATE_UNIQUE",
+		GEARMAN_CLIENT_GENERATE_UNIQUE,
+		CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_EXCEPTION",
+		GEARMAN_CLIENT_EXCEPTION,
+		CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_SSL",
+		GEARMAN_CLIENT_SSL,
+		CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_STATE_IDLE",
 		GEARMAN_CLIENT_STATE_IDLE,
 		CONST_CS | CONST_PERSISTENT);
@@ -4933,6 +5036,15 @@
 	REGISTER_LONG_CONSTANT("GEARMAN_WORKER_TIMEOUT_RETURN",
 		GEARMAN_WORKER_TIMEOUT_RETURN,
 		CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("GEARMAN_WORKER_GRAB_ALL",
+		GEARMAN_WORKER_GRAB_ALL,
+		CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("GEARMAN_WORKER_SSL",
+		GEARMAN_WORKER_SSL,
+		CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("GEARMAN_WORKER_IDENTIFIER",
+		GEARMAN_WORKER_IDENTIFIER,
+		CONST_CS | CONST_PERSISTENT);
 	REGISTER_LONG_CONSTANT("GEARMAN_WORKER_STATE_START",
 		GEARMAN_WORKER_STATE_START,
 		CONST_CS | CONST_PERSISTENT);
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 07 01:01:30 2024 UTC