diff options
-rw-r--r-- | source3/lib/messages.c | 2 | ||||
-rw-r--r-- | source3/locking/brlock.c | 51 | ||||
-rw-r--r-- | source3/locking/locking.c | 26 | ||||
-rw-r--r-- | source3/smbd/blocking.c | 11 | ||||
-rw-r--r-- | source3/smbd/close.c | 2 | ||||
-rw-r--r-- | source3/smbd/reply.c | 24 | ||||
-rw-r--r-- | source3/smbd/trans2.c | 6 |
7 files changed, 74 insertions, 48 deletions
diff --git a/source3/lib/messages.c b/source3/lib/messages.c index 10bf5dfcf7..7805f3c6d9 100644 --- a/source3/lib/messages.c +++ b/source3/lib/messages.c @@ -834,7 +834,7 @@ void messaging_deregister(struct messaging_context *ctx, uint32_t msg_type, */ NTSTATUS messaging_send(struct messaging_context *msg, struct server_id server, - uint32_t msg_type, DATA_BLOB *data) + uint32_t msg_type, const DATA_BLOB *data) { return message_send_pid_internal(server, msg_type, data->data, data->length, True, 0); 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; diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c index 7fe9f0c3c7..ab2b0949bd 100644 --- a/source3/smbd/blocking.c +++ b/source3/smbd/blocking.c @@ -195,7 +195,7 @@ BOOL push_blocking_lock_request( struct byte_range_lock *br_lck, blr->length = length; /* Add a pending lock record for this. */ - status = brl_lock(br_lck, + status = brl_lock(smbd_messaging_context(), br_lck, lock_pid, procid_self(), offset, @@ -355,7 +355,8 @@ static void reply_lockingX_error(blocking_lock_record *blr, NTSTATUS status) * request would never have been queued. JRA. */ - do_unlock(fsp, + do_unlock(smbd_messaging_context(), + fsp, lock_pid, count, offset, @@ -435,7 +436,8 @@ static BOOL process_lockingX(blocking_lock_record *blr) * request would never have been queued. JRA. */ errno = 0; - br_lck = do_lock(fsp, + br_lck = do_lock(smbd_messaging_context(), + fsp, lock_pid, count, offset, @@ -496,7 +498,8 @@ static BOOL process_trans2(blocking_lock_record *blr) char *outbuf; char params[2]; NTSTATUS status; - struct byte_range_lock *br_lck = do_lock(blr->fsp, + struct byte_range_lock *br_lck = do_lock(smbd_messaging_context(), + blr->fsp, blr->lock_pid, blr->count, blr->offset, diff --git a/source3/smbd/close.c b/source3/smbd/close.c index 2eb3a3e13c..ca4e501a14 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -352,7 +352,7 @@ static NTSTATUS close_normal_file(files_struct *fsp, enum file_close_type close_ release_file_oplock(fsp); } - locking_close_file(fsp); + locking_close_file(smbd_messaging_context(), fsp); status = fd_close(conn, fsp); diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 8748c1cd23..5353e392b1 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -2415,7 +2415,8 @@ int reply_lockread(connection_struct *conn, char *inbuf,char *outbuf, int length * Note that the requested lock size is unaffected by max_recv. */ - br_lck = do_lock(fsp, + br_lck = do_lock(smbd_messaging_context(), + fsp, (uint32)SVAL(inbuf,smb_pid), (SMB_BIG_UINT)numtoread, (SMB_BIG_UINT)startpos, @@ -2917,7 +2918,8 @@ int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, } if (numtowrite) { - status = do_unlock(fsp, + status = do_unlock(smbd_messaging_context(), + fsp, (uint32)SVAL(inbuf,smb_pid), (SMB_BIG_UINT)numtowrite, (SMB_BIG_UINT)startpos, @@ -3420,7 +3422,8 @@ int reply_lock(connection_struct *conn, DEBUG(3,("lock fd=%d fnum=%d offset=%.0f count=%.0f\n", fsp->fh->fd, fsp->fnum, (double)offset, (double)count)); - br_lck = do_lock(fsp, + br_lck = do_lock(smbd_messaging_context(), + fsp, (uint32)SVAL(inbuf,smb_pid), count, offset, @@ -3458,7 +3461,8 @@ int reply_unlock(connection_struct *conn, char *inbuf,char *outbuf, int size, count = (SMB_BIG_UINT)IVAL(inbuf,smb_vwv1); offset = (SMB_BIG_UINT)IVAL(inbuf,smb_vwv3); - status = do_unlock(fsp, + status = do_unlock(smbd_messaging_context(), + fsp, (uint32)SVAL(inbuf,smb_pid), count, offset, @@ -4144,7 +4148,8 @@ static void rename_open_files(connection_struct *conn, struct share_mode_lock *l } /* Send messages to all smbd's (not ourself) that the name has changed. */ - rename_share_filename(lck, conn->connectpath, newname); + rename_share_filename(smbd_messaging_context(), lck, conn->connectpath, + newname); } /**************************************************************************** @@ -5453,7 +5458,8 @@ int reply_lockingX(connection_struct *conn, char *inbuf, char *outbuf, "pid %u, file %s\n", (double)offset, (double)count, (unsigned int)lock_pid, fsp->fsp_name )); - status = do_unlock(fsp, + status = do_unlock(smbd_messaging_context(), + fsp, lock_pid, count, offset, @@ -5526,7 +5532,8 @@ int reply_lockingX(connection_struct *conn, char *inbuf, char *outbuf, BOOL defer_lock = False; struct byte_range_lock *br_lck; - br_lck = do_lock(fsp, + br_lck = do_lock(smbd_messaging_context(), + fsp, lock_pid, count, offset, @@ -5612,7 +5619,8 @@ int reply_lockingX(connection_struct *conn, char *inbuf, char *outbuf, return ERROR_DOS(ERRDOS,ERRnoaccess); } - do_unlock(fsp, + do_unlock(smbd_messaging_context(), + fsp, lock_pid, count, offset, diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 91218fe9f4..1c55684330 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -4805,13 +4805,15 @@ static NTSTATUS smb_set_posix_lock(connection_struct *conn, (double)offset )); if (lock_type == UNLOCK_LOCK) { - status = do_unlock(fsp, + status = do_unlock(smbd_messaging_context(), + fsp, lock_pid, count, offset, POSIX_LOCK); } else { - struct byte_range_lock *br_lck = do_lock(fsp, + struct byte_range_lock *br_lck = do_lock(smbd_messaging_context(), + fsp, lock_pid, count, offset, |