[SCM] Samba Shared Repository - branch master updated -
release-4-0-0alpha8-113-g857ed9c
Stefan Metzmacher
metze at samba.org
Mon Jun 29 14:04:29 GMT 2009
The branch, master has been updated
via 857ed9ca5a99e20c0ff58e761ba87c7e6bc872bd (commit)
via b1d5e515b23acd50ae5c41c347a2cad1726d03fb (commit)
from bd997b257457d928108747bcca80ed7708f8dc74 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 857ed9ca5a99e20c0ff58e761ba87c7e6bc872bd
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Jun 29 13:13:05 2009 +0200
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
commit b1d5e515b23acd50ae5c41c347a2cad1726d03fb
Author: Stefan Metzmacher <metze at samba.org>
Date: Mon Jun 29 13:05:27 2009 +0200
tsocket/bsd: more correctly check if the cached tevent_fd is still valid
I some cases the pointer value of tevent_context is the same again,
if we do something like:
ev1 = tevent_context_init();
...
fde = tevent_add_fd(ev1, fd, TEVENT_FD_READ...);
...
talloc_free(ev1);
...
ev2 = tevent_context_init();
if (ev1 == ev2) {
/* this can happen! */
}
if (tevent_fd_get_flags(fde) == 0) {
/* this is always true */
}
But the "talloc_free(ev1)" will set fde->event_ctx to NULL
and tevent_fd_get_flags() will always return 0.
metze
-----------------------------------------------------------------------
Summary of changes:
lib/tsocket/tsocket_bsd.c | 27 +++++++++++++++++++++------
1 files changed, 21 insertions(+), 6 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/tsocket/tsocket_bsd.c b/lib/tsocket/tsocket_bsd.c
index a4cbda8..78bca4b 100644
--- a/lib/tsocket/tsocket_bsd.c
+++ b/lib/tsocket/tsocket_bsd.c
@@ -612,7 +612,9 @@ static int tdgram_bsd_set_readable_handler(struct tdgram_bsd *bsds,
TALLOC_FREE(bsds->fde);
}
- if (bsds->fde == NULL) {
+ if (tevent_fd_get_flags(bsds->fde) == 0) {
+ TALLOC_FREE(bsds->fde);
+
bsds->fde = tevent_add_fd(ev, bsds,
bsds->fd, TEVENT_FD_READ,
tdgram_bsd_fde_handler,
@@ -664,7 +666,9 @@ static int tdgram_bsd_set_writeable_handler(struct tdgram_bsd *bsds,
TALLOC_FREE(bsds->fde);
}
- if (bsds->fde == NULL) {
+ if (tevent_fd_get_flags(bsds->fde) == 0) {
+ TALLOC_FREE(bsds->fde);
+
bsds->fde = tevent_add_fd(ev, bsds,
bsds->fd, TEVENT_FD_WRITE,
tdgram_bsd_fde_handler,
@@ -1288,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;
}
@@ -1325,7 +1333,9 @@ static int tstream_bsd_set_readable_handler(struct tstream_bsd *bsds,
TALLOC_FREE(bsds->fde);
}
- if (bsds->fde == NULL) {
+ if (tevent_fd_get_flags(bsds->fde) == 0) {
+ TALLOC_FREE(bsds->fde);
+
bsds->fde = tevent_add_fd(ev, bsds,
bsds->fd, TEVENT_FD_READ,
tstream_bsd_fde_handler,
@@ -1377,9 +1387,12 @@ static int tstream_bsd_set_writeable_handler(struct tstream_bsd *bsds,
TALLOC_FREE(bsds->fde);
}
- if (bsds->fde == NULL) {
+ if (tevent_fd_get_flags(bsds->fde) == 0) {
+ 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) {
@@ -1390,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;
--
Samba Shared Repository
More information about the samba-cvs
mailing list