This commit is contained in:
Aleksei Bavshin 2025-07-16 20:31:34 +00:00 committed by GitHub
commit a7587e6d16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View File

@ -19,6 +19,7 @@ ngx_shm_alloc(ngx_shm_t *shm)
MAP_ANON|MAP_SHARED, -1, 0);
if (shm->addr == MAP_FAILED) {
shm->addr = NULL;
ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno,
"mmap(MAP_ANON|MAP_SHARED, %uz) failed", shm->size);
return NGX_ERROR;
@ -35,6 +36,8 @@ ngx_shm_free(ngx_shm_t *shm)
ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno,
"munmap(%p, %uz) failed", shm->addr, shm->size);
}
shm->addr = NULL;
}
#elif (NGX_HAVE_MAP_DEVZERO)
@ -56,6 +59,7 @@ ngx_shm_alloc(ngx_shm_t *shm)
MAP_SHARED, fd, 0);
if (shm->addr == MAP_FAILED) {
shm->addr = NULL;
ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno,
"mmap(/dev/zero, MAP_SHARED, %uz) failed", shm->size);
}
@ -65,7 +69,7 @@ ngx_shm_alloc(ngx_shm_t *shm)
"close(\"/dev/zero\") failed");
}
return (shm->addr == MAP_FAILED) ? NGX_ERROR : NGX_OK;
return (shm->addr == NULL) ? NGX_ERROR : NGX_OK;
}
@ -76,6 +80,8 @@ ngx_shm_free(ngx_shm_t *shm)
ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno,
"munmap(%p, %uz) failed", shm->addr, shm->size);
}
shm->addr = NULL;
}
#elif (NGX_HAVE_SYSVSHM)
@ -102,6 +108,7 @@ ngx_shm_alloc(ngx_shm_t *shm)
shm->addr = shmat(id, NULL, 0);
if (shm->addr == (void *) -1) {
shm->addr = NULL;
ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno, "shmat() failed");
}
@ -110,7 +117,7 @@ ngx_shm_alloc(ngx_shm_t *shm)
"shmctl(IPC_RMID) failed");
}
return (shm->addr == (void *) -1) ? NGX_ERROR : NGX_OK;
return (shm->addr == NULL) ? NGX_ERROR : NGX_OK;
}
@ -121,6 +128,8 @@ ngx_shm_free(ngx_shm_t *shm)
ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno,
"shmdt(%p) failed", shm->addr);
}
shm->addr = NULL;
}
#endif

View File

@ -158,4 +158,6 @@ ngx_shm_free(ngx_shm_t *shm)
"CloseHandle() of file mapping \"%V\" failed",
&shm->name);
}
shm->addr = NULL;
}