Skip to content

Commit 1f3c395

Browse files
committed
Remove redundant global variable: SIGG(reset)
This global variable controls whether the Zend deferred signal handlers are installed at the beginning of each request or not. Interestingly, it is set to 1 on initialization, and there is only *one* place where the value is modified. This is in OPCache, where the global is temporarily set to 0 while preloading. Why is this? Discussion on GitHub revealed that the purpose was so that what happens during preloading would not affect subsequent requests... but the fact is, as long as Zend signal handling is enabled, the Zend signal handlers will always be installed on each subsequent request, so installing them during preloading will not affect anything.
1 parent 08858e7 commit 1f3c395

File tree

3 files changed

+2
-21
lines changed

3 files changed

+2
-21
lines changed

Zend/zend_signal.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,8 @@ void zend_signal_activate(void)
320320

321321
memcpy(&SIGG(handlers), &global_orig_handlers, sizeof(global_orig_handlers));
322322

323-
if (SIGG(reset)) {
324-
for (x = 0; x < sizeof(zend_sigs) / sizeof(*zend_sigs); x++) {
325-
zend_signal_register(zend_sigs[x], zend_signal_handler_defer);
326-
}
323+
for (x = 0; x < sizeof(zend_sigs) / sizeof(*zend_sigs); x++) {
324+
zend_signal_register(zend_sigs[x], zend_signal_handler_defer);
327325
}
328326

329327
SIGG(active) = 1;
@@ -376,7 +374,6 @@ static void zend_signal_globals_ctor(zend_signal_globals_t *zend_signal_globals)
376374
size_t x;
377375

378376
memset(zend_signal_globals, 0, sizeof(*zend_signal_globals));
379-
zend_signal_globals->reset = 1;
380377

381378
for (x = 0; x < sizeof(zend_signal_globals->pstorage) / sizeof(*zend_signal_globals->pstorage); ++x) {
382379
zend_signal_queue_t *queue = &zend_signal_globals->pstorage[x];

Zend/zend_signal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ typedef struct _zend_signal_globals_t {
5757
int running; /* in signal handler execution */
5858
int active; /* internal signal handling is enabled */
5959
zend_bool check; /* check for replaced handlers on shutdown */
60-
zend_bool reset; /* reset signal handlers on each request */
6160
zend_signal_entry_t handlers[NSIG];
6261
zend_signal_queue_t pstorage[ZEND_SIGNAL_QUEUE_SIZE], *phead, *ptail, *pavail; /* pending queue */
6362
} zend_signal_globals_t;

ext/opcache/ZendAccelerator.c

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4802,9 +4802,6 @@ static int accel_finish_startup(void)
48024802
size_t (*orig_ub_write)(const char *str, size_t str_length) = sapi_module.ub_write;
48034803
void (*orig_flush)(void *server_context) = sapi_module.flush;
48044804
uint32_t orig_compiler_options = CG(compiler_options);
4805-
#ifdef ZEND_SIGNALS
4806-
zend_bool old_reset_signals = SIGG(reset);
4807-
#endif
48084805

48094806
if (UNEXPECTED(file_cache_only)) {
48104807
zend_accel_error(ACCEL_LOG_WARNING, "Preloading doesn't work in \"file_cache_only\" mode");
@@ -4907,10 +4904,6 @@ static int accel_finish_startup(void)
49074904

49084905
zend_interned_strings_switch_storage(1);
49094906

4910-
#ifdef ZEND_SIGNALS
4911-
SIGG(reset) = 0;
4912-
#endif
4913-
49144907
orig_error_reporting = EG(error_reporting);
49154908
EG(error_reporting) = 0;
49164909

@@ -4943,20 +4936,12 @@ static int accel_finish_startup(void)
49434936

49444937
orig_report_memleaks = PG(report_memleaks);
49454938
PG(report_memleaks) = 0;
4946-
#ifdef ZEND_SIGNALS
4947-
/* We may not have registered signal handlers due to SIGG(reset)=0, so
4948-
* also disable the check that they are registered. */
4949-
SIGG(check) = 0;
4950-
#endif
49514939
php_request_shutdown(NULL); /* calls zend_shared_alloc_unlock(); */
49524940
PG(report_memleaks) = orig_report_memleaks;
49534941
} else {
49544942
zend_shared_alloc_unlock();
49554943
ret = FAILURE;
49564944
}
4957-
#ifdef ZEND_SIGNALS
4958-
SIGG(reset) = old_reset_signals;
4959-
#endif
49604945

49614946
CG(compiler_options) = orig_compiler_options;
49624947

0 commit comments

Comments
 (0)