Hi, On Thu, Jun 13, 2024 at 03:29:03PM -0700, Aleksei Bavshin wrote: > # HG changeset patch > # User Aleksei Bavshin <a.bavs...@nginx.com> > # Date 1712181327 25200 > # Wed Apr 03 14:55:27 2024 -0700 > # Node ID 375fa42f1a6010692a8782c4f03c6ad465d3f7f7 > # Parent 8c8d8118c7ac0a0426f48dbfed94e279dddff992 > Upstream: disable re-resolve functionality on Windows. > > Following features are currently not implemented on Windows, making re-resolve > functionality unsafe to use: > > * 'noreuse' shared zones that are re-created on each configuration reload. > The work scheduling logic is not prepared to handle simultaneous access to > the shared zone from multiple generations of the worker processes.
I don't see a problem here. Could you please elaborate. > * 'ngx_worker' identification. > It is possible to configure multiple worker processes on Windows, even if > only one would actually handle the traffic. All of the worker processes > are > currently identified as process 0, breaking scheduling and locking of the > resolver tasks. This can be fixed. Patch attached. > diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c > --- a/src/http/ngx_http_upstream.c > +++ b/src/http/ngx_http_upstream.c > @@ -6327,7 +6327,7 @@ ngx_http_upstream_server(ngx_conf_t *cf, > continue; > } > > -#if (NGX_HTTP_UPSTREAM_ZONE) > +#if (NGX_HTTP_UPSTREAM_ZONE && !(NGX_WIN32)) > if (ngx_strcmp(value[i].data, "resolve") == 0) { > resolve = 1; > continue; > diff --git a/src/stream/ngx_stream_upstream.c > b/src/stream/ngx_stream_upstream.c > --- a/src/stream/ngx_stream_upstream.c > +++ b/src/stream/ngx_stream_upstream.c > @@ -545,7 +545,7 @@ ngx_stream_upstream_server(ngx_conf_t *c > continue; > } > > -#if (NGX_STREAM_UPSTREAM_ZONE) > +#if (NGX_STREAM_UPSTREAM_ZONE && !(NGX_WIN32)) > if (ngx_strcmp(value[i].data, "resolve") == 0) { > resolve = 1; > continue; > _______________________________________________ > nginx-devel mailing list > nginx-devel@nginx.org > https://mailman.nginx.org/mailman/listinfo/nginx-devel -- Roman Arutyunyan
# HG changeset patch # User Roman Arutyunyan <a...@nginx.com> # Date 1720529662 -14400 # Tue Jul 09 16:54:22 2024 +0400 # Node ID 09dfd8c3da0e44dcf75052929e34c76dab3d7781 # Parent 8c8d8118c7ac0a0426f48dbfed94e279dddff992 Win32: support for ngx_worker variable. In unix the variable holds nginx worker number. For win32 it was always zero. diff --git a/src/os/win32/ngx_os.h b/src/os/win32/ngx_os.h --- a/src/os/win32/ngx_os.h +++ b/src/os/win32/ngx_os.h @@ -63,6 +63,7 @@ extern ngx_uint_t ngx_inherited_nonblo extern ngx_uint_t ngx_tcp_nodelay_and_tcp_nopush; extern ngx_uint_t ngx_win32_version; extern char ngx_unique[]; +extern char ngx_worker_str[]; #endif /* _NGX_OS_H_INCLUDED_ */ diff --git a/src/os/win32/ngx_process_cycle.c b/src/os/win32/ngx_process_cycle.c --- a/src/os/win32/ngx_process_cycle.c +++ b/src/os/win32/ngx_process_cycle.c @@ -375,6 +375,10 @@ ngx_start_worker_processes(ngx_cycle_t * ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); for (n = 0; n < ccf->worker_processes; n++) { + ngx_sprintf((u_char *) ngx_worker_str, "%i%Z", n); + + SetEnvironmentVariable("ngx_worker", ngx_worker_str); + if (ngx_spawn_process(cycle, "worker", type) == NGX_INVALID_PID) { break; } diff --git a/src/os/win32/ngx_win32_init.c b/src/os/win32/ngx_win32_init.c --- a/src/os/win32/ngx_win32_init.c +++ b/src/os/win32/ngx_win32_init.c @@ -18,6 +18,7 @@ ngx_uint_t ngx_inherited_nonblocking = ngx_uint_t ngx_tcp_nodelay_and_tcp_nopush; char ngx_unique[NGX_INT32_LEN + 1]; +char ngx_worker_str[NGX_INT32_LEN + 1]; ngx_os_io_t ngx_os_io = { @@ -71,6 +72,7 @@ ngx_os_init(ngx_log_t *log) SOCKET s; WSADATA wsd; ngx_err_t err; + ngx_int_t w; ngx_time_t *tp; ngx_uint_t n; SYSTEM_INFO si; @@ -260,6 +262,30 @@ nopoll: { ngx_process = NGX_PROCESS_WORKER; + bytes = GetEnvironmentVariable("ngx_worker", ngx_worker_str, + NGX_INT32_LEN + 1); + + if (bytes == 0) { + ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, + "GetEnvironmentVariable(\"ngx_worker\") failed"); + return NGX_ERROR; + } + + if (bytes <= NGX_INT32_LEN) { + w = ngx_atoi(ngx_worker_str, bytes); + + } else { + w = NGX_ERROR; + } + + if (w == NGX_ERROR) { + ngx_log_error(NGX_LOG_EMERG, log, 0, + "broken environment variable \"ngx_worker\""); + return NGX_ERROR; + } + + ngx_worker = w; + } else { err = ngx_errno;
_______________________________________________ nginx-devel mailing list nginx-devel@nginx.org https://mailman.nginx.org/mailman/listinfo/nginx-devel