summaryrefslogtreecommitdiff
path: root/source3/locking
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2007-05-14 13:01:28 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:22:02 -0500
commitb92064fcfd804b861e2f5125078812d83b9120a6 (patch)
tree8dc649a6c38732da79d025922bdebad24f8c978c /source3/locking
parentcb47bb6d8f987febfc7b70b2de2d8d32b2ce8229 (diff)
downloadsamba-b92064fcfd804b861e2f5125078812d83b9120a6.tar.gz
samba-b92064fcfd804b861e2f5125078812d83b9120a6.tar.bz2
samba-b92064fcfd804b861e2f5125078812d83b9120a6.zip
r22846: Chunk one to replace message_send_pid with messaging_send: Deep inside
locking/locking.c we have to send retry messages to timed lock holders. The majority of this patch passes a "struct messaging_context" down there. No functional change, survives make test. (This used to be commit bbb508414683eeddd2ee0d2d36fe620118180bbb)
Diffstat (limited to 'source3/locking')
-rw-r--r--source3/locking/brlock.c51
-rw-r--r--source3/locking/locking.c26
2 files changed, 45 insertions, 32 deletions
diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c
index c3a3ce1cb6..d48c746161 100644
--- a/source3/locking/brlock.c
+++ b/source3/locking/brlock.c
@@ -584,8 +584,9 @@ OR
We must cope with range splits and merges.
****************************************************************************/
-static NTSTATUS brl_lock_posix(struct byte_range_lock *br_lck,
- const struct lock_struct *plock)
+static NTSTATUS brl_lock_posix(struct messaging_context *msg_ctx,
+ struct byte_range_lock *br_lck,
+ const struct lock_struct *plock)
{
unsigned int i, count;
struct lock_struct *locks = br_lck->lock_data;
@@ -708,9 +709,8 @@ static NTSTATUS brl_lock_posix(struct byte_range_lock *br_lck,
DEBUG(10,("brl_lock_posix: sending unlock message to pid %s\n",
procid_str_static(&pend_lock->context.pid )));
- message_send_pid(pend_lock->context.pid,
- MSG_SMB_UNLOCK,
- NULL, 0, True);
+ messaging_send(msg_ctx, pend_lock->context.pid,
+ MSG_SMB_UNLOCK, &data_blob_null);
}
}
}
@@ -722,7 +722,8 @@ static NTSTATUS brl_lock_posix(struct byte_range_lock *br_lck,
Lock a range of bytes.
****************************************************************************/
-NTSTATUS brl_lock(struct byte_range_lock *br_lck,
+NTSTATUS brl_lock(struct messaging_context *msg_ctx,
+ struct byte_range_lock *br_lck,
uint32 smbpid,
struct server_id pid,
br_off start,
@@ -752,7 +753,7 @@ NTSTATUS brl_lock(struct byte_range_lock *br_lck,
if (lock_flav == WINDOWS_LOCK) {
ret = brl_lock_windows(br_lck, &lock, blocking_lock);
} else {
- ret = brl_lock_posix(br_lck, &lock);
+ ret = brl_lock_posix(msg_ctx, br_lck, &lock);
}
#if ZERO_ZERO
@@ -767,7 +768,9 @@ NTSTATUS brl_lock(struct byte_range_lock *br_lck,
Unlock a range of bytes - Windows semantics.
****************************************************************************/
-static BOOL brl_unlock_windows(struct byte_range_lock *br_lck, const struct lock_struct *plock)
+static BOOL brl_unlock_windows(struct messaging_context *msg_ctx,
+ struct byte_range_lock *br_lck,
+ const struct lock_struct *plock)
{
unsigned int i, j;
struct lock_struct *locks = br_lck->lock_data;
@@ -856,9 +859,8 @@ static BOOL brl_unlock_windows(struct byte_range_lock *br_lck, const struct lock
DEBUG(10,("brl_unlock: sending unlock message to pid %s\n",
procid_str_static(&pend_lock->context.pid )));
- message_send_pid(pend_lock->context.pid,
- MSG_SMB_UNLOCK,
- NULL, 0, True);
+ messaging_send(msg_ctx, pend_lock->context.pid,
+ MSG_SMB_UNLOCK, &data_blob_null);
}
}
@@ -869,7 +871,9 @@ static BOOL brl_unlock_windows(struct byte_range_lock *br_lck, const struct lock
Unlock a range of bytes - POSIX semantics.
****************************************************************************/
-static BOOL brl_unlock_posix(struct byte_range_lock *br_lck, const struct lock_struct *plock)
+static BOOL brl_unlock_posix(struct messaging_context *msg_ctx,
+ struct byte_range_lock *br_lck,
+ const struct lock_struct *plock)
{
unsigned int i, j, count;
struct lock_struct *tp;
@@ -1024,9 +1028,8 @@ static BOOL brl_unlock_posix(struct byte_range_lock *br_lck, const struct lock_s
DEBUG(10,("brl_unlock: sending unlock message to pid %s\n",
procid_str_static(&pend_lock->context.pid )));
- message_send_pid(pend_lock->context.pid,
- MSG_SMB_UNLOCK,
- NULL, 0, True);
+ messaging_send(msg_ctx, pend_lock->context.pid,
+ MSG_SMB_UNLOCK, &data_blob_null);
}
}
@@ -1037,7 +1040,8 @@ static BOOL brl_unlock_posix(struct byte_range_lock *br_lck, const struct lock_s
Unlock a range of bytes.
****************************************************************************/
-BOOL brl_unlock(struct byte_range_lock *br_lck,
+BOOL brl_unlock(struct messaging_context *msg_ctx,
+ struct byte_range_lock *br_lck,
uint32 smbpid,
struct server_id pid,
br_off start,
@@ -1056,9 +1060,9 @@ BOOL brl_unlock(struct byte_range_lock *br_lck,
lock.lock_flav = lock_flav;
if (lock_flav == WINDOWS_LOCK) {
- return brl_unlock_windows(br_lck, &lock);
+ return brl_unlock_windows(msg_ctx, br_lck, &lock);
} else {
- return brl_unlock_posix(br_lck, &lock);
+ return brl_unlock_posix(msg_ctx, br_lck, &lock);
}
}
@@ -1244,7 +1248,8 @@ BOOL brl_lock_cancel(struct byte_range_lock *br_lck,
fd and so we should not immediately close the fd.
****************************************************************************/
-void brl_close_fnum(struct byte_range_lock *br_lck)
+void brl_close_fnum(struct messaging_context *msg_ctx,
+ struct byte_range_lock *br_lck)
{
files_struct *fsp = br_lck->fsp;
uint16 tid = fsp->conn->cnum;
@@ -1299,7 +1304,8 @@ void brl_close_fnum(struct byte_range_lock *br_lck)
if (lock->context.tid == tid && procid_equal(&lock->context.pid, &pid) &&
(lock->fnum == fnum)) {
- brl_unlock(br_lck,
+ brl_unlock(msg_ctx,
+ br_lck,
lock->context.smbpid,
pid,
lock->start,
@@ -1348,9 +1354,8 @@ void brl_close_fnum(struct byte_range_lock *br_lck)
/* We could send specific lock info here... */
if (brl_pending_overlap(lock, pend_lock)) {
- message_send_pid(pend_lock->context.pid,
- MSG_SMB_UNLOCK,
- NULL, 0, True);
+ messaging_send(msg_ctx, pend_lock->context.pid,
+ MSG_SMB_UNLOCK, &data_blob_null);
}
}
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index c548d6eecb..28a7fab97d 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -180,7 +180,8 @@ NTSTATUS query_lock(files_struct *fsp,
Utility function called by locking requests.
****************************************************************************/
-struct byte_range_lock *do_lock(files_struct *fsp,
+struct byte_range_lock *do_lock(struct messaging_context *msg_ctx,
+ files_struct *fsp,
uint32 lock_pid,
SMB_BIG_UINT count,
SMB_BIG_UINT offset,
@@ -213,7 +214,8 @@ struct byte_range_lock *do_lock(files_struct *fsp,
return NULL;
}
- *perr = brl_lock(br_lck,
+ *perr = brl_lock(msg_ctx,
+ br_lck,
lock_pid,
procid_self(),
offset,
@@ -235,7 +237,8 @@ struct byte_range_lock *do_lock(files_struct *fsp,
Utility function called by unlocking requests.
****************************************************************************/
-NTSTATUS do_unlock(files_struct *fsp,
+NTSTATUS do_unlock(struct messaging_context *msg_ctx,
+ files_struct *fsp,
uint32 lock_pid,
SMB_BIG_UINT count,
SMB_BIG_UINT offset,
@@ -260,7 +263,8 @@ NTSTATUS do_unlock(files_struct *fsp,
return NT_STATUS_NO_MEMORY;
}
- ok = brl_unlock(br_lck,
+ ok = brl_unlock(msg_ctx,
+ br_lck,
lock_pid,
procid_self(),
offset,
@@ -334,7 +338,8 @@ NTSTATUS do_lock_cancel(files_struct *fsp,
Remove any locks on this fd. Called from file_close().
****************************************************************************/
-void locking_close_file(files_struct *fsp)
+void locking_close_file(struct messaging_context *msg_ctx,
+ files_struct *fsp)
{
struct byte_range_lock *br_lck;
@@ -354,7 +359,7 @@ void locking_close_file(files_struct *fsp)
if (br_lck) {
cancel_pending_lock_requests_by_fid(fsp, br_lck);
- brl_close_fnum(br_lck);
+ brl_close_fnum(msg_ctx, br_lck);
TALLOC_FREE(br_lck);
}
}
@@ -805,7 +810,8 @@ struct share_mode_lock *get_share_mode_lock(TALLOC_CTX *mem_ctx,
Based on an initial code idea from SATOH Fumiyasu <fumiya@samba.gr.jp>
********************************************************************/
-BOOL rename_share_filename(struct share_mode_lock *lck,
+BOOL rename_share_filename(struct messaging_context *msg_ctx,
+ struct share_mode_lock *lck,
const char *servicepath,
const char *newname)
{
@@ -814,6 +820,7 @@ BOOL rename_share_filename(struct share_mode_lock *lck,
size_t msg_len;
char *frm = NULL;
int i;
+ DATA_BLOB msg;
if (!lck) {
return False;
@@ -857,6 +864,8 @@ BOOL rename_share_filename(struct share_mode_lock *lck,
safe_strcpy(&frm[16], lck->servicepath, sp_len);
safe_strcpy(&frm[16 + sp_len + 1], lck->filename, fn_len);
+ msg = data_blob_const(frm, msg_len);
+
/* Send the messages. */
for (i=0; i<lck->num_share_modes; i++) {
struct share_mode_entry *se = &lck->share_modes[i];
@@ -874,8 +883,7 @@ BOOL rename_share_filename(struct share_mode_lock *lck,
(unsigned int)lck->dev, (double)lck->ino,
lck->servicepath, lck->filename ));
- message_send_pid(se->pid, MSG_SMB_FILE_RENAME,
- frm, msg_len, True);
+ messaging_send(msg_ctx, se->pid, MSG_SMB_FILE_RENAME, &msg);
}
return True;