mirror of https://github.com/F-Stack/f-stack.git
Nginx: hijack `read` and `write`.
Since libssl calls `read` and `write` when SSL handshake, we must hijack these two functions, so that the network IO can pass through f-stack.
This commit is contained in:
parent
b7d857a29d
commit
20be49f608
|
@ -112,6 +112,9 @@ static ssize_t (*real_sendmsg)(int, const struct msghdr*, int);
|
|||
static ssize_t (*real_writev)(int, const struct iovec *, int);
|
||||
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_ioctl)(int, int, void *);
|
||||
|
||||
static int (*real_gettimeofday)(struct timeval *tv, struct timezone *tz);
|
||||
|
@ -374,6 +377,34 @@ readv(int sockfd, const struct iovec *iov, int iovcnt)
|
|||
}
|
||||
}
|
||||
|
||||
ssize_t
|
||||
read(int sockfd, void *buf, size_t count)
|
||||
{
|
||||
if (unlikely(inited == 0)) {
|
||||
return SYSCALL(read)(sockfd, buf, count);
|
||||
}
|
||||
|
||||
if (ff_fdisused(sockfd)) {
|
||||
return ff_read(sockfd, buf, count);
|
||||
} else {
|
||||
return SYSCALL(read)(sockfd, buf, count);
|
||||
}
|
||||
}
|
||||
|
||||
ssize_t
|
||||
write(int sockfd, const void *buf, size_t count)
|
||||
{
|
||||
if (unlikely(inited == 0)) {
|
||||
return SYSCALL(write)(sockfd, buf, count);
|
||||
}
|
||||
|
||||
if (ff_fdisused(sockfd)) {
|
||||
return ff_write(sockfd, buf, count);
|
||||
} else {
|
||||
return SYSCALL(write)(sockfd, buf, count);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
ioctl(int sockfd, int request, void *p)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue