mirror of
https://github.com/samba-team/samba.git
synced 2025-02-02 09:47:23 +03:00
lib/tsocket: remember the first error as tstream_bsd->error
If we found that the connection is broken, there's no point in trying to use it anymore, so just return the first error we detected. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15202 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> (cherry picked from commit 4c7e2b9b60de5d02bb3f69effe7eddbf466a6155)
This commit is contained in:
parent
d8d5146d16
commit
aeb7dd2ca8
@ -1744,6 +1744,7 @@ int _tdgram_unix_socket(const struct tsocket_address *local,
|
||||
|
||||
struct tstream_bsd {
|
||||
int fd;
|
||||
int error;
|
||||
|
||||
void *event_ptr;
|
||||
struct tevent_fd *fde;
|
||||
@ -1921,7 +1922,19 @@ static ssize_t tstream_bsd_pending_bytes(struct tstream_context *stream)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (bsds->error != 0) {
|
||||
errno = bsds->error;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = tsocket_bsd_pending(bsds->fd);
|
||||
if (ret == -1) {
|
||||
/*
|
||||
* remember the error and don't
|
||||
* allow further requests
|
||||
*/
|
||||
bsds->error = errno;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -2029,9 +2042,15 @@ static void tstream_bsd_readv_handler(void *private_data)
|
||||
int _count;
|
||||
bool ok, retry;
|
||||
|
||||
if (bsds->error != 0) {
|
||||
tevent_req_error(req, bsds->error);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = readv(bsds->fd, state->vector, state->count);
|
||||
if (ret == 0) {
|
||||
/* propagate end of file */
|
||||
bsds->error = EPIPE;
|
||||
tevent_req_error(req, EPIPE);
|
||||
return;
|
||||
}
|
||||
@ -2040,6 +2059,13 @@ static void tstream_bsd_readv_handler(void *private_data)
|
||||
/* retry later */
|
||||
return;
|
||||
}
|
||||
if (err != 0) {
|
||||
/*
|
||||
* remember the error and don't
|
||||
* allow further requests
|
||||
*/
|
||||
bsds->error = err;
|
||||
}
|
||||
if (tevent_req_error(req, err)) {
|
||||
return;
|
||||
}
|
||||
@ -2172,9 +2198,15 @@ static void tstream_bsd_writev_handler(void *private_data)
|
||||
int _count;
|
||||
bool ok, retry;
|
||||
|
||||
if (bsds->error != 0) {
|
||||
tevent_req_error(req, bsds->error);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = writev(bsds->fd, state->vector, state->count);
|
||||
if (ret == 0) {
|
||||
/* propagate end of file */
|
||||
bsds->error = EPIPE;
|
||||
tevent_req_error(req, EPIPE);
|
||||
return;
|
||||
}
|
||||
@ -2183,6 +2215,13 @@ static void tstream_bsd_writev_handler(void *private_data)
|
||||
/* retry later */
|
||||
return;
|
||||
}
|
||||
if (err != 0) {
|
||||
/*
|
||||
* remember the error and don't
|
||||
* allow further requests
|
||||
*/
|
||||
bsds->error = err;
|
||||
}
|
||||
if (tevent_req_error(req, err)) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user