mirror of https://github.com/F-Stack/f-stack.git
Nginx: fix crash when server configuration item [`kernel_network_stack`] is on and uses `proxy_pass`.
When nginx is configured like this: ``` server { listen 8000; kernel_network_stack on; location / { proxy_pass http://127.0.0.1:8080/; } } ``` nginx will crash, becasue kernel network stack is handled in a single thread, but we have hijacked all the socket apis, it causes that all apis enter to f-stack's path which is in main thread.
This commit is contained in:
parent
e9cbb9895c
commit
e340d433ea
|
@ -10,6 +10,12 @@
|
||||||
#include <ngx_event.h>
|
#include <ngx_event.h>
|
||||||
|
|
||||||
|
|
||||||
|
#if (NGX_HAVE_FSTACK)
|
||||||
|
extern int fstack_territory(int domain, int type, int protocol);
|
||||||
|
extern int is_fstack_fd(int sockfd);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
ngx_os_io_t ngx_io;
|
ngx_os_io_t ngx_io;
|
||||||
|
|
||||||
|
|
||||||
|
@ -376,11 +382,6 @@ ngx_set_inherited_sockets(ngx_cycle_t *cycle)
|
||||||
return NGX_OK;
|
return NGX_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (NGX_HAVE_FSTACK)
|
|
||||||
extern int
|
|
||||||
fstack_territory(int domain, int type, int protocol);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ngx_int_t
|
ngx_int_t
|
||||||
ngx_open_listening_sockets(ngx_cycle_t *cycle)
|
ngx_open_listening_sockets(ngx_cycle_t *cycle)
|
||||||
{
|
{
|
||||||
|
@ -1166,6 +1167,10 @@ ngx_get_connection(ngx_socket_t s, ngx_log_t *log)
|
||||||
|
|
||||||
wev->write = 1;
|
wev->write = 1;
|
||||||
|
|
||||||
|
#if (NGX_HAVE_FSTACK)
|
||||||
|
rev->belong_to_host = wev->belong_to_host = is_fstack_fd(s) ? 0 : 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,7 +119,7 @@ static int (*real_ioctl)(int, int, void *);
|
||||||
|
|
||||||
static int (*real_gettimeofday)(struct timeval *tv, struct timezone *tz);
|
static int (*real_gettimeofday)(struct timeval *tv, struct timezone *tz);
|
||||||
|
|
||||||
static int inited;
|
static __thread int inited;
|
||||||
|
|
||||||
#define SYSCALL(func) \
|
#define SYSCALL(func) \
|
||||||
({ \
|
({ \
|
||||||
|
@ -151,7 +151,7 @@ static inline int restore_fstack_fd(int sockfd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tell whether a 'sockfd' belongs to fstack. */
|
/* Tell whether a 'sockfd' belongs to fstack. */
|
||||||
static inline int is_fstack_fd(int sockfd) {
|
int is_fstack_fd(int sockfd) {
|
||||||
if (unlikely(inited == 0)) {
|
if (unlikely(inited == 0)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue