summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@sernet.de>2008-09-05 11:48:36 +0200
committerVolker Lendecke <vl@samba.org>2008-09-05 12:33:48 +0200
commitf912ac962a0e0a79496178227e2a6614f700dde3 (patch)
treeb7ae7fdc6876af09b5463343540c5b16276fbc18
parentc1d4ae3b59f235bd5efa5ee661c9e3eb487b68f9 (diff)
downloadsamba-f912ac962a0e0a79496178227e2a6614f700dde3.tar.gz
samba-f912ac962a0e0a79496178227e2a6614f700dde3.tar.bz2
samba-f912ac962a0e0a79496178227e2a6614f700dde3.zip
Do proper error handling if the socket is closed
(This used to be commit e5a27773f97d7017cfa345799c6803fd82c8e797)
-rw-r--r--source3/libsmb/async_smb.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c
index 79a924b9db..a4c58aa5c7 100644
--- a/source3/libsmb/async_smb.c
+++ b/source3/libsmb/async_smb.c
@@ -845,6 +845,7 @@ static void cli_state_handler(struct event_context *event_ctx,
{
struct cli_state *cli = (struct cli_state *)p;
struct cli_request *req;
+ NTSTATUS status;
DEBUG(11, ("cli_state_handler called with flags %d\n", flags));
@@ -857,11 +858,13 @@ static void cli_state_handler(struct event_context *event_ctx,
if (res == -1) {
DEBUG(10, ("ioctl(FIONREAD) failed: %s\n",
strerror(errno)));
+ status = map_nt_error_from_unix(errno);
goto sock_error;
}
if (available == 0) {
/* EOF */
+ status = NT_STATUS_END_OF_FILE;
goto sock_error;
}
@@ -870,6 +873,7 @@ static void cli_state_handler(struct event_context *event_ctx,
if (new_size < old_size) {
/* wrap */
+ status = NT_STATUS_UNEXPECTED_IO_ERROR;
goto sock_error;
}
@@ -877,6 +881,7 @@ static void cli_state_handler(struct event_context *event_ctx,
new_size);
if (tmp == NULL) {
/* nomem */
+ status = NT_STATUS_NO_MEMORY;
goto sock_error;
}
cli->evt_inbuf = tmp;
@@ -884,6 +889,7 @@ static void cli_state_handler(struct event_context *event_ctx,
res = recv(cli->fd, cli->evt_inbuf + old_size, available, 0);
if (res == -1) {
DEBUG(10, ("recv failed: %s\n", strerror(errno)));
+ status = map_nt_error_from_unix(errno);
goto sock_error;
}
@@ -930,6 +936,7 @@ static void cli_state_handler(struct event_context *event_ctx,
to_send - req->sent, 0);
if (sent < 0) {
+ status = map_nt_error_from_unix(errno);
goto sock_error;
}
@@ -945,8 +952,7 @@ static void cli_state_handler(struct event_context *event_ctx,
for (req = cli->outstanding_requests; req; req = req->next) {
int i;
for (i=0; i<req->num_async; i++) {
- req->async[i]->state = ASYNC_REQ_ERROR;
- req->async[i]->status = map_nt_error_from_unix(errno);
+ async_req_error(req->async[i], status);
}
}
TALLOC_FREE(cli->fd_event);