mirror of
https://github.com/php/php-src.git
synced 2024-11-24 02:15:04 +08:00
Cleanup zend_signal API
This commit is contained in:
parent
3abd9c34c1
commit
c8706331b5
@ -40,10 +40,7 @@
|
||||
#include "zend_iterators.h"
|
||||
#include "zend_stream.h"
|
||||
#include "zend_smart_str_public.h"
|
||||
|
||||
#ifdef ZEND_SIGNALS
|
||||
# include "zend_signal.h"
|
||||
#endif
|
||||
#include "zend_signal.h"
|
||||
|
||||
#ifndef ZEND_SIGNALS
|
||||
/* block/unblock interruptions callbacks might be used by SAPI, and were used
|
||||
@ -52,7 +49,7 @@
|
||||
# define HANDLE_BLOCK_INTERRUPTIONS()
|
||||
# define HANDLE_UNBLOCK_INTERRUPTIONS()
|
||||
#else
|
||||
# define HANDLE_BLOCK_INTERRUPTIONS() ZEND_SIGNAL_BLOCK_INTERRUPUTIONS()
|
||||
# define HANDLE_BLOCK_INTERRUPTIONS() ZEND_SIGNAL_BLOCK_INTERRUPTIONS()
|
||||
# define HANDLE_UNBLOCK_INTERRUPTIONS() ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS()
|
||||
#endif
|
||||
|
||||
|
@ -48,7 +48,19 @@
|
||||
#ifdef ZTS
|
||||
ZEND_API int zend_signal_globals_id;
|
||||
#else
|
||||
zend_signal_globals_t zend_signal_globals;
|
||||
ZEND_API zend_signal_globals_t zend_signal_globals;
|
||||
#endif /* not ZTS */
|
||||
|
||||
#define SIGNAL_BEGIN_CRITICAL() \
|
||||
sigset_t oldmask; \
|
||||
zend_sigprocmask(SIG_BLOCK, &global_sigmask, &oldmask);
|
||||
#define SIGNAL_END_CRITICAL() \
|
||||
zend_sigprocmask(SIG_SETMASK, &oldmask, NULL);
|
||||
|
||||
#ifdef ZTS
|
||||
# define zend_sigprocmask(signo, set, oldset) tsrm_sigmask((signo), (set), (oldset))
|
||||
#else
|
||||
# define zend_sigprocmask(signo, set, oldset) sigprocmask((signo), (set), (oldset))
|
||||
#endif
|
||||
|
||||
static void zend_signal_handler(int signo, siginfo_t *siginfo, void *context);
|
||||
@ -338,7 +350,7 @@ static void zend_signal_globals_ctor(zend_signal_globals_t *zend_signal_globals)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void zend_signal_init() /* {{{ */
|
||||
void zend_signal_init(void) /* {{{ */
|
||||
{
|
||||
int signo;
|
||||
struct sigaction sa = {{0}};
|
||||
@ -360,7 +372,7 @@ void zend_signal_init() /* {{{ */
|
||||
|
||||
/* {{{ zend_signal_startup
|
||||
* alloc zend signal globals */
|
||||
void zend_signal_startup()
|
||||
void zend_signal_startup(void)
|
||||
{
|
||||
|
||||
#ifdef ZTS
|
||||
|
@ -23,9 +23,11 @@
|
||||
#ifndef ZEND_SIGNAL_H
|
||||
#define ZEND_SIGNAL_H
|
||||
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
#include <signal.h>
|
||||
#endif
|
||||
#ifdef ZEND_SIGNALS
|
||||
|
||||
# ifdef HAVE_SIGNAL_H
|
||||
# include <signal.h>
|
||||
# endif
|
||||
|
||||
#ifndef NSIG
|
||||
#define NSIG 65
|
||||
@ -63,39 +65,51 @@ typedef struct _zend_signal_globals_t {
|
||||
zend_signal_queue_t pstorage[ZEND_SIGNAL_QUEUE_SIZE], *phead, *ptail, *pavail; /* pending queue */
|
||||
} zend_signal_globals_t;
|
||||
|
||||
#ifdef ZTS
|
||||
# define SIGG(v) ZEND_TSRMG(zend_signal_globals_id, zend_signal_globals_t *, v)
|
||||
# ifdef ZTS
|
||||
# define SIGG(v) ZEND_TSRMG(zend_signal_globals_id, zend_signal_globals_t *, v)
|
||||
BEGIN_EXTERN_C()
|
||||
ZEND_API extern int zend_signal_globals_id;
|
||||
END_EXTERN_C()
|
||||
# define ZEND_SIGNAL_BLOCK_INTERRUPUTIONS() if (EXPECTED(zend_signal_globals_id)) { SIGG(depth)++; }
|
||||
# define ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS() if (EXPECTED(zend_signal_globals_id) && UNEXPECTED(((SIGG(depth)--) == SIGG(blocked)))) { zend_signal_handler_unblock(); }
|
||||
#else /* ZTS */
|
||||
# define SIGG(v) (zend_signal_globals.v)
|
||||
extern ZEND_API zend_signal_globals_t zend_signal_globals;
|
||||
# define ZEND_SIGNAL_BLOCK_INTERRUPUTIONS() SIGG(depth)++;
|
||||
# define ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS() if (((SIGG(depth)--) == SIGG(blocked))) { zend_signal_handler_unblock(); }
|
||||
#endif /* not ZTS */
|
||||
# else
|
||||
# define SIGG(v) (zend_signal_globals.v)
|
||||
BEGIN_EXTERN_C()
|
||||
ZEND_API extern zend_signal_globals_t zend_signal_globals;
|
||||
END_EXTERN_C()
|
||||
# endif /* not ZTS */
|
||||
|
||||
# define SIGNAL_BEGIN_CRITICAL() sigset_t oldmask; \
|
||||
zend_sigprocmask(SIG_BLOCK, &global_sigmask, &oldmask);
|
||||
# define SIGNAL_END_CRITICAL() zend_sigprocmask(SIG_SETMASK, &oldmask, NULL);
|
||||
# ifdef ZTS
|
||||
# define ZEND_SIGNAL_BLOCK_INTERRUPTIONS() if (EXPECTED(zend_signal_globals_id)) { SIGG(depth)++; }
|
||||
# define ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS() if (EXPECTED(zend_signal_globals_id) && UNEXPECTED(((SIGG(depth)--) == SIGG(blocked)))) { zend_signal_handler_unblock(); }
|
||||
# else /* ZTS */
|
||||
# define ZEND_SIGNAL_BLOCK_INTERRUPTIONS() SIGG(depth)++;
|
||||
# define ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS() if (((SIGG(depth)--) == SIGG(blocked))) { zend_signal_handler_unblock(); }
|
||||
# endif /* not ZTS */
|
||||
|
||||
void zend_signal_handler_defer(int signo, siginfo_t *siginfo, void *context);
|
||||
ZEND_API void zend_signal_handler_unblock();
|
||||
ZEND_API void zend_signal_handler_unblock(void);
|
||||
void zend_signal_activate(void);
|
||||
void zend_signal_deactivate(void);
|
||||
void zend_signal_startup();
|
||||
void zend_signal_init();
|
||||
void zend_signal_startup(void);
|
||||
void zend_signal_init(void);
|
||||
void zend_signal_shutdown(void);
|
||||
|
||||
ZEND_API int zend_signal(int signo, void (*handler)(int));
|
||||
ZEND_API int zend_sigaction(int signo, const struct sigaction *act, struct sigaction *oldact);
|
||||
|
||||
#ifdef ZTS
|
||||
#define zend_sigprocmask(signo, set, oldset) tsrm_sigmask((signo), (set), (oldset))
|
||||
#else
|
||||
#define zend_sigprocmask(signo, set, oldset) sigprocmask((signo), (set), (oldset))
|
||||
#endif
|
||||
#else /* ZEND_SIGNALS */
|
||||
|
||||
# define ZEND_SIGNAL_BLOCK_INTERRUPTIONS()
|
||||
# define ZEND_SIGNAL_UNBLOCK_INTERRUPTIONS()
|
||||
|
||||
# define zend_signal_activate()
|
||||
# define zend_signal_deactivate()
|
||||
# define zend_signal_startup()
|
||||
# define zend_signal_init()
|
||||
# define zend_signal_shutdown()
|
||||
|
||||
# define zend_signal(signo, handler) signal(signo, handler)
|
||||
# define zend_sigaction(signo, act, oldact) sigaction(signo, act, oldact)
|
||||
|
||||
#endif /* ZEND_SIGNALS */
|
||||
|
||||
#endif /* ZEND_SIGNAL_H */
|
||||
|
||||
|
@ -28,8 +28,7 @@
|
||||
Sigfunc *php_signal4(int signo, Sigfunc *func, int restart, int mask_all)
|
||||
{
|
||||
struct sigaction act,oact;
|
||||
#ifdef ZEND_SIGNALS
|
||||
#endif
|
||||
|
||||
act.sa_handler = func;
|
||||
if (mask_all) {
|
||||
sigfillset(&act.sa_mask);
|
||||
@ -46,12 +45,7 @@ Sigfunc *php_signal4(int signo, Sigfunc *func, int restart, int mask_all)
|
||||
act.sa_flags |= SA_RESTART; /* SVR4, 4.3+BSD */
|
||||
#endif
|
||||
}
|
||||
#ifdef ZEND_SIGNALS
|
||||
if (zend_sigaction(signo, &act, &oact) < 0)
|
||||
#else
|
||||
if (sigaction(signo, &act, &oact) < 0)
|
||||
#endif
|
||||
{
|
||||
if (zend_sigaction(signo, &act, &oact) < 0) {
|
||||
return SIG_ERR;
|
||||
}
|
||||
|
||||
|
@ -1597,9 +1597,7 @@ int php_request_startup(void)
|
||||
zend_activate();
|
||||
sapi_activate();
|
||||
|
||||
#ifdef ZEND_SIGNALS
|
||||
zend_signal_activate();
|
||||
#endif
|
||||
|
||||
if (PG(max_input_time) == -1) {
|
||||
zend_set_timeout(EG(timeout_seconds), 1);
|
||||
|
@ -456,9 +456,7 @@ php_apache_server_startup(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp
|
||||
ZEND_TSRMLS_CACHE_UPDATE();
|
||||
#endif
|
||||
|
||||
#ifdef ZEND_SIGNALS
|
||||
zend_signal_startup();
|
||||
#endif
|
||||
|
||||
sapi_startup(&apache2_sapi_module);
|
||||
apache2_sapi_module.startup(&apache2_sapi_module);
|
||||
|
@ -1800,9 +1800,7 @@ int main(int argc, char *argv[])
|
||||
ZEND_TSRMLS_CACHE_UPDATE();
|
||||
#endif
|
||||
|
||||
#ifdef ZEND_SIGNALS
|
||||
zend_signal_startup();
|
||||
#endif
|
||||
|
||||
#ifdef ZTS
|
||||
ts_allocate_id(&php_cgi_globals_id, sizeof(php_cgi_globals_struct), (ts_allocate_ctor) php_cgi_globals_ctor, NULL);
|
||||
|
@ -1230,9 +1230,7 @@ int main(int argc, char *argv[])
|
||||
ZEND_TSRMLS_CACHE_UPDATE();
|
||||
#endif
|
||||
|
||||
#ifdef ZEND_SIGNALS
|
||||
zend_signal_startup();
|
||||
#endif
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
_fmode = _O_BINARY; /*sets default for file streams to binary */
|
||||
|
@ -177,9 +177,7 @@ EMBED_SAPI_API int php_embed_init(int argc, char **argv)
|
||||
ZEND_TSRMLS_CACHE_UPDATE();
|
||||
#endif
|
||||
|
||||
#ifdef ZEND_SIGNALS
|
||||
zend_signal_startup();
|
||||
#endif
|
||||
|
||||
sapi_startup(&php_embed_module);
|
||||
|
||||
|
@ -1612,9 +1612,7 @@ int main(int argc, char *argv[])
|
||||
tsrm_ls = ts_resource(0);
|
||||
#endif
|
||||
|
||||
#ifdef ZEND_SIGNALS
|
||||
zend_signal_startup();
|
||||
#endif
|
||||
|
||||
sapi_startup(&cgi_sapi_module);
|
||||
cgi_sapi_module.php_ini_path_override = NULL;
|
||||
|
@ -242,9 +242,7 @@ int fpm_signals_init_child() /* {{{ */
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef ZEND_SIGNALS
|
||||
zend_signal_init();
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -1007,9 +1007,7 @@ int main( int argc, char * argv[] )
|
||||
tsrm_startup(1, 1, 0, NULL);
|
||||
#endif
|
||||
|
||||
#ifdef ZEND_SIGNALS
|
||||
zend_signal_startup();
|
||||
#endif
|
||||
|
||||
if (argc > 1 ) {
|
||||
if ( parse_opt( argc, argv, &climode,
|
||||
|
@ -1241,11 +1241,7 @@ void phpdbg_signal_handler(int sig, siginfo_t *info, void *context) /* {{{ */
|
||||
}
|
||||
is_handled = phpdbg_watchpoint_segfault_handler(info, context);
|
||||
if (is_handled == FAILURE) {
|
||||
#ifdef ZEND_SIGNALS
|
||||
zend_sigaction(sig, &PHPDBG_G(old_sigsegv_signal), NULL);
|
||||
#else
|
||||
sigaction(sig, &PHPDBG_G(old_sigsegv_signal), NULL);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1342,9 +1338,7 @@ int main(int argc, char **argv) /* {{{ */
|
||||
ZEND_TSRMLS_CACHE_UPDATE();
|
||||
#endif
|
||||
|
||||
#ifdef ZEND_SIGNALS
|
||||
zend_signal_startup();
|
||||
#endif
|
||||
|
||||
phpdbg_main:
|
||||
ini_entries = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user