diff options
author | Lukas Larsson <[email protected]> | 2014-01-27 15:29:58 +0100 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2014-01-27 15:29:58 +0100 |
commit | e59682eae1b7c04bfa011f40f202c0ab5a6527cd (patch) | |
tree | 7f7fdc873c9954ca5ac9b1c25240483f1effc891 /erts/emulator/drivers/common/inet_drv.c | |
parent | 7850ec6f9906eb62b3e33b8b05194944fff569ff (diff) | |
parent | 8f8a03ba3556f2c2c70797bedf5d44b360659425 (diff) | |
download | otp-e59682eae1b7c04bfa011f40f202c0ab5a6527cd.tar.gz otp-e59682eae1b7c04bfa011f40f202c0ab5a6527cd.tar.bz2 otp-e59682eae1b7c04bfa011f40f202c0ab5a6527cd.zip |
Merge branch 'lukas/erts/sendfile_passive_mode_fix/OTP-11614'
* lukas/erts/sendfile_passive_mode_fix/OTP-11614:
erts: fix bug when using passive mode and sendfile
Diffstat (limited to 'erts/emulator/drivers/common/inet_drv.c')
-rw-r--r-- | erts/emulator/drivers/common/inet_drv.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/erts/emulator/drivers/common/inet_drv.c b/erts/emulator/drivers/common/inet_drv.c index 80937dfcc8..4a861b121c 100644 --- a/erts/emulator/drivers/common/inet_drv.c +++ b/erts/emulator/drivers/common/inet_drv.c @@ -854,9 +854,10 @@ static int my_strncasecmp(const char *s1, const char *s2, size_t n) #define INET_IFNAMSIZ 16 /* INET Ignore states */ -#define INET_IGNORE_NONE 0 -#define INET_IGNORE_READ 1 -#define INET_IGNORE_WRITE 1 << 1 +#define INET_IGNORE_NONE 0 +#define INET_IGNORE_READ (1 << 0) +#define INET_IGNORE_WRITE (1 << 1) +#define INET_IGNORE_PASSIVE (1 << 2) /* Max length of Erlang Term Buffer (for outputting structured terms): */ #ifdef HAVE_SCTP @@ -8307,11 +8308,19 @@ static ErlDrvSSizeT inet_ctl(inet_descriptor* desc, int cmd, char* buf, if (*buf == 1 && !desc->is_ignored) { sock_select(desc, (FD_READ|FD_WRITE|FD_CLOSE|ERL_DRV_USE_NO_CALLBACK), 0); - desc->is_ignored = INET_IGNORE_READ; + if (desc->active) + desc->is_ignored = INET_IGNORE_READ; + else + desc->is_ignored = INET_IGNORE_PASSIVE; } else if (*buf == 0 && desc->is_ignored) { - int flags = (FD_READ|FD_CLOSE|((desc->is_ignored & INET_IGNORE_WRITE)?FD_WRITE:0)); + int flags = FD_CLOSE; + if (desc->is_ignored & INET_IGNORE_READ) + flags |= FD_READ; + if (desc->is_ignored & INET_IGNORE_WRITE) + flags |= FD_WRITE; desc->is_ignored = INET_IGNORE_NONE; - sock_select(desc, flags, 1); + if (flags != FD_CLOSE) + sock_select(desc, flags, 1); } else return ctl_error(EINVAL, rbuf, rsize); @@ -8988,6 +8997,8 @@ static ErlDrvSSizeT tcp_inet_ctl(ErlDrvData e, unsigned int cmd, driver_set_timer(desc->inet.port, timeout); if (!INETP(desc)->is_ignored) sock_select(INETP(desc),(FD_READ|FD_CLOSE),1); + else + INETP(desc)->is_ignored |= INET_IGNORE_READ; } } return ctl_reply(INET_REP_OK, tbuf, 2, rbuf, rsize); |