summaryrefslogtreecommitdiff
path: root/lib/tsocket
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2009-06-29 13:13:05 +0200
committerStefan Metzmacher <metze@samba.org>2009-06-29 16:03:57 +0200
commit857ed9ca5a99e20c0ff58e761ba87c7e6bc872bd (patch)
treed4e85bb21410073eb23cab061f84857c52d109b3 /lib/tsocket
parentb1d5e515b23acd50ae5c41c347a2cad1726d03fb (diff)
downloadsamba-857ed9ca5a99e20c0ff58e761ba87c7e6bc872bd.tar.gz
samba-857ed9ca5a99e20c0ff58e761ba87c7e6bc872bd.tar.bz2
samba-857ed9ca5a99e20c0ff58e761ba87c7e6bc872bd.zip
tsocket/bsd: also ask for TEVENT_FD_READ when we want to write into a stream socket
Otherwise we would not notice a broken connection. metze
Diffstat (limited to 'lib/tsocket')
-rw-r--r--lib/tsocket/tsocket_bsd.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/tsocket/tsocket_bsd.c b/lib/tsocket/tsocket_bsd.c
index 4f4b166e7d..78bca4b0b5 100644
--- a/lib/tsocket/tsocket_bsd.c
+++ b/lib/tsocket/tsocket_bsd.c
@@ -1292,6 +1292,10 @@ static void tstream_bsd_fde_handler(struct tevent_context *ev,
}
if (flags & TEVENT_FD_READ) {
if (!bsds->readable_handler) {
+ if (bsds->writeable_handler) {
+ bsds->writeable_handler(bsds->writeable_private);
+ return;
+ }
TEVENT_FD_NOT_READABLE(bsds->fde);
return;
}
@@ -1387,7 +1391,8 @@ static int tstream_bsd_set_writeable_handler(struct tstream_bsd *bsds,
TALLOC_FREE(bsds->fde);
bsds->fde = tevent_add_fd(ev, bsds,
- bsds->fd, TEVENT_FD_WRITE,
+ bsds->fd,
+ TEVENT_FD_READ | TEVENT_FD_WRITE,
tstream_bsd_fde_handler,
bsds);
if (!bsds->fde) {
@@ -1398,7 +1403,9 @@ static int tstream_bsd_set_writeable_handler(struct tstream_bsd *bsds,
/* cache the event context we're running on */
bsds->event_ptr = ev;
} else if (!bsds->writeable_handler) {
- TEVENT_FD_WRITEABLE(bsds->fde);
+ uint16_t flags = tevent_fd_get_flags(bsds->fde);
+ flags |= TEVENT_FD_READ | TEVENT_FD_WRITE;
+ tevent_fd_set_flags(bsds->fde, flags);
}
bsds->writeable_handler = handler;