Mercurial > hg > nginx
comparison src/os/win32/ngx_shmem.c @ 2945:87da6664fb49 stable-0.7
merge r2897, r2898, r2899, r2901, r2902, r2904, r2905, r2906, r2907,
r2909, r2910, r2922, r2923, r2924, r2925, r2929:
various win32 fixes:
*) use no-threads for Unix builds only
*) Win32 returns ERROR_PATH_NOT_FOUND instead of ERROR_FILE_NOT_FOUND
*) add trailing zero to a file name in ngx_win32_rename_file()
*) fix logging in ngx_win32_rename_file()
*) allow shared memory segments more than 4G
*) fix memory leak in successful case
*) log shared memory name in failure case
*) test that zone has the same addresses in different processes
*) add drive letter for Win32 root path
*) log GetExitCodeProcess()'s errno
*) test premature process termination
*) fix debug logging
*) exit if no workers could not be started
*) do not quit old workers if no new workers could not be started
*) a signaller process should stop configuration processing just after
it is able to get pid file, this allows to not open log files, etc.
*) win32 master process had aready closed listening sockets
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 15 Jun 2009 09:48:15 +0000 |
parents | d52cf82d0d77 |
children |
comparison
equal
deleted
inserted
replaced
2944:f892042956e3 | 2945:87da6664fb49 |
---|---|
9 | 9 |
10 | 10 |
11 ngx_int_t | 11 ngx_int_t |
12 ngx_shm_alloc(ngx_shm_t *shm) | 12 ngx_shm_alloc(ngx_shm_t *shm) |
13 { | 13 { |
14 u_char *name; | 14 u_char *name; |
15 uint64_t size; | |
15 | 16 |
16 name = ngx_alloc(shm->name.len + 2 + sizeof(NGX_INT32_LEN), shm->log); | 17 name = ngx_alloc(shm->name.len + 2 + sizeof(NGX_INT32_LEN), shm->log); |
17 if (name == NULL) { | 18 if (name == NULL) { |
18 return NGX_ERROR; | 19 return NGX_ERROR; |
19 } | 20 } |
20 | 21 |
21 ngx_sprintf(name, "%V_%s%Z", &shm->name, ngx_unique); | 22 (void) ngx_sprintf(name, "%V_%s%Z", &shm->name, ngx_unique); |
22 | 23 |
23 ngx_set_errno(0); | 24 ngx_set_errno(0); |
24 | 25 |
26 size = shm->size; | |
27 | |
25 shm->handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, | 28 shm->handle = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, |
26 0, shm->size, (char *) name); | 29 (u_long) (size >> 32), |
30 (u_long) (size & 0xffffffff), | |
31 (char *) name); | |
27 | 32 |
28 if (shm->handle == NULL) { | 33 if (shm->handle == NULL) { |
29 ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno, | 34 ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno, |
30 "CreateFileMapping(%uz, %s) failed", | 35 "CreateFileMapping(%uz, %s) failed", |
31 shm->size, shm->name.data); | 36 shm->size, name); |
32 goto failed; | 37 ngx_free(name); |
38 | |
39 return NGX_ERROR; | |
33 } | 40 } |
41 | |
42 ngx_free(name); | |
34 | 43 |
35 if (ngx_errno == ERROR_ALREADY_EXISTS) { | 44 if (ngx_errno == ERROR_ALREADY_EXISTS) { |
36 shm->exists = 1; | 45 shm->exists = 1; |
37 } | 46 } |
38 | 47 |
41 if (shm->addr != NULL) { | 50 if (shm->addr != NULL) { |
42 return NGX_OK; | 51 return NGX_OK; |
43 } | 52 } |
44 | 53 |
45 ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno, | 54 ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno, |
46 "MapViewOfFile(%uz) failed", shm->size); | 55 "MapViewOfFile(%uz) of file mapping \"%V\" failed", |
56 shm->size, &shm->name); | |
47 | 57 |
48 if (CloseHandle(shm->handle) == 0) { | 58 if (CloseHandle(shm->handle) == 0) { |
49 ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno, | 59 ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno, |
50 "CloseHandle() failed"); | 60 "CloseHandle() of file mapping \"%V\" failed", |
61 &shm->name); | |
51 } | 62 } |
52 | |
53 failed: | |
54 | |
55 ngx_free(name); | |
56 | 63 |
57 return NGX_ERROR; | 64 return NGX_ERROR; |
58 } | 65 } |
59 | 66 |
60 | 67 |
61 void | 68 void |
62 ngx_shm_free(ngx_shm_t *shm) | 69 ngx_shm_free(ngx_shm_t *shm) |
63 { | 70 { |
64 if (UnmapViewOfFile(shm->addr) == 0) { | 71 if (UnmapViewOfFile(shm->addr) == 0) { |
65 ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno, | 72 ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno, |
66 "UnmapViewOfFile(%p) failed", shm->addr); | 73 "UnmapViewOfFile(%p) of file mapping \"%V\" failed", |
74 shm->addr, &shm->name); | |
67 } | 75 } |
68 | 76 |
69 if (CloseHandle(shm->handle) == 0) { | 77 if (CloseHandle(shm->handle) == 0) { |
70 ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno, | 78 ngx_log_error(NGX_LOG_ALERT, shm->log, ngx_errno, |
71 "CloseHandle() failed"); | 79 "CloseHandle() of file mapping \"%V\" failed", |
80 &shm->name); | |
72 } | 81 } |
73 } | 82 } |