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.
This commit is contained in:
chenwei 2018-01-31 13:47:44 +08:00
parent f6a681c496
commit ab555adef4
1 changed files with 11 additions and 0 deletions

View File

@ -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)
{