Skip to content

Commit

Permalink
Nginx: hijack recvmsg.
Browse files Browse the repository at this point in the history
Since Nginx calls `recvmsg` in stream with udp, we must
hijack this function, so that the network IO can pass through
f-stack.
  • Loading branch information
chenwei committed Jan 31, 2018
1 parent f6a681c commit ab555ad
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/nginx-1.11.10/src/event/modules/ngx_ff_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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)
{
Expand Down

0 comments on commit ab555ad

Please sign in to comment.