[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha7-1463-g512879a

Jeremy Allison jra at samba.org
Wed May 6 22:08:22 GMT 2009


The branch, master has been updated
       via  512879a69b6e94c323c37a6c0e56824c097b7f70 (commit)
      from  78754ab2c9b28ea8ab09d3fd1f5450abe721a2c1 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 512879a69b6e94c323c37a6c0e56824c097b7f70
Author: Jeremy Allison <jra at samba.org>
Date:   Wed May 6 15:07:05 2009 -0700

    Make cli_setattrE async.
    Jeremy.

-----------------------------------------------------------------------

Summary of changes:
 source3/include/proto.h         |   17 ++++-
 source3/libsmb/clifile.c        |  120 +++++++++++++++++++++++++++++++--------
 source3/libsmb/libsmb_file.c    |    4 +-
 source3/utils/net_rpc_printer.c |    2 +-
 4 files changed, 112 insertions(+), 31 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/proto.h b/source3/include/proto.h
index 6b1febb..9a8b6a8 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2460,10 +2460,19 @@ NTSTATUS cli_getattrE(struct cli_state *cli,
 			time_t *change_time,
 			time_t *access_time,
 			time_t *write_time);
-bool cli_setattrE(struct cli_state *cli, int fd,
-		  time_t change_time,
-                  time_t access_time,
-                  time_t write_time);
+struct tevent_req *cli_setattrE_send(TALLOC_CTX *mem_ctx,
+				struct event_context *ev,
+				struct cli_state *cli,
+				uint16_t fnum,
+				time_t change_time,
+				time_t access_time,
+				time_t write_time);
+NTSTATUS cli_setattrE_recv(struct tevent_req *req);
+NTSTATUS cli_setattrE(struct cli_state *cli,
+			uint16_t fnum,
+			time_t change_time,
+			time_t access_time,
+			time_t write_time);
 struct tevent_req *cli_getatr_send(TALLOC_CTX *mem_ctx,
 				struct event_context *ev,
 				struct cli_state *cli,
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 357923a..7983516 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -2391,43 +2391,115 @@ NTSTATUS cli_getatr(struct cli_state *cli,
  Do a SMBsetattrE call.
 ****************************************************************************/
 
-bool cli_setattrE(struct cli_state *cli, int fd,
-		  time_t change_time,
-                  time_t access_time,
-                  time_t write_time)
+static void cli_setattrE_done(struct tevent_req *subreq);
 
+struct cli_setattrE_state {
+	int dummy;
+};
+
+struct tevent_req *cli_setattrE_send(TALLOC_CTX *mem_ctx,
+				struct event_context *ev,
+				struct cli_state *cli,
+				uint16_t fnum,
+				time_t change_time,
+				time_t access_time,
+				time_t write_time)
 {
-	char *p;
+	struct tevent_req *req = NULL, *subreq = NULL;
+	struct cli_setattrE_state *state = NULL;
+	uint8_t additional_flags = 0;
+	uint16_t vwv[7];
 
-	memset(cli->outbuf,'\0',smb_size);
-	memset(cli->inbuf,'\0',smb_size);
+	req = tevent_req_create(mem_ctx, &state, struct cli_setattrE_state);
+	if (req == NULL) {
+		return NULL;
+	}
 
-	cli_set_message(cli->outbuf,7,0,True);
+	memset(vwv, '\0', sizeof(vwv));
+	SSVAL(vwv+0, 0, fnum);
+	cli_put_dos_date2(cli, (char *)&vwv[1], 0, change_time);
+	cli_put_dos_date2(cli, (char *)&vwv[3], 0, access_time);
+	cli_put_dos_date2(cli, (char *)&vwv[5], 0, write_time);
 
-	SCVAL(cli->outbuf,smb_com,SMBsetattrE);
-	SSVAL(cli->outbuf,smb_tid,cli->cnum);
-	cli_setup_packet(cli);
+	subreq = cli_smb_send(state, ev, cli, SMBsetattrE, additional_flags,
+			      7, vwv, 0, NULL);
+	if (tevent_req_nomem(subreq, req)) {
+		return tevent_req_post(req, ev);
+	}
+	tevent_req_set_callback(subreq, cli_setattrE_done, req);
+	return req;
+}
 
-	SSVAL(cli->outbuf,smb_vwv0, fd);
-	cli_put_dos_date2(cli, cli->outbuf,smb_vwv1, change_time);
-	cli_put_dos_date2(cli, cli->outbuf,smb_vwv3, access_time);
-	cli_put_dos_date2(cli, cli->outbuf,smb_vwv5, write_time);
+static void cli_setattrE_done(struct tevent_req *subreq)
+{
+	struct tevent_req *req = tevent_req_callback_data(
+		subreq, struct tevent_req);
+	NTSTATUS status;
 
-	p = smb_buf(cli->outbuf);
-	*p++ = 4;
+	status = cli_smb_recv(subreq, 0, NULL, NULL, NULL, NULL);
+	TALLOC_FREE(subreq);
+	if (!NT_STATUS_IS_OK(status)) {
+		tevent_req_nterror(req, status);
+		return;
+	}
+	tevent_req_done(req);
+}
 
-	cli_setup_bcc(cli, p);
+NTSTATUS cli_setattrE_recv(struct tevent_req *req)
+{
+	return tevent_req_simple_recv_ntstatus(req);
+}
 
-	cli_send_smb(cli);
-	if (!cli_receive_smb(cli)) {
-		return False;
+NTSTATUS cli_setattrE(struct cli_state *cli,
+			uint16_t fnum,
+			time_t change_time,
+			time_t access_time,
+			time_t write_time)
+{
+	TALLOC_CTX *frame = talloc_stackframe();
+	struct event_context *ev = NULL;
+	struct tevent_req *req = NULL;
+	NTSTATUS status = NT_STATUS_OK;
+
+	if (cli_has_async_calls(cli)) {
+		/*
+		 * Can't use sync call while an async call is in flight
+		 */
+		status = NT_STATUS_INVALID_PARAMETER;
+		goto fail;
 	}
 
-	if (cli_is_error(cli)) {
-		return False;
+	ev = event_context_init(frame);
+	if (ev == NULL) {
+		status = NT_STATUS_NO_MEMORY;
+		goto fail;
 	}
 
-	return True;
+	req = cli_setattrE_send(frame, ev,
+			cli,
+			fnum,
+			change_time,
+			access_time,
+			write_time);
+
+	if (req == NULL) {
+		status = NT_STATUS_NO_MEMORY;
+		goto fail;
+	}
+
+	if (!tevent_req_poll(req, ev)) {
+		status = map_nt_error_from_unix(errno);
+		goto fail;
+	}
+
+	status = cli_setattrE_recv(req);
+
+ fail:
+	TALLOC_FREE(frame);
+	if (!NT_STATUS_IS_OK(status)) {
+		cli_set_error(cli, status);
+	}
+	return status;
 }
 
 /****************************************************************************
diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c
index 63590d2..1bb1212 100644
--- a/source3/libsmb/libsmb_file.c
+++ b/source3/libsmb/libsmb_file.c
@@ -669,10 +669,10 @@ SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path,
                 }
                 
                 /* Set the new attributes */
-                ret = cli_setattrE(srv->cli, fd,
+                ret = NT_STATUS_IS_OK(cli_setattrE(srv->cli, fd,
                                    change_time,
                                    access_time,
-                                   write_time);
+                                   write_time));
                 
                 /* Close the file */
                 cli_close(srv->cli, fd);
diff --git a/source3/utils/net_rpc_printer.c b/source3/utils/net_rpc_printer.c
index 10fd415..b01c5af 100644
--- a/source3/utils/net_rpc_printer.c
+++ b/source3/utils/net_rpc_printer.c
@@ -221,7 +221,7 @@ NTSTATUS net_copy_fileattr(struct net_context *c,
 	if (copy_timestamps) {
 
 		/* set timestamps */
-		if (!cli_setattrE(cli_share_dst, fnum_dst, f_ctime, f_atime, f_mtime)) {
+		if (!NT_STATUS_IS_OK(cli_setattrE(cli_share_dst, fnum_dst, f_ctime, f_atime, f_mtime))) {
 			DEBUG(0,("failed to set file-attrs (timestamps): %s\n",
 				cli_errstr(cli_share_dst)));
 			nt_status = cli_nt_error(cli_share_dst);


-- 
Samba Shared Repository


More information about the samba-cvs mailing list