[PECL-CVS] [pecl-networking-gearman] master: Merge pull request #52 from php/expose-stop-wait-on-signal

[email protected] (Rasmus Lerdorf via GitHub) Sat, 4 Apr 2026 13:24:37 +0000
Newsgroups php.pecl.cvs
Message-ID <[email protected]>
Author: Rasmus Lerdorf (rlerdorf)
Committer: GitHub (web-flow)
Pusher: rlerdorf
Date: 2026-04-04T14:24:34+01:00

Commit: https://github.com/php/pecl-networking-gearman/commit/7ea2e2bac9ddbd83feb3eae9d5df4b9caec2446b
Raw diff: https://github.com/php/pecl-networking-gearman/commit/7ea2e2bac9ddbd83feb3eae9d5df4b9caec2446b.diff

Merge pull request #52 from php/expose-stop-wait-on-signal

fixes #51

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


Diff:

diff --git a/const_gen.sh b/const_gen.sh
index 2b27f0a..cfe74b2 100755
--- a/const_gen.sh
+++ b/const_gen.sh
@@ -33,6 +33,7 @@ awk 'BEGIN { p= 1; } \
      { if (p == 1) { print $0; } }' php_gearman.c >> php_gearman.c.new
 
 grep ' GEARMAN' $header | \
+  grep -v 'STOP_WAIT_ON_SIGNAL' | \
   sed 's/.*\(GEARMAN[A-Z0-9_]*\).*/\1/' | \
   sed 's/\(.*\)/	REGISTER_LONG_CONSTANT("\1",\
 		\1,\
diff --git a/php_gearman.c b/php_gearman.c
index 474039e..f62756d 100644
--- a/php_gearman.c
+++ b/php_gearman.c
@@ -604,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..a377fd2
--- /dev/null
+++ b/tests/gearman_client_023.phpt
@@ -0,0 +1,22 @@
+--TEST--
+GEARMAN_CLIENT_STOP_WAIT_ON_SIGNAL constant and addOptions()
+--SKIPIF--
+<?php
+if (!extension_loaded("gearman")) die("skip");
+if (!defined("GEARMAN_CLIENT_STOP_WAIT_ON_SIGNAL")) die("skip libgearman too old");
+?>
+--FILE--
+<?php
+$client = new GearmanClient();
+$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..bd7b282
--- /dev/null
+++ b/tests/gearman_worker_019.phpt
@@ -0,0 +1,22 @@
+--TEST--
+GEARMAN_WORKER_STOP_WAIT_ON_SIGNAL constant and addOptions()
+--SKIPIF--
+<?php
+if (!extension_loaded("gearman")) die("skip");
+if (!defined("GEARMAN_WORKER_STOP_WAIT_ON_SIGNAL")) die("skip libgearman too old");
+?>
+--FILE--
+<?php
+$worker = new GearmanWorker();
+$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