[PECL-CVS] [pecl-networking-gearman] expose-stop-wait-on-signal: address reviews

[email protected] (Rasmus Lerdorf) Sat, 4 Apr 2026 13:02:51 +0000
Newsgroups php.pecl.cvs
Message-ID <[email protected]>
Author: Rasmus Lerdorf (rlerdorf)
Date: 2026-04-04T09:02:45-04:00

Commit: https://github.com/php/pecl-networking-gearman/commit/2e123d488a64f7c71a1b0ea3b29c8d5501a80208
Raw diff: https://github.com/php/pecl-networking-gearman/commit/2e123d488a64f7c71a1b0ea3b29c8d5501a80208.diff

address reviews

Changed paths:
  A  tests/gearman_client_023.phpt
  A  tests/gearman_worker_019.phpt
  M  php_gearman.c


Diff:

diff --git a/php_gearman.c b/php_gearman.c
index 548f4ee..f62756d 100644
--- a/php_gearman.c
+++ b/php_gearman.c
@@ -545,11 +545,6 @@ PHP_MINIT_FUNCTION(gearman) {
 	REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_FREE_TASKS",
 		GEARMAN_CLIENT_FREE_TASKS,
 		CONST_CS | CONST_PERSISTENT);
-#ifdef GEARMAN_CLIENT_STOP_WAIT_ON_SIGNAL
-	REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_STOP_WAIT_ON_SIGNAL",
-		GEARMAN_CLIENT_STOP_WAIT_ON_SIGNAL,
-		CONST_CS | CONST_PERSISTENT);
-#endif
 	REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_STATE_IDLE",
 		GEARMAN_CLIENT_STATE_IDLE,
 		CONST_CS | CONST_PERSISTENT);
@@ -589,11 +584,6 @@ PHP_MINIT_FUNCTION(gearman) {
 	REGISTER_LONG_CONSTANT("GEARMAN_WORKER_TIMEOUT_RETURN",
 		GEARMAN_WORKER_TIMEOUT_RETURN,
 		CONST_CS | CONST_PERSISTENT);
-#ifdef GEARMAN_WORKER_STOP_WAIT_ON_SIGNAL
-	REGISTER_LONG_CONSTANT("GEARMAN_WORKER_STOP_WAIT_ON_SIGNAL",
-		GEARMAN_WORKER_STOP_WAIT_ON_SIGNAL,
-		CONST_CS | CONST_PERSISTENT);
-#endif
 	REGISTER_LONG_CONSTANT("GEARMAN_WORKER_STATE_START",
 		GEARMAN_WORKER_STATE_START,
 		CONST_CS | CONST_PERSISTENT);
@@ -614,6 +604,17 @@ PHP_MINIT_FUNCTION(gearman) {
 		CONST_CS | CONST_PERSISTENT);
 	/* CONST_GEN_STOP */
 
+#ifdef GEARMAN_CLIENT_STOP_WAIT_ON_SIGNAL
+	REGISTER_LONG_CONSTANT("GEARMAN_CLIENT_STOP_WAIT_ON_SIGNAL",
+		GEARMAN_CLIENT_STOP_WAIT_ON_SIGNAL,
+		CONST_CS | CONST_PERSISTENT);
+#endif
+#ifdef GEARMAN_WORKER_STOP_WAIT_ON_SIGNAL
+	REGISTER_LONG_CONSTANT("GEARMAN_WORKER_STOP_WAIT_ON_SIGNAL",
+		GEARMAN_WORKER_STOP_WAIT_ON_SIGNAL,
+		CONST_CS | CONST_PERSISTENT);
+#endif
+
 	return SUCCESS;
 }
 
diff --git a/tests/gearman_client_023.phpt b/tests/gearman_client_023.phpt
new file mode 100644
index 0000000..95dee1f
--- /dev/null
+++ b/tests/gearman_client_023.phpt
@@ -0,0 +1,23 @@
+--TEST--
+GEARMAN_CLIENT_STOP_WAIT_ON_SIGNAL constant and addOptions()
+--SKIPIF--
+<?php
+if (!extension_loaded("gearman")) print "skip";
+if (!defined("GEARMAN_CLIENT_STOP_WAIT_ON_SIGNAL")) print "skip libgearman too old";
+?>
+--FILE--
+<?php
+$client = new GearmanClient();
+$before = $client->options();
+$client->addOptions(GEARMAN_CLIENT_STOP_WAIT_ON_SIGNAL);
+$after = $client->options();
+var_dump(($after & GEARMAN_CLIENT_STOP_WAIT_ON_SIGNAL) !== 0);
+$client->removeOptions(GEARMAN_CLIENT_STOP_WAIT_ON_SIGNAL);
+$removed = $client->options();
+var_dump(($removed & GEARMAN_CLIENT_STOP_WAIT_ON_SIGNAL) === 0);
+print "OK";
+?>
+--EXPECT--
+bool(true)
+bool(true)
+OK
diff --git a/tests/gearman_worker_019.phpt b/tests/gearman_worker_019.phpt
new file mode 100644
index 0000000..6d27fd7
--- /dev/null
+++ b/tests/gearman_worker_019.phpt
@@ -0,0 +1,23 @@
+--TEST--
+GEARMAN_WORKER_STOP_WAIT_ON_SIGNAL constant and addOptions()
+--SKIPIF--
+<?php
+if (!extension_loaded("gearman")) print "skip";
+if (!defined("GEARMAN_WORKER_STOP_WAIT_ON_SIGNAL")) print "skip libgearman too old";
+?>
+--FILE--
+<?php
+$worker = new GearmanWorker();
+$before = $worker->options();
+$worker->addOptions(GEARMAN_WORKER_STOP_WAIT_ON_SIGNAL);
+$after = $worker->options();
+var_dump(($after & GEARMAN_WORKER_STOP_WAIT_ON_SIGNAL) !== 0);
+$worker->removeOptions(GEARMAN_WORKER_STOP_WAIT_ON_SIGNAL);
+$removed = $worker->options();
+var_dump(($removed & GEARMAN_WORKER_STOP_WAIT_ON_SIGNAL) === 0);
+print "OK";
+?>
+--EXPECT--
+bool(true)
+bool(true)
+OK