From 857ed9ca5a99e20c0ff58e761ba87c7e6bc872bd Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 29 Jun 2009 13:13:05 +0200 Subject: 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 --- lib/tsocket/tsocket_bsd.c | 11 +++++++++-- 1 file 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; -- cgit