comparison src/os/win32/ngx_win32_init.c @ 2720:b3b8c66bd520

support attaching to an existent Win32 shared memory
author Igor Sysoev <igor@sysoev.ru>
date Sat, 18 Apr 2009 19:27:28 +0000
parents 0b592a68aade
children d43d73277c5c
comparison
equal deleted inserted replaced
2719:9237cf8b400b 2720:b3b8c66bd520
15 ngx_int_t ngx_max_sockets; 15 ngx_int_t ngx_max_sockets;
16 ngx_uint_t ngx_inherited_nonblocking = 1; 16 ngx_uint_t ngx_inherited_nonblocking = 1;
17 ngx_uint_t ngx_tcp_nodelay_and_tcp_nopush; 17 ngx_uint_t ngx_tcp_nodelay_and_tcp_nopush;
18 18
19 ngx_fd_t ngx_stderr_fileno; 19 ngx_fd_t ngx_stderr_fileno;
20 char ngx_unique[NGX_INT32_LEN + 1];
20 21
21 22
22 ngx_os_io_t ngx_os_io = { 23 ngx_os_io_t ngx_os_io = {
23 ngx_wsarecv, 24 ngx_wsarecv,
24 ngx_wsarecv_chain, 25 ngx_wsarecv_chain,
58 ngx_int_t ngx_os_init(ngx_log_t *log) 59 ngx_int_t ngx_os_init(ngx_log_t *log)
59 { 60 {
60 DWORD bytes; 61 DWORD bytes;
61 SOCKET s; 62 SOCKET s;
62 WSADATA wsd; 63 WSADATA wsd;
64 ngx_err_t err;
63 ngx_uint_t n; 65 ngx_uint_t n;
64 SYSTEM_INFO si; 66 SYSTEM_INFO si;
65 67
66 /* get Windows version */ 68 /* get Windows version */
67 69
203 if (ngx_close_socket(s) == -1) { 205 if (ngx_close_socket(s) == -1) {
204 ngx_log_error(NGX_LOG_ALERT, log, ngx_socket_errno, 206 ngx_log_error(NGX_LOG_ALERT, log, ngx_socket_errno,
205 ngx_close_socket_n " failed"); 207 ngx_close_socket_n " failed");
206 } 208 }
207 209
210 if (GetEnvironmentVariable("nginx_unique", ngx_unique, NGX_INT32_LEN + 1)
211 != 0)
212 {
213 ngx_process = NGX_PROCESS_WORKER;
214
215 } else {
216 err = ngx_errno;
217
218 if (err != ERROR_ENVVAR_NOT_FOUND) {
219 ngx_log_error(NGX_LOG_EMERG, log, err,
220 "GetEnvironmentVariable(\"nginx_unique\") failed");
221 return NGX_ERROR;
222 }
223
224 ngx_sprintf((u_char *) ngx_unique, "%P%Z", ngx_pid);
225 }
226
208 return NGX_OK; 227 return NGX_OK;
209 } 228 }
210 229
211 230
212 void ngx_os_status(ngx_log_t *log) 231 void ngx_os_status(ngx_log_t *log)