summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2009-04-05 06:33:17 +0200
committerVolker Lendecke <vl@samba.org>2009-04-06 21:32:07 +0200
commit17b8d05b624bd87dfe3c996cd10be5a981007bac (patch)
tree559b3a9e822de6f8926a3b37cc848c0ab3b5511b /source3
parentc23ccff13a6e92b37a104845736e5e8cecd27f35 (diff)
downloadsamba-17b8d05b624bd87dfe3c996cd10be5a981007bac.tar.gz
samba-17b8d05b624bd87dfe3c996cd10be5a981007bac.tar.bz2
samba-17b8d05b624bd87dfe3c996cd10be5a981007bac.zip
Streamline cli_pull sync wrapper
Diffstat (limited to 'source3')
-rw-r--r--source3/libsmb/clireadwrite.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c
index a59b26f961..08b9684f63 100644
--- a/source3/libsmb/clireadwrite.c
+++ b/source3/libsmb/clireadwrite.c
@@ -512,34 +512,43 @@ NTSTATUS cli_pull(struct cli_state *cli, uint16_t fnum,
TALLOC_CTX *frame = talloc_stackframe();
struct event_context *ev;
struct async_req *req;
- NTSTATUS result = NT_STATUS_NO_MEMORY;
+ NTSTATUS status = NT_STATUS_OK;
- if (cli->fd_event != NULL) {
+ if (cli_has_async_calls(cli)) {
/*
* Can't use sync call while an async call is in flight
*/
- return NT_STATUS_INVALID_PARAMETER;
+ status = NT_STATUS_INVALID_PARAMETER;
+ goto fail;
}
ev = event_context_init(frame);
if (ev == NULL) {
- goto nomem;
+ status = NT_STATUS_NO_MEMORY;
+ goto fail;
}
req = cli_pull_send(frame, ev, cli, fnum, start_offset, size,
window_size, sink, priv);
if (req == NULL) {
- goto nomem;
+ status = NT_STATUS_NO_MEMORY;
+ goto fail;
}
while (req->state < ASYNC_REQ_DONE) {
- event_loop_once(ev);
+ if (event_loop_once(ev) == -1) {
+ status = map_nt_error_from_unix(errno);
+ goto fail;
+ }
}
- result = cli_pull_recv(req, received);
- nomem:
+ status = cli_pull_recv(req, received);
+ fail:
TALLOC_FREE(frame);
- return result;
+ if (!NT_STATUS_IS_OK(status)) {
+ cli_set_error(cli, status);
+ }
+ return status;
}
static NTSTATUS cli_read_sink(char *buf, size_t n, void *priv)