From 2dc228040a82a8919f722ca5a5b9fa6d82d83983 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 19 Oct 2020 16:59:00 +0200 Subject: [PATCH] Use zend_accel_error_noreturn in more places Missed the place in accelerator_blacklist that was the actual motivation here... --- ext/opcache/zend_accelerator_blacklist.c | 10 +++++----- ext/opcache/zend_accelerator_hash.c | 4 ++-- ext/opcache/zend_shared_alloc.c | 20 ++++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/ext/opcache/zend_accelerator_blacklist.c b/ext/opcache/zend_accelerator_blacklist.c index 9ae897b521..45ad0b2685 100644 --- a/ext/opcache/zend_accelerator_blacklist.c +++ b/ext/opcache/zend_accelerator_blacklist.c @@ -60,7 +60,7 @@ void zend_accel_blacklist_init(zend_blacklist *blacklist) blacklist->entries = (zend_blacklist_entry *) calloc(sizeof(zend_blacklist_entry), blacklist->size); if (!blacklist->entries) { - zend_accel_error(ACCEL_LOG_FATAL, "Blacklist initialization: no memory\n"); + zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Blacklist initialization: no memory\n"); return; } blacklist->regexp_list = NULL; @@ -68,7 +68,7 @@ void zend_accel_blacklist_init(zend_blacklist *blacklist) static void blacklist_report_regexp_error(const char *pcre_error, int pcre_error_offset) { - zend_accel_error(ACCEL_LOG_ERROR, "Blacklist compilation failed (offset: %d), %s\n", pcre_error_offset, pcre_error); + zend_accel_error_noreturn(ACCEL_LOG_ERROR, "Blacklist compilation failed (offset: %d), %s\n", pcre_error_offset, pcre_error); } static void zend_accel_blacklist_update_regexp(zend_blacklist *blacklist) @@ -163,7 +163,7 @@ static void zend_accel_blacklist_update_regexp(zend_blacklist *blacklist) if (*c || i == blacklist->pos - 1) { if (*c) { if (!backtrack) { - zend_accel_error(ACCEL_LOG_ERROR, "Too long blacklist entry\n"); + zend_accel_error_noreturn(ACCEL_LOG_ERROR, "Too long blacklist entry\n"); } p = backtrack; } else { @@ -173,7 +173,7 @@ static void zend_accel_blacklist_update_regexp(zend_blacklist *blacklist) it = (zend_regexp_list*)malloc(sizeof(zend_regexp_list)); if (!it) { - zend_accel_error(ACCEL_LOG_ERROR, "malloc() failed\n"); + zend_accel_error_noreturn(ACCEL_LOG_ERROR, "malloc() failed\n"); return; } it->next = NULL; @@ -302,7 +302,7 @@ static void zend_accel_blacklist_loadone(zend_blacklist *blacklist, char *filena blacklist->entries[blacklist->pos].path_length = path_length; blacklist->entries[blacklist->pos].path = (char *)malloc(path_length + 1); if (!blacklist->entries[blacklist->pos].path) { - zend_accel_error(ACCEL_LOG_ERROR, "malloc() failed\n"); + zend_accel_error_noreturn(ACCEL_LOG_ERROR, "malloc() failed\n"); fclose(fp); return; } diff --git a/ext/opcache/zend_accelerator_hash.c b/ext/opcache/zend_accelerator_hash.c index 7cd9ef1ef4..b0293ae8f2 100644 --- a/ext/opcache/zend_accelerator_hash.c +++ b/ext/opcache/zend_accelerator_hash.c @@ -54,14 +54,14 @@ void zend_accel_hash_init(zend_accel_hash *accel_hash, uint32_t hash_size) /* set up hash pointers table */ accel_hash->hash_table = zend_shared_alloc(sizeof(zend_accel_hash_entry *)*accel_hash->max_num_entries); if (!accel_hash->hash_table) { - zend_accel_error(ACCEL_LOG_FATAL, "Insufficient shared memory!"); + zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Insufficient shared memory!"); return; } /* set up hash values table */ accel_hash->hash_entries = zend_shared_alloc(sizeof(zend_accel_hash_entry)*accel_hash->max_num_entries); if (!accel_hash->hash_entries) { - zend_accel_error(ACCEL_LOG_FATAL, "Insufficient shared memory!"); + zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Insufficient shared memory!"); return; } memset(accel_hash->hash_table, 0, sizeof(zend_accel_hash_entry *)*accel_hash->max_num_entries); diff --git a/ext/opcache/zend_shared_alloc.c b/ext/opcache/zend_shared_alloc.c index d32a70b7e8..f4cb4f55af 100644 --- a/ext/opcache/zend_shared_alloc.c +++ b/ext/opcache/zend_shared_alloc.c @@ -86,7 +86,7 @@ void zend_shared_alloc_create_lock(char *lockfile_path) fchmod(lock_file, 0666); if (lock_file == -1) { - zend_accel_error(ACCEL_LOG_FATAL, "Unable to create lock file: %s (%d)", strerror(errno), errno); + zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Unable to create lock file: %s (%d)", strerror(errno), errno); } val = fcntl(lock_file, F_GETFD, 0); val |= FD_CLOEXEC; @@ -98,7 +98,7 @@ void zend_shared_alloc_create_lock(char *lockfile_path) static void no_memory_bailout(size_t allocate_size, char *error) { - zend_accel_error(ACCEL_LOG_FATAL, "Unable to allocate shared memory segment of %zu bytes: %s: %s (%d)", allocate_size, error?error:"unknown", strerror(errno), errno ); + zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Unable to allocate shared memory segment of %zu bytes: %s: %s (%d)", allocate_size, error?error:"unknown", strerror(errno), errno ); } static void copy_shared_segments(void *to, void *from, int count, int size) @@ -231,14 +231,14 @@ int zend_shared_alloc_startup(size_t requested_size, size_t reserved_size) p_tmp_shared_globals = (zend_smm_shared_globals *) zend_shared_alloc(sizeof(zend_smm_shared_globals)); if (!p_tmp_shared_globals) { - zend_accel_error(ACCEL_LOG_FATAL, "Insufficient shared memory!"); + zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Insufficient shared memory!"); return ALLOC_FAILURE; } memset(p_tmp_shared_globals, 0, sizeof(zend_smm_shared_globals)); tmp_shared_segments = zend_shared_alloc(shared_segments_array_size + ZSMMG(shared_segments_count) * sizeof(void *)); if (!tmp_shared_segments) { - zend_accel_error(ACCEL_LOG_FATAL, "Insufficient shared memory!"); + zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Insufficient shared memory!"); return ALLOC_FAILURE; } @@ -252,7 +252,7 @@ int zend_shared_alloc_startup(size_t requested_size, size_t reserved_size) ZSMMG(shared_memory_state).positions = (int *)zend_shared_alloc(sizeof(int) * ZSMMG(shared_segments_count)); if (!ZSMMG(shared_memory_state).positions) { - zend_accel_error(ACCEL_LOG_FATAL, "Insufficient shared memory!"); + zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Insufficient shared memory!"); return ALLOC_FAILURE; } @@ -263,7 +263,7 @@ int zend_shared_alloc_startup(size_t requested_size, size_t reserved_size) ZSMMG(reserved) = (char*)ZSMMG(shared_segments)[i]->p + ZSMMG(shared_segments)[i]->end; ZSMMG(reserved_size) = reserved_size; } else { - zend_accel_error(ACCEL_LOG_FATAL, "Insufficient shared memory!"); + zend_accel_error_noreturn(ACCEL_LOG_FATAL, "Insufficient shared memory!"); return ALLOC_FAILURE; } } @@ -340,7 +340,7 @@ void *zend_shared_alloc(size_t size) #if 1 if (!ZCG(locked)) { - zend_accel_error(ACCEL_LOG_ERROR, "Shared memory lock not obtained"); + zend_accel_error_noreturn(ACCEL_LOG_ERROR, "Shared memory lock not obtained"); } #endif if (block_size > ZSMMG(shared_free)) { /* No hope to find a big-enough block */ @@ -482,7 +482,7 @@ void zend_shared_alloc_lock(void) if (errno == EINTR) { continue; } - zend_accel_error(ACCEL_LOG_ERROR, "Cannot create lock - %s (%d)", strerror(errno), errno); + zend_accel_error_noreturn(ACCEL_LOG_ERROR, "Cannot create lock - %s (%d)", strerror(errno), errno); } break; } @@ -508,7 +508,7 @@ void zend_shared_alloc_unlock(void) #ifndef ZEND_WIN32 if (fcntl(lock_file, F_SETLK, &mem_write_unlock) == -1) { - zend_accel_error(ACCEL_LOG_ERROR, "Cannot remove lock - %s (%d)", strerror(errno), errno); + zend_accel_error_noreturn(ACCEL_LOG_ERROR, "Cannot remove lock - %s (%d)", strerror(errno), errno); } #ifdef ZTS tsrm_mutex_unlock(zts_lock); @@ -631,7 +631,7 @@ void zend_accel_shared_protect(int mode) for (i = 0; i < ZSMMG(shared_segments_count); i++) { DWORD oldProtect; if (!VirtualProtect(ZSMMG(shared_segments)[i]->p, ZSMMG(shared_segments)[i]->end, mode, &oldProtect)) { - zend_accel_error(ACCEL_LOG_ERROR, "Failed to protect memory"); + zend_accel_error_noreturn(ACCEL_LOG_ERROR, "Failed to protect memory"); } } #endif -- 2.40.0