mirror of https://github.com/F-Stack/f-stack.git
Merge pull request #197 from chadwill/master
Nginx: fixbug, support process `NGX_PROCESS_HELPER` .e.g cache, refer to #142
This commit is contained in:
commit
196bdd01f1
|
@ -1043,15 +1043,6 @@ ngx_close_listening_sockets(ngx_cycle_t *cycle)
|
||||||
ls = cycle->listening.elts;
|
ls = cycle->listening.elts;
|
||||||
for (i = 0; i < cycle->listening.nelts; i++) {
|
for (i = 0; i < cycle->listening.nelts; i++) {
|
||||||
|
|
||||||
#if (NGX_HAVE_FSTACK)
|
|
||||||
|
|
||||||
// No need to deal with, just skip
|
|
||||||
if (fstack_territory(ls[i].sockaddr->sa_family, ls[i].type, 0)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif //(NGX_HAVE_FSTACK)
|
|
||||||
|
|
||||||
c = ls[i].connection;
|
c = ls[i].connection;
|
||||||
|
|
||||||
if (c) {
|
if (c) {
|
||||||
|
@ -1079,11 +1070,22 @@ ngx_close_listening_sockets(ngx_cycle_t *cycle)
|
||||||
ngx_log_debug2(NGX_LOG_DEBUG_CORE, cycle->log, 0,
|
ngx_log_debug2(NGX_LOG_DEBUG_CORE, cycle->log, 0,
|
||||||
"close listening %V #%d ", &ls[i].addr_text, ls[i].fd);
|
"close listening %V #%d ", &ls[i].addr_text, ls[i].fd);
|
||||||
|
|
||||||
|
#if (NGX_HAVE_FSTACK)
|
||||||
|
if(ls[i].fd != (ngx_socket_t) -1) {
|
||||||
|
if (ngx_close_socket(ls[i].fd) == -1) {
|
||||||
|
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno,
|
||||||
|
ngx_close_socket_n " %V failed", &ls[i].addr_text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
if (ngx_close_socket(ls[i].fd) == -1) {
|
if (ngx_close_socket(ls[i].fd) == -1) {
|
||||||
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno,
|
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_socket_errno,
|
||||||
ngx_close_socket_n " %V failed", &ls[i].addr_text);
|
ngx_close_socket_n " %V failed", &ls[i].addr_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif //(NGX_HAVE_FSTACK)
|
||||||
|
|
||||||
#if (NGX_HAVE_UNIX_DOMAIN)
|
#if (NGX_HAVE_UNIX_DOMAIN)
|
||||||
|
|
||||||
if (ls[i].sockaddr->sa_family == AF_UNIX
|
if (ls[i].sockaddr->sa_family == AF_UNIX
|
||||||
|
|
|
@ -127,6 +127,12 @@ ngx_kqueue_init(ngx_cycle_t *cycle, ngx_msec_t timer)
|
||||||
struct kevent kev;
|
struct kevent kev;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (NGX_HAVE_FSTACK)
|
||||||
|
if(ngx_process != NGX_PROCESS_WORKER) {
|
||||||
|
return NGX_OK;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
kcf = ngx_event_get_conf(cycle->conf_ctx, ngx_kqueue_module);
|
kcf = ngx_event_get_conf(cycle->conf_ctx, ngx_kqueue_module);
|
||||||
|
|
||||||
if (ngx_kqueue == -1) {
|
if (ngx_kqueue == -1) {
|
||||||
|
|
|
@ -250,19 +250,34 @@ ngx_process_events_and_timers(ngx_cycle_t *cycle)
|
||||||
|
|
||||||
delta = ngx_current_msec;
|
delta = ngx_current_msec;
|
||||||
|
|
||||||
|
#if (NGX_HAVE_FSTACK)
|
||||||
|
/*
|
||||||
|
* NGX_PROCESS_WORKERs run on both fstack and kernel,
|
||||||
|
* others ( e.g. cache manager/loader ) only run on kernel.
|
||||||
|
*/
|
||||||
|
if(ngx_process == NGX_PROCESS_WORKER) {
|
||||||
|
(void) ngx_process_events(cycle, timer, flags);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* handle message from kernel ( e.g. signals)
|
||||||
|
* in case of network inactivity
|
||||||
|
*/
|
||||||
|
if (ngx_current_msec - initial >= ngx_schedule_timeout) {
|
||||||
|
(void) ngx_ff_process_host_events(cycle, 0, flags);
|
||||||
|
|
||||||
|
/* Update timer*/
|
||||||
|
initial = ngx_current_msec;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
(void) ngx_ff_process_host_events(cycle, timer, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
delta = ngx_current_msec - delta;
|
||||||
|
#else
|
||||||
(void) ngx_process_events(cycle, timer, flags);
|
(void) ngx_process_events(cycle, timer, flags);
|
||||||
|
|
||||||
delta = ngx_current_msec - delta;
|
delta = ngx_current_msec - delta;
|
||||||
|
|
||||||
#if (NGX_HAVE_FSTACK)
|
|
||||||
/* handle message from kernel (PS: signals from master) in case of network inactivity */
|
|
||||||
if (ngx_current_msec - initial >= ngx_schedule_timeout) {
|
|
||||||
(void) ngx_ff_process_host_events(cycle, 0, flags);
|
|
||||||
|
|
||||||
/* Update timer*/
|
|
||||||
initial = ngx_current_msec;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
|
||||||
"timer delta: %M", delta);
|
"timer delta: %M", delta);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue