svn commit: samba r16950 - in branches/SAMBA_4_0/source: ntvfs ntvfs/cifs ntvfs/posix rpc_server/srvsvc smb_server smb_server/smb smb_server/smb2

metze at samba.org metze at samba.org
Tue Jul 11 18:15:43 GMT 2006


Author: metze
Date: 2006-07-11 18:15:42 +0000 (Tue, 11 Jul 2006)
New Revision: 16950

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16950

Log:
remove the smb mid from the ntvfs layer and keep a list of pending
requests on the smbsrv_connection, to be able to match then on
ntcancel

metze
Modified:
   branches/SAMBA_4_0/source/ntvfs/cifs/vfs_cifs.c
   branches/SAMBA_4_0/source/ntvfs/ntvfs.h
   branches/SAMBA_4_0/source/ntvfs/ntvfs_util.c
   branches/SAMBA_4_0/source/ntvfs/posix/pvfs_wait.c
   branches/SAMBA_4_0/source/rpc_server/srvsvc/dcesrv_srvsvc.c
   branches/SAMBA_4_0/source/rpc_server/srvsvc/srvsvc_ntvfs.c
   branches/SAMBA_4_0/source/smb_server/smb/reply.c
   branches/SAMBA_4_0/source/smb_server/smb/request.c
   branches/SAMBA_4_0/source/smb_server/smb/service.c
   branches/SAMBA_4_0/source/smb_server/smb2/smb2_server.h
   branches/SAMBA_4_0/source/smb_server/smb2/tcon.c
   branches/SAMBA_4_0/source/smb_server/smb_server.h


Changeset:
Modified: branches/SAMBA_4_0/source/ntvfs/cifs/vfs_cifs.c
===================================================================
--- branches/SAMBA_4_0/source/ntvfs/cifs/vfs_cifs.c	2006-07-11 18:06:53 UTC (rev 16949)
+++ branches/SAMBA_4_0/source/ntvfs/cifs/vfs_cifs.c	2006-07-11 18:15:42 UTC (rev 16950)
@@ -803,7 +803,7 @@
 
 	/* find the matching request */
 	for (a=private->pending;a;a=a->next) {
-		if (a->req->smbmid == req->smbmid) {
+		if (a->req == req) {
 			break;
 		}
 	}

Modified: branches/SAMBA_4_0/source/ntvfs/ntvfs.h
===================================================================
--- branches/SAMBA_4_0/source/ntvfs/ntvfs.h	2006-07-11 18:06:53 UTC (rev 16949)
+++ branches/SAMBA_4_0/source/ntvfs/ntvfs.h	2006-07-11 18:15:42 UTC (rev 16950)
@@ -253,9 +253,6 @@
 	/* the smb pid is needed for locking contexts */
 	uint16_t smbpid;
 
-	/* the smb mid is needed for matching requests */
-	uint16_t smbmid;
-
 	/* some statictics for the management tools */
 	struct {
 		/* the system time when the request arrived */

Modified: branches/SAMBA_4_0/source/ntvfs/ntvfs_util.c
===================================================================
--- branches/SAMBA_4_0/source/ntvfs/ntvfs_util.c	2006-07-11 18:06:53 UTC (rev 16949)
+++ branches/SAMBA_4_0/source/ntvfs/ntvfs_util.c	2006-07-11 18:15:42 UTC (rev 16950)
@@ -28,7 +28,7 @@
 
 _PUBLIC_ struct ntvfs_request *ntvfs_request_create(struct ntvfs_context *ctx, TALLOC_CTX *mem_ctx,
 						    struct auth_session_info *session_info,
-						    uint16_t smbpid, uint16_t smbmid,
+						    uint16_t smbpid,
 						    struct timeval request_time,
 						    void *private_data,
 						    void (*send_fn)(struct ntvfs_request *),
@@ -43,7 +43,6 @@
 	req->async_states		= NULL;
 	req->session_info		= session_info;
 	req->smbpid			= smbpid;
-	req->smbmid			= smbmid;
 	req->statistics.request_time	= request_time;
 
 	async = talloc(req, struct ntvfs_async_state);

Modified: branches/SAMBA_4_0/source/ntvfs/posix/pvfs_wait.c
===================================================================
--- branches/SAMBA_4_0/source/ntvfs/posix/pvfs_wait.c	2006-07-11 18:06:53 UTC (rev 16949)
+++ branches/SAMBA_4_0/source/ntvfs/posix/pvfs_wait.c	2006-07-11 18:15:42 UTC (rev 16950)
@@ -179,8 +179,7 @@
 	struct pvfs_wait *pwait;
 
 	for (pwait=pvfs->wait_list;pwait;pwait=pwait->next) {
-		if (req->smbmid == pwait->req->smbmid &&
-		    req->smbpid == pwait->req->smbpid) {
+		if (pwait->req == req) {
 			/* trigger a cancel on the request */
 			pwait->reason = PVFS_WAIT_CANCEL;
 			ntvfs_async_setup(pwait->req, pwait);

Modified: branches/SAMBA_4_0/source/rpc_server/srvsvc/dcesrv_srvsvc.c
===================================================================
--- branches/SAMBA_4_0/source/rpc_server/srvsvc/dcesrv_srvsvc.c	2006-07-11 18:06:53 UTC (rev 16949)
+++ branches/SAMBA_4_0/source/rpc_server/srvsvc/dcesrv_srvsvc.c	2006-07-11 18:15:42 UTC (rev 16950)
@@ -1417,7 +1417,6 @@
 	ntvfs_req = ntvfs_request_create(ntvfs_ctx, mem_ctx,
 					 dce_call->conn->auth_state.session_info,
 					 0,
-					 0,
 					 dce_call->time,
 					 NULL, NULL, 0);
 	W_ERROR_HAVE_NO_MEMORY(ntvfs_req);
@@ -1459,7 +1458,6 @@
 	ntvfs_req = ntvfs_request_create(ntvfs_ctx, mem_ctx,
 					 dce_call->conn->auth_state.session_info,
 					 0,
-					 0,
 					 dce_call->time,
 					 NULL, NULL, 0);
 	W_ERROR_HAVE_NO_MEMORY(ntvfs_req);

Modified: branches/SAMBA_4_0/source/rpc_server/srvsvc/srvsvc_ntvfs.c
===================================================================
--- branches/SAMBA_4_0/source/rpc_server/srvsvc/srvsvc_ntvfs.c	2006-07-11 18:06:53 UTC (rev 16949)
+++ branches/SAMBA_4_0/source/rpc_server/srvsvc/srvsvc_ntvfs.c	2006-07-11 18:15:42 UTC (rev 16950)
@@ -113,7 +113,6 @@
 	ntvfs_req = ntvfs_request_create(c->ntvfs, mem_ctx,
 					 dce_call->conn->auth_state.session_info,
 					 0, /* TODO: fill in PID */
-					 0, /* TODO: fill in MID */
 					 dce_call->time,
 					 NULL, NULL, 0);
 	NT_STATUS_HAVE_NO_MEMORY(ntvfs_req);

Modified: branches/SAMBA_4_0/source/smb_server/smb/reply.c
===================================================================
--- branches/SAMBA_4_0/source/smb_server/smb/reply.c	2006-07-11 18:06:53 UTC (rev 16949)
+++ branches/SAMBA_4_0/source/smb_server/smb/reply.c	2006-07-11 18:15:42 UTC (rev 16950)
@@ -633,7 +633,6 @@
 	req->ntvfs = ntvfs_request_create(req->tcon->ntvfs, req,
 					  req->session->session_info,
 					  SVAL(req->in.hdr,HDR_PID),
-					  SVAL(req->in.hdr,HDR_MID),
 					  req->request_time,
 					  req, NULL, 0);
 	if (!req->ntvfs) {
@@ -2197,10 +2196,24 @@
 ****************************************************************************/
 void smbsrv_reply_ntcancel(struct smbsrv_request *req)
 {
-	/* NOTE: this request does not generate a reply */
-	SMBSRV_SETUP_NTVFS_REQUEST(NULL,0);
-	ntvfs_cancel(req->ntvfs);
-	talloc_free(req);
+	struct smbsrv_request *r;
+	uint16_t mid = SVAL(req->in.hdr,HDR_MID);
+	uint16_t pid = SVAL(req->in.hdr,HDR_PID);
+
+	for (r = req->smb_conn->requests; r; r = r->next) {
+		if (mid != SVAL(r->in.hdr,HDR_MID)) continue;
+		/* do we really need to check the PID? */
+		if (pid != SVAL(r->in.hdr,HDR_PID)) continue;
+
+		SMBSRV_CHECK(ntvfs_cancel(r->ntvfs));
+
+		/* NOTE: this request does not generate a reply */
+		talloc_free(req);
+		return;
+	}
+
+	/* TODO: workout the correct error code */
+	smbsrv_send_error(req, NT_STATUS_FOOBAR);
 }
 
 /*

Modified: branches/SAMBA_4_0/source/smb_server/smb/request.c
===================================================================
--- branches/SAMBA_4_0/source/smb_server/smb/request.c	2006-07-11 18:06:53 UTC (rev 16949)
+++ branches/SAMBA_4_0/source/smb_server/smb/request.c	2006-07-11 18:15:42 UTC (rev 16950)
@@ -33,6 +33,12 @@
 /* we over allocate the data buffer to prevent too many realloc calls */
 #define REQ_OVER_ALLOCATION 0
 
+static int smbsrv_request_destructor(struct smbsrv_request *req)
+{
+	DLIST_REMOVE(req->smb_conn->requests, req);
+	return 0;
+}
+
 /****************************************************************************
 construct a basic request packet, mostly used to construct async packets
 such as change notify and oplock break requests
@@ -49,6 +55,8 @@
 	/* setup the request context */
 	req->smb_conn = smb_conn;
 
+	talloc_set_destructor(req, smbsrv_request_destructor);
+
 	return req;
 }
 

Modified: branches/SAMBA_4_0/source/smb_server/smb/service.c
===================================================================
--- branches/SAMBA_4_0/source/smb_server/smb/service.c	2006-07-11 18:06:53 UTC (rev 16949)
+++ branches/SAMBA_4_0/source/smb_server/smb/service.c	2006-07-11 18:15:42 UTC (rev 16950)
@@ -89,7 +89,6 @@
 	req->ntvfs = ntvfs_request_create(req->tcon->ntvfs, req,
 					  req->session->session_info,
 					  SVAL(req->in.hdr,HDR_PID),
-					  SVAL(req->in.hdr,HDR_MID),
 					  req->request_time,
 					  req, NULL, 0);
 	if (!req->ntvfs) {

Modified: branches/SAMBA_4_0/source/smb_server/smb2/smb2_server.h
===================================================================
--- branches/SAMBA_4_0/source/smb_server/smb2/smb2_server.h	2006-07-11 18:06:53 UTC (rev 16949)
+++ branches/SAMBA_4_0/source/smb_server/smb2/smb2_server.h	2006-07-11 18:15:42 UTC (rev 16950)
@@ -103,7 +103,6 @@
 	req->ntvfs = ntvfs_request_create(req->tcon->ntvfs, req, \
 					  req->session->session_info,\
 					  0, \
-					  0, \
 					  req->request_time, \
 					  req, send_fn, state); \
 	if (!req->ntvfs) { \

Modified: branches/SAMBA_4_0/source/smb_server/smb2/tcon.c
===================================================================
--- branches/SAMBA_4_0/source/smb_server/smb2/tcon.c	2006-07-11 18:06:53 UTC (rev 16949)
+++ branches/SAMBA_4_0/source/smb_server/smb2/tcon.c	2006-07-11 18:15:42 UTC (rev 16950)
@@ -242,7 +242,6 @@
 	req->ntvfs = ntvfs_request_create(req->tcon->ntvfs, req,
 					  req->session->session_info,
 					  0, /* TODO: fill in PID */
-					  0, /* TODO: fill in MID */
 					  req->request_time,
 					  req, NULL, 0);
 	if (!req->ntvfs) {

Modified: branches/SAMBA_4_0/source/smb_server/smb_server.h
===================================================================
--- branches/SAMBA_4_0/source/smb_server/smb_server.h	2006-07-11 18:06:53 UTC (rev 16949)
+++ branches/SAMBA_4_0/source/smb_server/smb_server.h	2006-07-11 18:15:42 UTC (rev 16950)
@@ -24,6 +24,7 @@
 #include "libcli/raw/interfaces.h"
 #include "lib/events/events.h"
 #include "lib/socket/socket.h"
+#include "dlinklist.h"
 
 /*
   this header declares the core context structures associated with smb
@@ -320,15 +321,11 @@
 	/* context associated with currently valid session setups */
 	struct smbsrv_sessions_context sessions;
 
-	/* the server_context holds a linked list of pending requests,
-	 * this is used for blocking locks and requests blocked due to oplock
-	 * break requests */
-	struct _smbsrv_pending_request {
-		struct _smbsrv_pending_request *next, *prev;
-	
-		/* the request itself - needs to be freed */
-		struct smbsrv_request *request;
-	} *requests;
+	/*
+	 * the server_context holds a linked list of pending requests,
+	 * this is used for finding the request structures on ntcancel requests
+	 */
+	struct smbsrv_request *requests;
 
 	struct smb_signing_context signing;
 
@@ -387,7 +384,6 @@
 	req->ntvfs = ntvfs_request_create(req->tcon->ntvfs, req, \
 					  req->session->session_info,\
 					  SVAL(req->in.hdr,HDR_PID), \
-					  SVAL(req->in.hdr,HDR_MID), \
 					  req->request_time, \
 					  req, send_fn, state); \
 	if (!req->ntvfs) { \
@@ -418,6 +414,15 @@
 	} \
 } while (0)
 
+#define SMBSRV_CHECK(cmd) do {\
+	NTSTATUS _status; \
+	_status = cmd; \
+	if (!NT_STATUS_IS_OK(_status)) { \
+		smbsrv_send_error(req,  _status); \
+		return; \
+	} \
+} while (0)
+
 /* 
    check if the backend wants to handle the request asynchronously.
    if it wants it handled synchronously then call the send function
@@ -425,7 +430,9 @@
 */
 #define SMBSRV_CALL_NTVFS_BACKEND(cmd) do { \
 	req->ntvfs->async_states->status = cmd; \
-	if (!(req->ntvfs->async_states->state & NTVFS_ASYNC_STATE_ASYNC)) { \
+	if (req->ntvfs->async_states->state & NTVFS_ASYNC_STATE_ASYNC) { \
+		DLIST_ADD_END(req->smb_conn->requests, req, struct smbsrv_request *); \
+	} else { \
 		req->ntvfs->async_states->send_fn(req->ntvfs); \
 	} \
 } while (0)



More information about the samba-cvs mailing list