diff options
author | Volker Lendecke <vl@samba.org> | 2008-08-01 23:18:15 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2008-08-28 17:53:36 +0200 |
commit | 8f408a676eb1d2bac665d8212d727dafeecd386e (patch) | |
tree | 7b765a8cf024c351feec379357b633fb4d695b24 | |
parent | 58aa97c0d9db06588d1aba4f06a3c98ed2098d8f (diff) | |
download | samba-8f408a676eb1d2bac665d8212d727dafeecd386e.tar.gz samba-8f408a676eb1d2bac665d8212d727dafeecd386e.tar.bz2 samba-8f408a676eb1d2bac665d8212d727dafeecd386e.zip |
Add async cli_close
(This used to be commit f84a2b5dbf8a072a9e356fa39523f65d042a2643)
-rw-r--r-- | source3/include/proto.h | 3 | ||||
-rw-r--r-- | source3/libsmb/clifile.c | 51 |
2 files changed, 41 insertions, 13 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h index 0e691d9062..41185a63b9 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -4379,6 +4379,9 @@ int cli_nt_create_full(struct cli_state *cli, const char *fname, uint8 SecuityFlags); int cli_nt_create(struct cli_state *cli, const char *fname, uint32 DesiredAccess); int cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode); +struct async_req *cli_close_send(TALLOC_CTX *mem_ctx, struct event_context *ev, + struct cli_state *cli, int fnum); +NTSTATUS cli_close_recv(struct async_req *req); bool cli_close(struct cli_state *cli, int fnum); bool cli_ftruncate(struct cli_state *cli, int fnum, uint64_t size); NTSTATUS cli_locktype(struct cli_state *cli, int fnum, diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c index 12b10ba0a0..20357bbec0 100644 --- a/source3/libsmb/clifile.c +++ b/source3/libsmb/clifile.c @@ -865,28 +865,53 @@ int cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode Close a file. ****************************************************************************/ -bool cli_close(struct cli_state *cli, int fnum) +struct async_req *cli_close_send(TALLOC_CTX *mem_ctx, struct cli_state *cli, + int fnum) { - memset(cli->outbuf,'\0',smb_size); - memset(cli->inbuf,'\0',smb_size); + uint16_t vwv[3]; - cli_set_message(cli->outbuf,3,0,True); + SSVAL(vwv+0, 0, fnum); + SIVALS(vwv+1, 0, -1); - SCVAL(cli->outbuf,smb_com,SMBclose); - SSVAL(cli->outbuf,smb_tid,cli->cnum); - cli_setup_packet(cli); + return cli_request_send(mem_ctx, cli, SMBclose, 0, 3, vwv, 0, NULL); +} - SSVAL(cli->outbuf,smb_vwv0,fnum); - SIVALS(cli->outbuf,smb_vwv1,-1); +NTSTATUS cli_close_recv(struct async_req *req) +{ + struct cli_request *cli_req = cli_request_get(req); - cli_send_smb(cli); - if (!cli_receive_smb(cli)) { - return False; + SMB_ASSERT(req->state >= ASYNC_REQ_DONE); + if (req->state == ASYNC_REQ_ERROR) { + return req->status; } - return !cli_is_error(cli); + return cli_pull_error(cli_req->inbuf); } +bool cli_close(struct cli_state *cli, int fnum) +{ + TALLOC_CTX *frame = talloc_stackframe(); + struct async_req *req; + bool result = false; + + if (cli_tmp_event_ctx(frame, cli) == NULL) { + goto fail; + } + + req = cli_close_send(frame, cli, fnum); + if (req == NULL) { + goto fail; + } + + while (req->state < ASYNC_REQ_DONE) { + event_loop_once(cli->event_ctx); + } + + result = NT_STATUS_IS_OK(cli_close_recv(req)); + fail: + TALLOC_FREE(frame); + return result; +} /**************************************************************************** Truncate a file to a specified size |