From ab555adef4a79fbc3de8a333c84e14f15b84cdf0 Mon Sep 17 00:00:00 2001 From: chenwei Date: Wed, 31 Jan 2018 13:47:44 +0800 Subject: [PATCH] Nginx: hijack `recvmsg`. Since Nginx calls `recvmsg` in stream with udp, we must hijack this function, so that the network IO can pass through f-stack. --- app/nginx-1.11.10/src/event/modules/ngx_ff_module.c | 11 +++++++++++ 1 file changed, 11 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 4bf5537d8..75bd3de44 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 @@ -109,6 +109,7 @@ static ssize_t (*real_send)(int, const void *, size_t, int); static ssize_t (*real_sendto)(int, const void *, size_t, int, const struct sockaddr*, socklen_t); static ssize_t (*real_sendmsg)(int, const struct msghdr*, int); +static ssize_t (*real_recvmsg)(int, struct msghdr *, int); static ssize_t (*real_writev)(int, const struct iovec *, int); static ssize_t (*real_readv)(int, const struct iovec *, int); @@ -292,6 +293,16 @@ sendmsg(int sockfd, const struct msghdr *msg, int flags) return SYSCALL(sendmsg)(sockfd, msg, flags); } +ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags) +{ + if(is_fstack_fd(sockfd)){ + sockfd = restore_fstack_fd(sockfd); + return ff_recvmsg(sockfd, msg, flags); + } + + return SYSCALL(recvmsg)(sockfd, msg, flags); +} + ssize_t recv(int sockfd, void *buf, size_t len, int flags) {