The environment may be replaced while parsing configuration, as it
happens with the perl module, which calls ngx_set_environment() when
creating an interpreter. As a result, the control socket was not
inherited on binary upgrade.
The variable is now read before ngx_init_cycle(), similarly to
inherited listening sockets.
return 1;
}
+#if (NGX_CONTROL_API)
+ ngx_control_preinit();
+#endif
+
if (ngx_preinit_modules() != NGX_OK) {
return 1;
}
static ngx_uint_t ngx_control_pollfd_n;
static char ngx_control_unix_path[NGX_UNIX_ADDRSTRLEN];
static ngx_uint_t ngx_control_inherited;
+static u_char *ngx_control_env;
ngx_uint_t ngx_control_api_enabled;
};
+void
+ngx_control_preinit(void)
+{
+ /*
+ * the variable is read before ngx_init_cycle(), which may replace
+ * the environment while parsing configuration
+ */
+
+ ngx_control_env = (u_char *) getenv(NGX_CTRL_ENV);
+}
+
+
ngx_int_t
ngx_control_init(u_char *addr)
{
u_char *env;
ngx_fd_t fd;
- env = (u_char *) getenv(NGX_CTRL_ENV);
+ env = ngx_control_env;
if (env == NULL) {
return NGX_DECLINED;
}
#include <ngx_core.h>
+void ngx_control_preinit(void);
ngx_int_t ngx_control_init(u_char *addr);
void ngx_control_uninit(void);
void ngx_control_close_sockets(void);