summaryrefslogtreecommitdiff
path: root/source4/smb_server
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2006-07-11 18:15:42 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:10:02 -0500
commit3b36a857980b1f9fa5a6be0253e85c975f35c13f (patch)
tree3eadbd0a44cb67b6773e0bee0e81af688c097854 /source4/smb_server
parentd89b4adf7abdc74f23960dee3f4961006ac12be6 (diff)
downloadsamba-3b36a857980b1f9fa5a6be0253e85c975f35c13f.tar.gz
samba-3b36a857980b1f9fa5a6be0253e85c975f35c13f.tar.bz2
samba-3b36a857980b1f9fa5a6be0253e85c975f35c13f.zip
r16950: 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 (This used to be commit 04f0d3d03179b6060fd013b867d13caa92ec6460)
Diffstat (limited to 'source4/smb_server')
-rw-r--r--source4/smb_server/smb/reply.c23
-rw-r--r--source4/smb_server/smb/request.c8
-rw-r--r--source4/smb_server/smb/service.c1
-rw-r--r--source4/smb_server/smb2/smb2_server.h1
-rw-r--r--source4/smb_server/smb2/tcon.c1
-rw-r--r--source4/smb_server/smb_server.h29
6 files changed, 44 insertions, 19 deletions
diff --git a/source4/smb_server/smb/reply.c b/source4/smb_server/smb/reply.c
index 75830ae73a..c79ad15ea8 100644
--- a/source4/smb_server/smb/reply.c
+++ b/source4/smb_server/smb/reply.c
@@ -633,7 +633,6 @@ void smbsrv_reply_readbraw(struct smbsrv_request *req)
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_ntcreate_and_X(struct smbsrv_request *req)
****************************************************************************/
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);
}
/*
diff --git a/source4/smb_server/smb/request.c b/source4/smb_server/smb/request.c
index a08ae46852..fc7d060ea8 100644
--- a/source4/smb_server/smb/request.c
+++ b/source4/smb_server/smb/request.c
@@ -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 @@ struct smbsrv_request *smbsrv_init_request(struct smbsrv_connection *smb_conn)
/* setup the request context */
req->smb_conn = smb_conn;
+ talloc_set_destructor(req, smbsrv_request_destructor);
+
return req;
}
diff --git a/source4/smb_server/smb/service.c b/source4/smb_server/smb/service.c
index 676f417619..92967d858c 100644
--- a/source4/smb_server/smb/service.c
+++ b/source4/smb_server/smb/service.c
@@ -89,7 +89,6 @@ static NTSTATUS make_connection_snum(struct smbsrv_request *req,
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) {
diff --git a/source4/smb_server/smb2/smb2_server.h b/source4/smb_server/smb2/smb2_server.h
index ce13756836..838abdf4d6 100644
--- a/source4/smb_server/smb2/smb2_server.h
+++ b/source4/smb_server/smb2/smb2_server.h
@@ -103,7 +103,6 @@ struct smbsrv_request;
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) { \
diff --git a/source4/smb_server/smb2/tcon.c b/source4/smb_server/smb2/tcon.c
index cc0a911224..338fb5ed22 100644
--- a/source4/smb_server/smb2/tcon.c
+++ b/source4/smb_server/smb2/tcon.c
@@ -242,7 +242,6 @@ static NTSTATUS smb2srv_tcon_backend(struct smb2srv_request *req, union smb_tcon
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) {
diff --git a/source4/smb_server/smb_server.h b/source4/smb_server/smb_server.h
index 7ad1af2d27..c546de7e1c 100644
--- a/source4/smb_server/smb_server.h
+++ b/source4/smb_server/smb_server.h
@@ -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 @@ struct smbsrv_connection {
/* 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 @@ struct smbsrv_connection {
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 @@ struct smbsrv_connection {
} \
} 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 @@ struct smbsrv_connection {
*/
#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)