[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha6-288-gcee0d85

Volker Lendecke vlendec at samba.org
Sat Jan 31 10:09:59 GMT 2009


The branch, master has been updated
       via  cee0d85e0b2be27d9314206f3fe832fc0c75b0f3 (commit)
       via  d94e9c802ceddeff93168337b6fc5533db7f2d33 (commit)
       via  b99859b948f31dbe474b6ce0c6cab601e7e7bc56 (commit)
      from  ea157f495fec9906736ed3c79a84d9b71ae6ded3 (commit)

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


- Log -----------------------------------------------------------------
commit cee0d85e0b2be27d9314206f3fe832fc0c75b0f3
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jan 30 23:45:35 2009 +0100

    make send_file_readbraw static

commit d94e9c802ceddeff93168337b6fc5533db7f2d33
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jan 30 23:44:21 2009 +0100

    Remove the global variable "chain_size"

commit b99859b948f31dbe474b6ce0c6cab601e7e7bc56
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Jan 30 23:29:37 2009 +0100

    Make is_andx_req non-static

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

Summary of changes:
 source3/include/proto.h      |    7 ++-----
 source3/include/smb.h        |    5 -----
 source3/include/smb_macros.h |    2 +-
 source3/lib/util.c           |    3 ---
 source3/libsmb/async_smb.c   |   26 --------------------------
 source3/libsmb/clientgen.c   |   25 +++++++++++++++++++++++++
 source3/smbd/aio.c           |    6 ++----
 source3/smbd/blocking.c      |    7 +------
 source3/smbd/process.c       |   26 ++++++++++++++++++++++++--
 source3/smbd/reply.c         |   17 +++++++++--------
 10 files changed, 64 insertions(+), 60 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/proto.h b/source3/include/proto.h
index d30eb09..9199d6c 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -2472,6 +2472,7 @@ struct async_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
 NTSTATUS cli_echo_recv(struct async_req *req);
 NTSTATUS cli_echo(struct cli_state *cli, uint16_t num_echos, DATA_BLOB data);
 bool cli_ucs2(struct cli_state *cli);
+bool is_andx_req(uint8_t cmd);
 
 /* The following definitions come from libsmb/clierror.c  */
 
@@ -7200,6 +7201,7 @@ void remove_from_common_flags2(uint32 v);
 void construct_reply_common_req(struct smb_request *req, char *outbuf);
 size_t req_wct_ofs(struct smb_request *req);
 void chain_reply(struct smb_request *req);
+bool req_is_in_chain(struct smb_request *req);
 void check_reload(time_t t);
 void smbd_process(void);
 
@@ -7273,11 +7275,6 @@ void reply_ctemp(struct smb_request *req);
 NTSTATUS unlink_internals(connection_struct *conn, struct smb_request *req,
 			  uint32 dirtype, const char *name_in, bool has_wild);
 void reply_unlink(struct smb_request *req);
-void send_file_readbraw(connection_struct *conn,
-			files_struct *fsp,
-			SMB_OFF_T startpos,
-			size_t nread,
-			ssize_t mincount);
 void reply_readbraw(struct smb_request *req);
 void reply_lockread(struct smb_request *req);
 void reply_read(struct smb_request *req);
diff --git a/source3/include/smb.h b/source3/include/smb.h
index 9451710..be6ccbf 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -1550,11 +1550,6 @@ enum acl_compatibility {ACL_COMPAT_AUTO, ACL_COMPAT_WINNT, ACL_COMPAT_WIN2K};
 #define COPYBUF_SIZE (8*1024)
 
 /*
- * Used in chaining code.
- */
-extern int chain_size;
-
-/*
  * Map the Core and Extended Oplock requesst bits down
  * to common bits (EXCLUSIVE_OPLOCK & BATCH_OPLOCK).
  */
diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h
index 92c60a7..fd1bba1 100644
--- a/source3/include/smb_macros.h
+++ b/source3/include/smb_macros.h
@@ -135,7 +135,7 @@
 
 
 /* Note that chain_size must be available as an extern int to this macro. */
-#define smb_offset(p,buf) (PTR_DIFF(p,buf+4) + chain_size)
+#define smb_offset(p,buf) (PTR_DIFF(p,buf+4))
 
 #define smb_len(buf) (PVAL(buf,3)|(PVAL(buf,2)<<8)|((PVAL(buf,1)&1)<<16))
 #define _smb_setlen(buf,len) do { buf[0] = 0; buf[1] = ((len)&0x10000)>>16; \
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 195065a..df01c03 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -57,9 +57,6 @@ extern unsigned int global_clobber_region_line;
 
 enum protocol_types Protocol = PROTOCOL_COREPLUS;
 
-/* this is used by the chaining code */
-int chain_size = 0;
-
 static enum remote_arch_types ra_type = RA_UNKNOWN;
 
 /***********************************************************************
diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c
index a4bbe6d..18e5a71 100644
--- a/source3/libsmb/async_smb.c
+++ b/source3/libsmb/async_smb.c
@@ -152,32 +152,6 @@ bool cli_in_chain(struct cli_state *cli)
 }
 
 /**
- * Is the SMB command able to hold an AND_X successor
- * @param[in] cmd	The SMB command in question
- * @retval Can we add a chained request after "cmd"?
- */
-
-static bool is_andx_req(uint8_t cmd)
-{
-	switch (cmd) {
-	case SMBtconX:
-	case SMBlockingX:
-	case SMBopenX:
-	case SMBreadX:
-	case SMBwriteX:
-	case SMBsesssetupX:
-	case SMBulogoffX:
-	case SMBntcreateX:
-		return true;
-		break;
-	default:
-		break;
-	}
-
-	return false;
-}
-
-/**
  * @brief Find the smb_cmd offset of the last command pushed
  * @param[in] buf	The buffer we're building up
  * @retval		Where can we put our next andx cmd?
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index d841bcf..a41aa11 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -775,3 +775,28 @@ NTSTATUS cli_echo(struct cli_state *cli, uint16_t num_echos, DATA_BLOB data)
 	TALLOC_FREE(frame);
 	return status;
 }
+
+/**
+ * Is the SMB command able to hold an AND_X successor
+ * @param[in] cmd	The SMB command in question
+ * @retval Can we add a chained request after "cmd"?
+ */
+bool is_andx_req(uint8_t cmd)
+{
+	switch (cmd) {
+	case SMBtconX:
+	case SMBlockingX:
+	case SMBopenX:
+	case SMBreadX:
+	case SMBwriteX:
+	case SMBsesssetupX:
+	case SMBulogoffX:
+	case SMBntcreateX:
+		return true;
+		break;
+	default:
+		break;
+	}
+
+	return false;
+}
diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c
index 4ce43c9..64d512d 100644
--- a/source3/smbd/aio.c
+++ b/source3/smbd/aio.c
@@ -141,8 +141,7 @@ bool schedule_aio_read_and_X(connection_struct *conn,
 
 	/* Only do this on non-chained and non-chaining reads not using the
 	 * write cache. */
-        if (chain_size !=0 || (CVAL(req->vwv+0, 0) != 0xFF)
-	    || (lp_write_cache_size(SNUM(conn)) != 0) ) {
+        if (req_is_in_chain(req) || (lp_write_cache_size(SNUM(conn)) != 0)) {
 		return False;
 	}
 
@@ -238,8 +237,7 @@ bool schedule_aio_write_and_X(connection_struct *conn,
 
 	/* Only do this on non-chained and non-chaining reads not using the
 	 * write cache. */
-        if (chain_size !=0 || (CVAL(req->vwv+0, 0) != 0xFF)
-	    || (lp_write_cache_size(SNUM(conn)) != 0) ) {
+        if (req_is_in_chain(req) || (lp_write_cache_size(SNUM(conn)) != 0)) {
 		return False;
 	}
 
diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c
index 9936fb2..ac1ff00 100644
--- a/source3/smbd/blocking.c
+++ b/source3/smbd/blocking.c
@@ -47,11 +47,6 @@ typedef struct blocking_lock_record {
  Determine if this is a secondary element of a chained SMB.
   **************************************************************************/
 
-static bool in_chained_smb(void)
-{
-	return (chain_size != 0);
-}
-
 static void received_unlock_msg(struct messaging_context *msg,
 				void *private_data,
 				uint32_t msg_type,
@@ -144,7 +139,7 @@ bool push_blocking_lock_request( struct byte_range_lock *br_lck,
 	blocking_lock_record *blr;
 	NTSTATUS status;
 
-	if(in_chained_smb() ) {
+	if(req_is_in_chain(req)) {
 		DEBUG(0,("push_blocking_lock_request: cannot queue a chained request (currently).\n"));
 		return False;
 	}
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index d617ef1..c9fc1fb 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -1359,8 +1359,6 @@ static void construct_reply(char *inbuf, int size, size_t unread_bytes, bool enc
 	connection_struct *conn;
 	struct smb_request *req;
 
-	chain_size = 0;
-
 	if (!(req = talloc(talloc_tos(), struct smb_request))) {
 		smb_panic("could not allocate smb_request");
 	}
@@ -2114,3 +2112,27 @@ void smbd_process(void)
 
 	exit_server_cleanly(NULL);
 }
+
+bool req_is_in_chain(struct smb_request *req)
+{
+	if (req->vwv != (uint16_t *)(req->inbuf+smb_vwv)) {
+		/*
+		 * We're right now handling a subsequent request, so we must
+		 * be in a chain
+		 */
+		return true;
+	}
+
+	if (!is_andx_req(req->cmd)) {
+		return false;
+	}
+
+	if (req->wct < 2) {
+		/*
+		 * Okay, an illegal request, but definitely not chained :-)
+		 */
+		return false;
+	}
+
+	return (CVAL(req->vwv+0, 0) != 0xFF);
+}
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 25d5047..f2d4ff7 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -2728,11 +2728,12 @@ static void reply_readbraw_error(void)
  Use sendfile in readbraw.
 ****************************************************************************/
 
-void send_file_readbraw(connection_struct *conn,
-			files_struct *fsp,
-			SMB_OFF_T startpos,
-			size_t nread,
-			ssize_t mincount)
+static void send_file_readbraw(connection_struct *conn,
+			       struct smb_request *req,
+			       files_struct *fsp,
+			       SMB_OFF_T startpos,
+			       size_t nread,
+			       ssize_t mincount)
 {
 	char *outbuf = NULL;
 	ssize_t ret=0;
@@ -2745,7 +2746,7 @@ void send_file_readbraw(connection_struct *conn,
 	 * reply_readbraw has already checked the length.
 	 */
 
-	if ( (chain_size == 0) && (nread > 0) && (fsp->base_fsp == NULL) &&
+	if ( !req_is_in_chain(req) && (nread > 0) && (fsp->base_fsp == NULL) &&
 	    (fsp->wcp == NULL) && lp_use_sendfile(SNUM(conn)) ) {
 		ssize_t sendfile_read = -1;
 		char header[4];
@@ -2963,7 +2964,7 @@ void reply_readbraw(struct smb_request *req)
 		(unsigned long)mincount,
 		(unsigned long)nread ) );
 
-	send_file_readbraw(conn, fsp, startpos, nread, mincount);
+	send_file_readbraw(conn, req, fsp, startpos, nread, mincount);
 
 	DEBUG(5,("reply_readbraw finished\n"));
 	END_PROFILE(SMBreadbraw);
@@ -3229,7 +3230,7 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req,
 	 * on a train in Germany :-). JRA.
 	 */
 
-	if ((chain_size == 0) && (CVAL(req->vwv+0, 0) == 0xFF) &&
+	if (!req_is_in_chain(req) &&
 	    !is_encrypted_packet(req->inbuf) && (fsp->base_fsp == NULL) &&
 	    lp_use_sendfile(SNUM(conn)) && (fsp->wcp == NULL) ) {
 		uint8 headerbuf[smb_size + 12 * 2];


-- 
Samba Shared Repository


More information about the samba-cvs mailing list