From e036d21d680655784b46947347ee26ca525d19dc Mon Sep 17 00:00:00 2001 From: whl739 Date: Thu, 21 Jun 2018 17:22:59 +0800 Subject: [PATCH] Nginx: hijack `shutdown`. In some cases, nginx will call `ngx_shutdown_socket`, so we need to hijack `shutdown`. --- app/nginx-1.11.10/src/event/modules/ngx_ff_module.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/app/nginx-1.11.10/src/event/modules/ngx_ff_module.c b/app/nginx-1.11.10/src/event/modules/ngx_ff_module.c index 46aee1ea..d3123fe0 100644 --- a/app/nginx-1.11.10/src/event/modules/ngx_ff_module.c +++ b/app/nginx-1.11.10/src/event/modules/ngx_ff_module.c @@ -117,6 +117,8 @@ static ssize_t (*real_readv)(int, const struct iovec *, int); static ssize_t (*real_read)(int, void *, size_t); static ssize_t (*real_write)(int, const void *, size_t); +static int (*real_shutdown)(int, int); + static int (*real_ioctl)(int, int, void *); static int (*real_gettimeofday)(struct timeval *tv, struct timezone *tz); @@ -444,6 +446,17 @@ close(int sockfd) return SYSCALL(close)(sockfd); } +int +shutdown(int sockfd, int how) +{ + if(is_fstack_fd(sockfd)){ + sockfd = restore_fstack_fd(sockfd); + return ff_close(sockfd); + } + + return SYSCALL(shutdown)(sockfd, how); +} + ssize_t writev(int sockfd, const struct iovec *iov, int iovcnt) {