Enable cpu affinity function.
This commit is contained in:
parent
3a575e2cba
commit
188e4e6d88
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=433492
5 changed files with 68 additions and 2 deletions
|
@ -3,6 +3,7 @@
|
|||
|
||||
PORTNAME= swoole
|
||||
PORTVERSION= 1.9.5
|
||||
PORTREVISION= 1
|
||||
CATEGORIES= devel net
|
||||
MASTER_SITES= http://pecl.php.net/get/
|
||||
PKGNAMEPREFIX= pecl-
|
||||
|
|
|
@ -1,6 +1,20 @@
|
|||
--- config.m4.orig 2017-02-05 15:08:47 UTC
|
||||
--- config.m4.orig 2017-01-24 02:05:48 UTC
|
||||
+++ config.m4
|
||||
@@ -178,7 +178,7 @@ if test "$PHP_SWOOLE" != "no"; then
|
||||
@@ -85,7 +85,13 @@ AC_DEFUN([AC_SWOOLE_CPU_AFFINITY],
|
||||
AC_MSG_CHECKING([for cpu affinity])
|
||||
AC_TRY_COMPILE(
|
||||
[
|
||||
+ #ifdef __FreeBSD__
|
||||
+ #include <sys/types.h>
|
||||
+ #include <sys/cpuset.h>
|
||||
+ typedef cpuset_t cpu_set_t;
|
||||
+ #else
|
||||
#include <sched.h>
|
||||
+ #endif
|
||||
], [
|
||||
cpu_set_t cpu_set;
|
||||
CPU_ZERO(&cpu_set);
|
||||
@@ -178,7 +184,7 @@ if test "$PHP_SWOOLE" != "no"; then
|
||||
AC_CHECK_LIB(c, poll, AC_DEFINE(HAVE_POLL, 1, [have poll]))
|
||||
AC_CHECK_LIB(c, sendfile, AC_DEFINE(HAVE_SENDFILE, 1, [have sendfile]))
|
||||
AC_CHECK_LIB(c, kqueue, AC_DEFINE(HAVE_KQUEUE, 1, [have kqueue]))
|
||||
|
|
20
devel/pecl-swoole/files/patch-include_swoole.h
Normal file
20
devel/pecl-swoole/files/patch-include_swoole.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
--- include/swoole.h.orig 2017-01-24 02:05:48 UTC
|
||||
+++ include/swoole.h
|
||||
@@ -40,7 +40,17 @@ extern "C" {
|
||||
#include <assert.h>
|
||||
#include <time.h>
|
||||
#include <pthread.h>
|
||||
+
|
||||
+#if defined(HAVE_CPU_AFFINITY)
|
||||
+#ifdef __FreeBSD__
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/cpuset.h>
|
||||
+#include <pthread_np.h>
|
||||
+typedef cpuset_t cpu_set_t;
|
||||
+#else
|
||||
#include <sched.h>
|
||||
+#endif
|
||||
+#endif
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
16
devel/pecl-swoole/files/patch-src_network_Server.c
Normal file
16
devel/pecl-swoole/files/patch-src_network_Server.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
--- src/network/Server.c.orig 2017-02-06 09:30:50 UTC
|
||||
+++ src/network/Server.c
|
||||
@@ -522,7 +522,13 @@ int swServer_worker_init(swServer *serv,
|
||||
{
|
||||
CPU_SET(SwooleWG.id % SW_CPU_NUM, &cpu_set);
|
||||
}
|
||||
+
|
||||
+#ifdef __FreeBSD__
|
||||
+ if (cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1,
|
||||
+ sizeof(cpu_set), &cpu_set) < 0)
|
||||
+#else
|
||||
if (sched_setaffinity(getpid(), sizeof(cpu_set), &cpu_set) < 0)
|
||||
+#endif
|
||||
{
|
||||
swSysError("sched_setaffinity() failed.");
|
||||
}
|
15
devel/pecl-swoole/files/patch-swoole__process.c
Normal file
15
devel/pecl-swoole/files/patch-swoole__process.c
Normal file
|
@ -0,0 +1,15 @@
|
|||
--- swoole_process.c.orig 2017-02-06 09:32:48 UTC
|
||||
+++ swoole_process.c
|
||||
@@ -963,7 +963,12 @@ static PHP_METHOD(swoole_process, setaff
|
||||
CPU_SET(Z_LVAL_P(value), &cpu_set);
|
||||
SW_HASHTABLE_FOREACH_END();
|
||||
|
||||
+#ifdef __FreeBSD__
|
||||
+ if (cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1,
|
||||
+ sizeof(cpu_set), &cpu_set) < 0)
|
||||
+#else
|
||||
if (sched_setaffinity(getpid(), sizeof(cpu_set), &cpu_set) < 0)
|
||||
+#endif
|
||||
{
|
||||
swoole_php_sys_error(E_WARNING, "sched_setaffinity() failed.");
|
||||
RETURN_FALSE;
|
Loading…
Reference in a new issue