[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pecl-cvs
Subject:    [PECL-CVS] com pecl/networking/gearman: fix job handle returned by doBackground(): =?UTF-8?Q?php=5Fg
From:       Rasmus Lerdorf <rasmus () php ! net>
Date:       2016-07-14 22:40:47
Message-ID: php-mail-124ace2a2023b6306a981677ce897e061862457138 () git ! php ! net
[Download RAW message or body]

Commit:    a7389eddf350d59f19fce5fc9ad6569c6d2dfdd1
Author:    Xaver Loppenstedt <xaver@loppenstedt.de>         Fri, 1 Jul 2016 16:22:27 \
                +0200
Parents:   ab175f3e85213d7fc8583451eaa4f53dc4d7170c
Branches:  master

Link:       http://git.php.net/?p=pecl/networking/gearman.git;a=commitdiff;h=a7389eddf350d59f19fce5fc9ad6569c6d2dfdd1


Log:
fix job handle returned by doBackground()

Changed paths:
  M  php_gearman.c
  M  tests/gearman_worker_014.phpt


Diff:
diff --git a/php_gearman.c b/php_gearman.c
index 4b6fd9b..5b17311 100644
--- a/php_gearman.c
+++ b/php_gearman.c
@@ -2155,6 +2155,8 @@ static void \
gearman_client_do_background_work_handler(gearman_return_t (*do_back  job_handle->val
 					);
 
+	ZSTR_LEN(job_handle) = strnlen(ZSTR_VAL(job_handle), GEARMAN_JOB_HANDLE_SIZE-1);
+
 	if (! PHP_GEARMAN_CLIENT_RET_OK(obj->ret)) {
 		php_error_docref(NULL, E_WARNING, "%s",
 						 gearman_client_error(&(obj->client)));
diff --git a/tests/gearman_worker_014.phpt b/tests/gearman_worker_014.phpt
index 5b99ea5..c7e7c2b 100644
--- a/tests/gearman_worker_014.phpt
+++ b/tests/gearman_worker_014.phpt
@@ -17,8 +17,10 @@ $workload = '{"workload":"test"}';
 // Adding 2 jobs, one for OO and one for procedural
 $client = new GearmanClient();
 $client->addServer($host, $port);
+$handle = $client->doBackground($job, $workload);
 $client->doBackground($job, $workload);
-$client->doBackground($job, $workload);
+
+print "GearmanWorker::doBackground() (OO): \
".(preg_match('/^H:'.gethostname().':\d+$/', $handle) === 1? 'Success' : \
'Failure').PHP_EOL;  
 $worker = new GearmanWorker();
 $worker->addServer($host, $port);
@@ -39,6 +41,7 @@ function do_work($job) {
 }
 ?>
 --EXPECT--
+GearmanWorker::doBackground() (OO): Success
 Calling function do_work
 GearmanWorker::work() (OO): Success
 Calling function do_work


--
PECL CVS Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic