mirror of
https://github.com/samba-team/samba.git
synced 2025-02-28 01:58:17 +03:00
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
This commit is contained in:
parent
bd997b2574
commit
b1d5e515b2
@ -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,
|
||||
@ -1325,7 +1329,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,7 +1383,9 @@ 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,
|
||||
tstream_bsd_fde_handler,
|
||||
|
Loading…
x
Reference in New Issue
Block a user