summaryrefslogtreecommitdiff
path: root/source3/smbd/reply.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>1998-08-20 19:28:37 +0000
committerJeremy Allison <jra@samba.org>1998-08-20 19:28:37 +0000
commitdc76502cd8a950f6aff84ce4eedfd9d2b30d3dcc (patch)
tree8d8aead30371fec7fa6b191468098d631a6002af /source3/smbd/reply.c
parent852519282d43d7d12c103c01ca979952f041d683 (diff)
downloadsamba-dc76502cd8a950f6aff84ce4eedfd9d2b30d3dcc.tar.gz
samba-dc76502cd8a950f6aff84ce4eedfd9d2b30d3dcc.tar.bz2
samba-dc76502cd8a950f6aff84ce4eedfd9d2b30d3dcc.zip
Turning on blocking locking code. NB. Blocking lock requests that are not
the head of an SMB request (ie. are part of a chain) will not be queued - this will be fixed when we move to the new chain code. In practice, this doesn't seem to cause much of a problem (in my admittedly limited testing) bug a debug level zero message will be placed in the log when this happens to help determine how real the problem is. smbd/locking.c: New debug messages. smbd/blocking.c: New blocking code - handles SMBlock, SMBlockread and SMBlockingX smbd/chgpasswd.c: Fix for master fd leak. smbd/files.c: Tidyup comment. smbd/nttrans.c: Added fnum to debug message. smbd/process.c: Made chain_reply() use construct_reply_common(). Added blocking lock queue processing into idle loop. smbd/reply.c: Added queue pushes for SMBlock, SMBlockread and SMBlockingX. Jeremy. (This used to be commit e1dd03ecda0bc6d7eaa31070c83774bb5679fd1b)
Diffstat (limited to 'source3/smbd/reply.c')
-rw-r--r--source3/smbd/reply.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 28fed8bc04..3e59e7dbd0 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -1861,7 +1861,7 @@ int reply_readbraw(connection_struct *conn, char *inbuf, char *outbuf, int dum_s
/****************************************************************************
reply to a lockread (core+ protocol)
****************************************************************************/
-int reply_lockread(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsiz)
+int reply_lockread(connection_struct *conn, char *inbuf,char *outbuf, int length, int dum_buffsiz)
{
int nread = -1;
char *data;
@@ -1882,8 +1882,18 @@ int reply_lockread(connection_struct *conn, char *inbuf,char *outbuf, int dum_si
numtoread = MIN(BUFFER_SIZE-outsize,numtoread);
data = smb_buf(outbuf) + 3;
- if(!do_lock( fsp, conn, numtoread, startpos, F_RDLCK, &eclass, &ecode))
+ if(!do_lock( fsp, conn, numtoread, startpos, F_RDLCK, &eclass, &ecode)) {
+ if(ecode == ERRlock) {
+ /*
+ * A blocking lock was requested. Package up
+ * this smb into a queued request and push it
+ * onto the blocking lock queue.
+ */
+ if(push_blocking_lock_request(inbuf, length, -1, 0))
+ return -1;
+ }
return (ERROR(eclass,ecode));
+ }
nread = read_file(fsp,data,startpos,numtoread);
@@ -2449,7 +2459,7 @@ int reply_writeclose(connection_struct *conn,
reply to a lock
****************************************************************************/
int reply_lock(connection_struct *conn,
- char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
+ char *inbuf,char *outbuf, int length, int dum_buffsize)
{
int outsize = set_message(outbuf,0,0,True);
uint32 count,offset;
@@ -2466,8 +2476,18 @@ int reply_lock(connection_struct *conn,
DEBUG(3,("lock fd=%d fnum=%d ofs=%d cnt=%d\n",
fsp->fd_ptr->fd, fsp->fnum, offset, count));
- if (!do_lock(fsp, conn, count, offset, F_WRLCK, &eclass, &ecode))
- return (ERROR(eclass,ecode));
+ if (!do_lock(fsp, conn, count, offset, F_WRLCK, &eclass, &ecode)) {
+ if(ecode == ERRlock) {
+ /*
+ * A blocking lock was requested. Package up
+ * this smb into a queued request and push it
+ * onto the blocking lock queue.
+ */
+ if(push_blocking_lock_request(inbuf, length, -1, 0))
+ return -1;
+ }
+ return (ERROR(eclass,ecode));
+ }
return(outsize);
}
@@ -3564,6 +3584,8 @@ dev = %x, inode = %x\n",
for(i = 0; i < (int)num_ulocks; i++) {
count = IVAL(data,SMB_LKLEN_OFFSET(i));
offset = IVAL(data,SMB_LKOFF_OFFSET(i));
+ DEBUG(10,("reply_lockingX: unlock start=%d, len=%d for file %s\n",
+ (int)offset, (int)count, fsp->fsp_name ));
if(!do_unlock(fsp,conn,count,offset,&eclass, &ecode))
return ERROR(eclass,ecode);
}
@@ -3578,9 +3600,10 @@ dev = %x, inode = %x\n",
for(i = 0; i < (int)num_locks; i++) {
count = IVAL(data,SMB_LKLEN_OFFSET(i));
offset = IVAL(data,SMB_LKOFF_OFFSET(i));
+ DEBUG(10,("reply_lockingX: lock start=%d, len=%d for file %s\n",
+ (int)offset, (int)count, fsp->fsp_name ));
if(!do_lock(fsp,conn,count,offset, ((locktype & 1) ? F_RDLCK : F_WRLCK),
&eclass, &ecode)) {
-#if 0 /* JRATEST */
if((ecode == ERRlock) && (lock_timeout != 0)) {
/*
* A blocking lock was requested. Package up
@@ -3590,7 +3613,6 @@ dev = %x, inode = %x\n",
if(push_blocking_lock_request(inbuf, length, lock_timeout, i))
return -1;
}
-#endif /* JRATEST */
break;
}
}