summaryrefslogtreecommitdiff
path: root/source3/smbd/oplock.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2005-07-08 04:51:27 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:58:18 -0500
commitaf8a691db11a5072865f8b03fd1cbd3aab5cb6d7 (patch)
tree0779dd2d2c6d9ea3eae0f094803f6ba3b3c56f24 /source3/smbd/oplock.c
parent22268d79265d79b8d86d1152a7bfe2ebc8988905 (diff)
downloadsamba-af8a691db11a5072865f8b03fd1cbd3aab5cb6d7.tar.gz
samba-af8a691db11a5072865f8b03fd1cbd3aab5cb6d7.tar.bz2
samba-af8a691db11a5072865f8b03fd1cbd3aab5cb6d7.zip
r8219: Merge the new open code from HEAD to 3.0. Haven't yet run the torture
tests on this as it's very late NY time (just wanted to get this work into the tree). I'll test this over the weekend.... Jerry - in looking at the difference between the two trees there seem to be some printing/ntprinting.c and registry changes we might want to examine to try keep in sync. Jeremy. (This used to be commit c7fe18761e2c753afbffd3a78abff46472a9b8eb)
Diffstat (limited to 'source3/smbd/oplock.c')
-rw-r--r--source3/smbd/oplock.c67
1 files changed, 38 insertions, 29 deletions
diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index 8208fbebe3..3cfce5c7a1 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -343,6 +343,7 @@ BOOL process_local_message(char *buffer, int buf_size)
SMB_INO_T inode;
unsigned long file_id;
uint16 break_cmd_type;
+ struct sockaddr_in toaddr;
msg_len = IVAL(buffer,OPBRK_CMD_LEN_OFFSET);
from_port = SVAL(buffer,OPBRK_CMD_PORT_OFFSET);
@@ -366,6 +367,7 @@ BOOL process_local_message(char *buffer, int buf_size)
}
if (!koplocks->parse_message(msg_start, msg_len, &inode, &dev, &file_id)) {
DEBUG(0,("kernel oplock break parse failure!\n"));
+ return False;
}
break;
@@ -449,49 +451,54 @@ pid %d, port %d, dev = %x, inode = %.0f, file_id = %lu\n",
* Now actually process the break request.
*/
- if((exclusive_oplocks_open + level_II_oplocks_open) != 0) {
- if (oplock_break(dev, inode, file_id, False) == False) {
- DEBUG(0,("process_local_message: oplock break failed.\n"));
- return False;
- }
- } else {
+ if ((exclusive_oplocks_open == 0) &&
+ (level_II_oplocks_open == 0)) {
/*
* If we have no record of any currently open oplocks,
* it's not an error, as a close command may have
* just been issued on the file that was oplocked.
* Just log a message and return success in this case.
*/
- DEBUG(3,("process_local_message: oplock break requested with no outstanding \
-oplocks. Returning success.\n"));
+ DEBUG(3,("process_local_message: oplock break requested with "
+ "no outstanding oplocks. Returning success.\n"));
+ return True;
+ }
+
+ if (!oplock_break(dev, inode, file_id, False)) {
+ DEBUG(0,("process_local_message: oplock break failed.\n"));
+ return False;
}
/*
- * Do the appropriate reply - none in the kernel or async level II case.
+ * Do the appropriate reply - none in the kernel or async level II
+ * case.
*/
- if(break_cmd_type == OPLOCK_BREAK_CMD || break_cmd_type == LEVEL_II_OPLOCK_BREAK_CMD) {
- struct sockaddr_in toaddr;
+ if (!((break_cmd_type == OPLOCK_BREAK_CMD) ||
+ (break_cmd_type == LEVEL_II_OPLOCK_BREAK_CMD))) {
+ return True;
+ }
- /* Send the message back after OR'ing in the 'REPLY' bit. */
- SSVAL(msg_start,OPBRK_MESSAGE_CMD_OFFSET,break_cmd_type | CMD_REPLY);
+ /* Send the message back after OR'ing in the 'REPLY' bit. */
+ SSVAL(msg_start,OPBRK_MESSAGE_CMD_OFFSET,break_cmd_type | CMD_REPLY);
- memset((char *)&toaddr,'\0',sizeof(toaddr));
- toaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
- toaddr.sin_port = htons(from_port);
- toaddr.sin_family = AF_INET;
+ memset((char *)&toaddr,'\0',sizeof(toaddr));
+ toaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
+ toaddr.sin_port = htons(from_port);
+ toaddr.sin_family = AF_INET;
- if(sys_sendto( oplock_sock, msg_start, OPLOCK_BREAK_MSG_LEN, 0,
- (struct sockaddr *)&toaddr, sizeof(toaddr)) < 0) {
- DEBUG(0,("process_local_message: sendto process %d failed. Errno was %s\n",
- (int)remotepid, strerror(errno)));
- return False;
- }
-
- DEBUG(5,("process_local_message: oplock break reply sent to \
-pid %d, port %d, for file dev = %x, inode = %.0f, file_id = %lu\n",
- (int)remotepid, from_port, (unsigned int)dev, (double)inode, file_id));
+ if(sys_sendto( oplock_sock, msg_start, OPLOCK_BREAK_MSG_LEN, 0,
+ (struct sockaddr *)&toaddr, sizeof(toaddr)) < 0) {
+ DEBUG(0,("process_local_message: sendto process %d failed. "
+ "Errno was %s\n", (int)remotepid, strerror(errno)));
+ return False;
}
+ DEBUG(5,("process_local_message: oplock break reply sent to pid %d, "
+ "port %d, for file dev = %x, inode = %.0f, file_id = %lu\n",
+ (int)remotepid, from_port, (unsigned int)dev,
+ (double)inode, file_id));
+
return True;
}
@@ -1150,7 +1157,7 @@ BOOL attempt_close_oplocked_file(files_struct *fsp)
{
DEBUG(5,("attempt_close_oplocked_file: checking file %s.\n", fsp->fsp_name));
- if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) && !fsp->sent_oplock_break && (fsp->fd != -1)) {
+ if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type) && !fsp->sent_oplock_break && (fsp->fh->fd != -1)) {
/* Try and break the oplock. */
if (oplock_break(fsp->dev, fsp->inode, fsp->file_id, True)) {
if(file_find_fsp(fsp) == NULL) /* Did the oplock break close the file ? */
@@ -1223,6 +1230,7 @@ void release_level_2_oplocks_on_change(files_struct *fsp)
pid_t pid = sys_getpid();
int num_share_modes = 0;
int i;
+ BOOL dummy;
/*
* If this file is level II oplocked then we need
@@ -1239,7 +1247,8 @@ void release_level_2_oplocks_on_change(files_struct *fsp)
DEBUG(0,("release_level_2_oplocks_on_change: failed to lock share mode entry for file %s.\n", fsp->fsp_name ));
}
- num_share_modes = get_share_modes(fsp->conn, fsp->dev, fsp->inode, &share_list);
+ num_share_modes = get_share_modes(fsp->dev, fsp->inode, &share_list,
+ &dummy);
DEBUG(10,("release_level_2_oplocks_on_change: num_share_modes = %d\n",
num_share_modes ));