aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/drivers/common/inet_drv.c
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2011-12-07 14:47:40 +0100
committerLukas Larsson <[email protected]>2011-12-08 15:13:31 +0100
commit4181dc36580a0ec7476aeed389948976a89c755d (patch)
tree5bd97dca565eaf86cbf3b0a2e36e268d4ef3e469 /erts/emulator/drivers/common/inet_drv.c
parent1137c0a08b25ab5e38286260f0b7c51ba015afbb (diff)
downloadotp-4181dc36580a0ec7476aeed389948976a89c755d.tar.gz
otp-4181dc36580a0ec7476aeed389948976a89c755d.tar.bz2
otp-4181dc36580a0ec7476aeed389948976a89c755d.zip
Fix cleanup when sendfile process crashes
When sendfile crashes during a send there should be no error_logger printouts about stolen fds.
Diffstat (limited to 'erts/emulator/drivers/common/inet_drv.c')
-rw-r--r--erts/emulator/drivers/common/inet_drv.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/erts/emulator/drivers/common/inet_drv.c b/erts/emulator/drivers/common/inet_drv.c
index abbd835605..634fc8e8e0 100644
--- a/erts/emulator/drivers/common/inet_drv.c
+++ b/erts/emulator/drivers/common/inet_drv.c
@@ -445,7 +445,7 @@ static int my_strncasecmp(const char *s1, const char *s2, size_t n)
driver_select(port, e, mode | (on?ERL_DRV_USE:0), on)
#define sock_select(d, flags, onoff) do { \
- ASSERT(!onoff || !(d)->is_ignored); \
+ ASSERT(!(d)->is_ignored); \
(d)->event_mask = (onoff) ? \
((d)->event_mask | (flags)) : \
((d)->event_mask & ~(flags)); \
@@ -3738,7 +3738,13 @@ static void desc_close(inet_descriptor* desc)
desc->forced_events = 0;
desc->send_would_block = 0;
#endif
- driver_select(desc->port, (ErlDrvEvent)(long)desc->event, ERL_DRV_USE, 0);
+ // We should close the fd here, but the other driver might still
+ // be selecting on it.
+ if (!desc->is_ignored)
+ driver_select(desc->port,(ErlDrvEvent)(long)desc->event,
+ ERL_DRV_USE, 0);
+ else
+ inet_stop_select((ErlDrvEvent)(long)desc->event,NULL);
desc->event = INVALID_EVENT; /* closed by stop_select callback */
desc->s = INVALID_SOCKET;
desc->event_mask = 0;
@@ -7612,8 +7618,8 @@ static int inet_ctl(inet_descriptor* desc, int cmd, char* buf, int len,
return ctl_error(EINVAL, rbuf, rsize);
if (*buf == 1 && !desc->is_ignored) {
- desc->is_ignored = INET_IGNORE_READ;
sock_select(desc, (FD_READ|FD_WRITE|FD_CLOSE|ERL_DRV_USE_NO_CALLBACK), 0);
+ desc->is_ignored = INET_IGNORE_READ;
} else if (*buf == 0 && desc->is_ignored) {
int flags = (FD_READ|FD_CLOSE|((desc->is_ignored & INET_IGNORE_WRITE)?FD_WRITE:0));
desc->is_ignored = INET_IGNORE_NONE;