Nginx : replace macro with inline function to implement ```ngx_ff_skip_listening_socket```

dev
chenwei 2018-02-01 16:30:46 +08:00
parent 19acab5d5f
commit d65c1f94b4
1 changed files with 37 additions and 28 deletions

View File

@ -14,32 +14,37 @@
extern int fstack_territory(int domain, int type, int protocol); extern int fstack_territory(int domain, int type, int protocol);
extern int is_fstack_fd(int sockfd); extern int is_fstack_fd(int sockfd);
#define ngx_ff_skip_listening_socket(ls) \ static ngx_inline int
if (ngx_process <= NGX_PROCESS_MASTER) { \ ngx_ff_skip_listening_socket(ngx_cycle_t *cycle, const ngx_listening_t *ls)
\ {
/* process master, kernel network stack*/ \ if (ngx_process <= NGX_PROCESS_MASTER) {
if (!ls[i].belong_to_host) { \
/* We should continue to process the listening socket, */ \ /* process master, kernel network stack*/
/* if it is not supported by fstack. */ \ if (!ls->belong_to_host) {
if (fstack_territory(ls[i].sockaddr->sa_family, ls[i].type, 0)) { \ /* We should continue to process the listening socket,
continue; \ if it is not supported by fstack. */
} \ if (fstack_territory(ls->sockaddr->sa_family, ls->type, 0)) {
} \ return 1;
} else if (NGX_PROCESS_WORKER == ngx_process) { \ }
/* process worker, fstack */ \ }
if (ls[i].belong_to_host) { \ } else if (NGX_PROCESS_WORKER == ngx_process) {
continue; \ /* process worker, fstack */
} \ if (ls->belong_to_host) {
\ return 1;
if (!fstack_territory(ls[i].sockaddr->sa_family, ls[i].type, 0)) { \ }
continue; \
} \ if (!fstack_territory(ls->sockaddr->sa_family, ls->type, 0)) {
} else { \ return 1;
ngx_log_error(NGX_LOG_ALERT, cycle->log, 0, \ }
"unexpected process type: %d, ignored", \ } else {
ngx_process); \ ngx_log_error(NGX_LOG_ALERT, cycle->log, 0,
exit(1); \ "unexpected process type: %d, ignored",
} ngx_process);
exit(1);
}
return 0;
}
#endif #endif
@ -438,7 +443,9 @@ ngx_open_listening_sockets(ngx_cycle_t *cycle)
#if (NGX_HAVE_FSTACK) #if (NGX_HAVE_FSTACK)
ngx_ff_skip_listening_socket(ls); if(ngx_ff_skip_listening_socket(cycle, &ls[i])){
continue;
}
#endif #endif
@ -700,7 +707,9 @@ ngx_configure_listening_sockets(ngx_cycle_t *cycle)
#if (NGX_HAVE_FSTACK) #if (NGX_HAVE_FSTACK)
ngx_ff_skip_listening_socket(ls); if(ngx_ff_skip_listening_socket(cycle, &ls[i])){
continue;
}
#endif #endif