diff options
author | Igor Sysoev <igor@sysoev.ru> | 2009-06-02 17:56:42 +0400 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2009-06-02 17:56:42 +0400 |
commit | 5b26bec9e8b3e7659e3aaa161b491c34ecdff036 (patch) | |
tree | 8f8f7349610597f99aef986aa92b3cc16d6a586f /src | |
parent | 785ee23467321cccebbcc6aa344c85927c03d867 (diff) |
*) fix memory leak in successful case
*) log shared memory name in failure case
Diffstat (limited to 'src')
-rw-r--r-- | src/os/win32/ngx_shmem.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/os/win32/ngx_shmem.c b/src/os/win32/ngx_shmem.c index a4f5eff84..e4b357a97 100644 --- a/src/os/win32/ngx_shmem.c +++ b/src/os/win32/ngx_shmem.c @@ -19,7 +19,7 @@ ngx_shm_alloc(ngx_shm_t *shm) return NGX_ERROR; } - ngx_sprintf(name, "%V_%s%Z", &shm->name, ngx_unique); + (void) ngx_sprintf(name, "%V_%s%Z", &shm->name, ngx_unique); ngx_set_errno(0); @@ -33,10 +33,14 @@ ngx_shm_alloc(ngx_shm_t *shm) if (shm->handle == NULL) { ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno, "CreateFileMapping(%uz, %s) failed", - shm->size, shm->name.data); - goto failed; + shm->size, name); + ngx_free(name); + + return NGX_ERROR; } + ngx_free(name); + if (ngx_errno == ERROR_ALREADY_EXISTS) { shm->exists = 1; } @@ -48,17 +52,15 @@ ngx_shm_alloc(ngx_shm_t *shm) } ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno, - "MapViewOfFile(%uz) failed", shm->size); + "MapViewOfFile(%uz) of file mapping \"%V\" failed", + shm->size, &shm->name); if (CloseHandle(shm->handle) == 0) { ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno, - "CloseHandle() failed"); + "CloseHandle() of file mapping \"%V\" failed", + &shm->name); } -failed: - - ngx_free(name); - return NGX_ERROR; } @@ -68,11 +70,13 @@ ngx_shm_free(ngx_shm_t *shm) { if (UnmapViewOfFile(shm->addr) == 0) { ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno, - "UnmapViewOfFile(%p) failed", shm->addr); + "UnmapViewOfFile(%p) of file mapping \"%V\" failed", + shm->addr, &shm->name); } if (CloseHandle(shm->handle) == 0) { ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno, - "CloseHandle() failed"); + "CloseHandle() of file mapping \"%V\" failed", + &shm->name); } } |