mirror of
https://github.com/samba-team/samba.git
synced 2025-08-04 08:22:08 +03:00
r22868: Replace some message_send_pid calls with messaging_send_pid calls. More
tomorrow.
(This used to be commit 74fa57ca5d
)
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
1f073a0319
commit
fad7dd8a60
@ -832,7 +832,7 @@ void messaging_deregister(struct messaging_context *ctx, uint32_t msg_type,
|
||||
/*
|
||||
Send a message to a particular server
|
||||
*/
|
||||
NTSTATUS messaging_send(struct messaging_context *msg,
|
||||
NTSTATUS messaging_send(struct messaging_context *msg_ctx,
|
||||
struct server_id server,
|
||||
uint32_t msg_type, const DATA_BLOB *data)
|
||||
{
|
||||
@ -840,4 +840,22 @@ NTSTATUS messaging_send(struct messaging_context *msg,
|
||||
data->length, True, 0);
|
||||
}
|
||||
|
||||
NTSTATUS messaging_send_buf(struct messaging_context *msg_ctx,
|
||||
struct server_id server, uint32_t msg_type,
|
||||
const uint8 *buf, size_t len)
|
||||
{
|
||||
DATA_BLOB blob = data_blob_const(buf, len);
|
||||
return messaging_send(msg_ctx, server, msg_type, &blob);
|
||||
}
|
||||
|
||||
NTSTATUS messaging_send_buf_with_timeout(struct messaging_context *msg_ctx,
|
||||
struct server_id server,
|
||||
uint32_t msg_type,
|
||||
const uint8 *buf, size_t len,
|
||||
int timeout)
|
||||
{
|
||||
return message_send_pid_internal(server, msg_type, buf, len,
|
||||
True, timeout);
|
||||
}
|
||||
|
||||
/** @} **/
|
||||
|
@ -116,7 +116,9 @@ again:
|
||||
Send the batched messages - on a per-printer basis.
|
||||
*******************************************************************/
|
||||
|
||||
static void print_notify_send_messages_to_printer(const char *printer, unsigned int timeout)
|
||||
static void print_notify_send_messages_to_printer(struct messaging_context *msg_ctx,
|
||||
const char *printer,
|
||||
unsigned int timeout)
|
||||
{
|
||||
char *buf;
|
||||
struct notify_queue *pq, *pq_next;
|
||||
@ -182,9 +184,11 @@ static void print_notify_send_messages_to_printer(const char *printer, unsigned
|
||||
printer, q_len ));
|
||||
continue;
|
||||
}
|
||||
message_send_pid_with_timeout(pid_to_procid(pid_list[i]),
|
||||
messaging_send_buf_with_timeout(msg_ctx,
|
||||
pid_to_procid(pid_list[i]),
|
||||
MSG_PRINTER_NOTIFY2,
|
||||
buf, offset, True, timeout);
|
||||
(uint8 *)buf, offset,
|
||||
timeout);
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,7 +196,8 @@ static void print_notify_send_messages_to_printer(const char *printer, unsigned
|
||||
Actually send the batched messages.
|
||||
*******************************************************************/
|
||||
|
||||
void print_notify_send_messages(unsigned int timeout)
|
||||
void print_notify_send_messages(struct messaging_context *msg_ctx,
|
||||
unsigned int timeout)
|
||||
{
|
||||
if (!print_notify_messages_pending())
|
||||
return;
|
||||
@ -201,7 +206,8 @@ void print_notify_send_messages(unsigned int timeout)
|
||||
return;
|
||||
|
||||
while (print_notify_messages_pending())
|
||||
print_notify_send_messages_to_printer(notify_queue_head->msg->printer, timeout);
|
||||
print_notify_send_messages_to_printer(
|
||||
msg_ctx, notify_queue_head->msg->printer, timeout);
|
||||
|
||||
talloc_free_children(send_ctx);
|
||||
num_messages = 0;
|
||||
|
@ -1428,7 +1428,8 @@ void start_background_queue(void)
|
||||
|
||||
/* process any pending print change notify messages */
|
||||
|
||||
print_notify_send_messages(0);
|
||||
print_notify_send_messages(smbd_messaging_context(),
|
||||
0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -893,9 +893,9 @@ BOOL blocking_lock_cancel(files_struct *fsp,
|
||||
memcpy(msg, &blr, sizeof(blr));
|
||||
memcpy(&msg[sizeof(blr)], &err, sizeof(NTSTATUS));
|
||||
|
||||
message_send_pid(pid_to_procid(sys_getpid()),
|
||||
messaging_send_buf(smbd_messaging_context(), procid_self(),
|
||||
MSG_SMB_BLOCKING_LOCK_CANCEL,
|
||||
&msg, sizeof(msg), True);
|
||||
(uint8 *)&msg, sizeof(msg));
|
||||
|
||||
return True;
|
||||
}
|
||||
|
@ -135,8 +135,10 @@ static void notify_deferred_opens(struct share_mode_lock *lck)
|
||||
|
||||
share_mode_entry_to_message(msg, e);
|
||||
|
||||
message_send_pid(e->pid, MSG_SMB_OPEN_RETRY,
|
||||
msg, MSG_SMB_SHARE_MODE_ENTRY_SIZE, True);
|
||||
messaging_send_buf(smbd_messaging_context(),
|
||||
e->pid, MSG_SMB_OPEN_RETRY,
|
||||
(uint8 *)msg,
|
||||
MSG_SMB_SHARE_MODE_ENTRY_SIZE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -737,8 +737,10 @@ static BOOL delay_for_oplocks(struct share_mode_lock *lck,
|
||||
SSVAL(msg,6,exclusive->op_type | FORCE_OPLOCK_BREAK_TO_NONE);
|
||||
}
|
||||
|
||||
status = message_send_pid(exclusive->pid, MSG_SMB_BREAK_REQUEST,
|
||||
msg, MSG_SMB_SHARE_MODE_ENTRY_SIZE, True);
|
||||
status = messaging_send_buf(smbd_messaging_context(), exclusive->pid,
|
||||
MSG_SMB_BREAK_REQUEST,
|
||||
(uint8 *)msg,
|
||||
MSG_SMB_SHARE_MODE_ENTRY_SIZE);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
DEBUG(3, ("Could not send oplock break message: %s\n",
|
||||
nt_errstr(status)));
|
||||
|
@ -62,7 +62,7 @@ BOOL oplock_message_waiting(fd_set *fds)
|
||||
we're calling this in a shutting down state.
|
||||
****************************************************************************/
|
||||
|
||||
void process_kernel_oplocks(fd_set *pfds)
|
||||
void process_kernel_oplocks(struct messaging_context *msg_ctx, fd_set *pfds)
|
||||
{
|
||||
/*
|
||||
* We need to check for kernel oplocks before going into the select
|
||||
@ -94,9 +94,9 @@ void process_kernel_oplocks(fd_set *pfds)
|
||||
/* Don't need to be root here as we're only ever
|
||||
sending to ourselves. */
|
||||
|
||||
message_send_pid(pid_to_procid(sys_getpid()),
|
||||
messaging_send_buf(msg_ctx, procid_self(),
|
||||
MSG_SMB_KERNEL_BREAK,
|
||||
&msg, MSG_SMB_KERNEL_BREAK_SIZE, True);
|
||||
(uint8 *)&msg, MSG_SMB_KERNEL_BREAK_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -391,27 +391,29 @@ static void add_oplock_timeout_handler(files_struct *fsp)
|
||||
the client for LEVEL2.
|
||||
*******************************************************************/
|
||||
|
||||
static void process_oplock_async_level2_break_message(int msg_type, struct server_id src,
|
||||
void *buf, size_t len,
|
||||
void *private_data)
|
||||
static void process_oplock_async_level2_break_message(struct messaging_context *msg_ctx,
|
||||
void *private_data,
|
||||
uint32_t msg_type,
|
||||
struct server_id src,
|
||||
DATA_BLOB *data)
|
||||
{
|
||||
struct share_mode_entry msg;
|
||||
files_struct *fsp;
|
||||
char *break_msg;
|
||||
BOOL sign_state;
|
||||
|
||||
if (buf == NULL) {
|
||||
if (data->data == NULL) {
|
||||
DEBUG(0, ("Got NULL buffer\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (len != MSG_SMB_SHARE_MODE_ENTRY_SIZE) {
|
||||
DEBUG(0, ("Got invalid msg len %d\n", (int)len));
|
||||
if (data->length != MSG_SMB_SHARE_MODE_ENTRY_SIZE) {
|
||||
DEBUG(0, ("Got invalid msg len %d\n", (int)data->length));
|
||||
return;
|
||||
}
|
||||
|
||||
/* De-linearize incoming message. */
|
||||
message_to_share_mode_entry(&msg, (char *)buf);
|
||||
message_to_share_mode_entry(&msg, (char *)data->data);
|
||||
|
||||
DEBUG(10, ("Got oplock async level 2 break message from pid %d: 0x%x/%.0f/%lu\n",
|
||||
(int)procid_to_pid(&src), (unsigned int)msg.dev,
|
||||
@ -478,9 +480,11 @@ static void process_oplock_async_level2_break_message(int msg_type, struct serve
|
||||
This handles the generic oplock break message from another smbd.
|
||||
*******************************************************************/
|
||||
|
||||
static void process_oplock_break_message(int msg_type, struct server_id src,
|
||||
void *buf, size_t len,
|
||||
void *private_data)
|
||||
static void process_oplock_break_message(struct messaging_context *msg_ctx,
|
||||
void *private_data,
|
||||
uint32_t msg_type,
|
||||
struct server_id src,
|
||||
DATA_BLOB *data)
|
||||
{
|
||||
struct share_mode_entry msg;
|
||||
files_struct *fsp;
|
||||
@ -488,18 +492,18 @@ static void process_oplock_break_message(int msg_type, struct server_id src,
|
||||
BOOL break_to_level2 = False;
|
||||
BOOL sign_state;
|
||||
|
||||
if (buf == NULL) {
|
||||
if (data->data == NULL) {
|
||||
DEBUG(0, ("Got NULL buffer\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (len != MSG_SMB_SHARE_MODE_ENTRY_SIZE) {
|
||||
DEBUG(0, ("Got invalid msg len %d\n", (int)len));
|
||||
if (data->length != MSG_SMB_SHARE_MODE_ENTRY_SIZE) {
|
||||
DEBUG(0, ("Got invalid msg len %d\n", (int)data->length));
|
||||
return;
|
||||
}
|
||||
|
||||
/* De-linearize incoming message. */
|
||||
message_to_share_mode_entry(&msg, (char *)buf);
|
||||
message_to_share_mode_entry(&msg, (char *)data->data);
|
||||
|
||||
DEBUG(10, ("Got oplock break message from pid %d: 0x%x/%.0f/%lu\n",
|
||||
(int)procid_to_pid(&src), (unsigned int)msg.dev,
|
||||
@ -515,8 +519,9 @@ static void process_oplock_break_message(int msg_type, struct server_id src,
|
||||
DEBUG(3, ("Did not find fsp\n"));
|
||||
|
||||
/* We just send the same message back. */
|
||||
message_send_pid(src, MSG_SMB_BREAK_RESPONSE,
|
||||
buf, MSG_SMB_SHARE_MODE_ENTRY_SIZE, True);
|
||||
messaging_send_buf(msg_ctx, src, MSG_SMB_BREAK_RESPONSE,
|
||||
(uint8 *)data->data,
|
||||
MSG_SMB_SHARE_MODE_ENTRY_SIZE);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -536,8 +541,9 @@ static void process_oplock_break_message(int msg_type, struct server_id src,
|
||||
(unsigned int)fsp->dev, (double)fsp->inode,
|
||||
fsp->fsp_name));
|
||||
/* We just send the same message back. */
|
||||
message_send_pid(src, MSG_SMB_BREAK_RESPONSE,
|
||||
buf, MSG_SMB_SHARE_MODE_ENTRY_SIZE, True);
|
||||
messaging_send_buf(msg_ctx, src, MSG_SMB_BREAK_RESPONSE,
|
||||
(uint8 *)data->data,
|
||||
MSG_SMB_SHARE_MODE_ENTRY_SIZE);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -587,9 +593,11 @@ static void process_oplock_break_message(int msg_type, struct server_id src,
|
||||
This handles the kernel oplock break message.
|
||||
*******************************************************************/
|
||||
|
||||
static void process_kernel_oplock_break(int msg_type, struct server_id src,
|
||||
void *buf, size_t len,
|
||||
void *private_data)
|
||||
static void process_kernel_oplock_break(struct messaging_context *msg_ctx,
|
||||
void *private_data,
|
||||
uint32_t msg_type,
|
||||
struct server_id src,
|
||||
DATA_BLOB *data)
|
||||
{
|
||||
SMB_DEV_T dev;
|
||||
SMB_INO_T inode;
|
||||
@ -598,20 +606,20 @@ static void process_kernel_oplock_break(int msg_type, struct server_id src,
|
||||
char *break_msg;
|
||||
BOOL sign_state;
|
||||
|
||||
if (buf == NULL) {
|
||||
if (data->data == NULL) {
|
||||
DEBUG(0, ("Got NULL buffer\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (len != MSG_SMB_KERNEL_BREAK_SIZE) {
|
||||
DEBUG(0, ("Got invalid msg len %d\n", (int)len));
|
||||
if (data->length != MSG_SMB_KERNEL_BREAK_SIZE) {
|
||||
DEBUG(0, ("Got invalid msg len %d\n", (int)data->length));
|
||||
return;
|
||||
}
|
||||
|
||||
/* Pull the data from the message. */
|
||||
dev = DEV_T_VAL(buf, 0);
|
||||
inode = INO_T_VAL(buf, 8);
|
||||
file_id = (unsigned long)IVAL(buf, 16);
|
||||
dev = DEV_T_VAL(data->data, 0);
|
||||
inode = INO_T_VAL(data->data, 8);
|
||||
file_id = (unsigned long)IVAL(data->data, 16);
|
||||
|
||||
DEBUG(10, ("Got kernel oplock break message from pid %d: 0x%x/%.0f/%u\n",
|
||||
(int)procid_to_pid(&src), (unsigned int)dev, (double)inode,
|
||||
@ -665,8 +673,10 @@ void reply_to_oplock_break_requests(files_struct *fsp)
|
||||
|
||||
share_mode_entry_to_message(msg, e);
|
||||
|
||||
message_send_pid(e->pid, MSG_SMB_BREAK_RESPONSE,
|
||||
msg, MSG_SMB_SHARE_MODE_ENTRY_SIZE, True);
|
||||
messaging_send_buf(smbd_messaging_context(), e->pid,
|
||||
MSG_SMB_BREAK_RESPONSE,
|
||||
(uint8 *)msg,
|
||||
MSG_SMB_SHARE_MODE_ENTRY_SIZE);
|
||||
}
|
||||
|
||||
SAFE_FREE(fsp->pending_break_messages);
|
||||
@ -679,24 +689,27 @@ void reply_to_oplock_break_requests(files_struct *fsp)
|
||||
return;
|
||||
}
|
||||
|
||||
static void process_oplock_break_response(int msg_type, struct server_id src,
|
||||
void *buf, size_t len,
|
||||
void *private_data)
|
||||
static void process_oplock_break_response(struct messaging_context *msg_ctx,
|
||||
void *private_data,
|
||||
uint32_t msg_type,
|
||||
struct server_id src,
|
||||
DATA_BLOB *data)
|
||||
{
|
||||
struct share_mode_entry msg;
|
||||
|
||||
if (buf == NULL) {
|
||||
if (data->data == NULL) {
|
||||
DEBUG(0, ("Got NULL buffer\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (len != MSG_SMB_SHARE_MODE_ENTRY_SIZE) {
|
||||
DEBUG(0, ("Got invalid msg len %u\n", (unsigned int)len));
|
||||
if (data->length != MSG_SMB_SHARE_MODE_ENTRY_SIZE) {
|
||||
DEBUG(0, ("Got invalid msg len %u\n",
|
||||
(unsigned int)data->length));
|
||||
return;
|
||||
}
|
||||
|
||||
/* De-linearize incoming message. */
|
||||
message_to_share_mode_entry(&msg, (char *)buf);
|
||||
message_to_share_mode_entry(&msg, (char *)data->data);
|
||||
|
||||
DEBUG(10, ("Got oplock break response from pid %d: 0x%x/%.0f/%lu mid %u\n",
|
||||
(int)procid_to_pid(&src), (unsigned int)msg.dev,
|
||||
@ -707,24 +720,26 @@ static void process_oplock_break_response(int msg_type, struct server_id src,
|
||||
schedule_deferred_open_smb_message(msg.op_mid);
|
||||
}
|
||||
|
||||
static void process_open_retry_message(int msg_type, struct server_id src,
|
||||
void *buf, size_t len,
|
||||
void *private_data)
|
||||
static void process_open_retry_message(struct messaging_context *msg_ctx,
|
||||
void *private_data,
|
||||
uint32_t msg_type,
|
||||
struct server_id src,
|
||||
DATA_BLOB *data)
|
||||
{
|
||||
struct share_mode_entry msg;
|
||||
|
||||
if (buf == NULL) {
|
||||
if (data->data == NULL) {
|
||||
DEBUG(0, ("Got NULL buffer\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (len != MSG_SMB_SHARE_MODE_ENTRY_SIZE) {
|
||||
DEBUG(0, ("Got invalid msg len %d\n", (int)len));
|
||||
if (data->length != MSG_SMB_SHARE_MODE_ENTRY_SIZE) {
|
||||
DEBUG(0, ("Got invalid msg len %d\n", (int)data->length));
|
||||
return;
|
||||
}
|
||||
|
||||
/* De-linearize incoming message. */
|
||||
message_to_share_mode_entry(&msg, (char *)buf);
|
||||
message_to_share_mode_entry(&msg, (char *)data->data);
|
||||
|
||||
DEBUG(10, ("Got open retry msg from pid %d: 0x%x/%.0f/%lu mid %u\n",
|
||||
(int)procid_to_pid(&src), (unsigned int)msg.dev,
|
||||
@ -804,8 +819,10 @@ void release_level_2_oplocks_on_change(files_struct *fsp)
|
||||
|
||||
share_mode_entry_to_message(msg, share_entry);
|
||||
|
||||
message_send_pid(share_entry->pid, MSG_SMB_ASYNC_LEVEL2_BREAK,
|
||||
msg, MSG_SMB_SHARE_MODE_ENTRY_SIZE, True);
|
||||
messaging_send_buf(smbd_messaging_context(), share_entry->pid,
|
||||
MSG_SMB_ASYNC_LEVEL2_BREAK,
|
||||
(uint8 *)msg,
|
||||
MSG_SMB_SHARE_MODE_ENTRY_SIZE);
|
||||
}
|
||||
|
||||
/* We let the message receivers handle removing the oplock state
|
||||
@ -860,25 +877,20 @@ void message_to_share_mode_entry(struct share_mode_entry *e, char *msg)
|
||||
Setup oplocks for this process.
|
||||
****************************************************************************/
|
||||
|
||||
BOOL init_oplocks(void)
|
||||
BOOL init_oplocks(struct messaging_context *msg_ctx)
|
||||
{
|
||||
DEBUG(3,("init_oplocks: initializing messages.\n"));
|
||||
|
||||
message_register(MSG_SMB_BREAK_REQUEST,
|
||||
process_oplock_break_message,
|
||||
NULL);
|
||||
message_register(MSG_SMB_ASYNC_LEVEL2_BREAK,
|
||||
process_oplock_async_level2_break_message,
|
||||
NULL);
|
||||
message_register(MSG_SMB_BREAK_RESPONSE,
|
||||
process_oplock_break_response,
|
||||
NULL);
|
||||
message_register(MSG_SMB_KERNEL_BREAK,
|
||||
process_kernel_oplock_break,
|
||||
NULL);
|
||||
message_register(MSG_SMB_OPEN_RETRY,
|
||||
process_open_retry_message,
|
||||
NULL);
|
||||
messaging_register(msg_ctx, NULL, MSG_SMB_BREAK_REQUEST,
|
||||
process_oplock_break_message);
|
||||
messaging_register(msg_ctx, NULL, MSG_SMB_ASYNC_LEVEL2_BREAK,
|
||||
process_oplock_async_level2_break_message);
|
||||
messaging_register(msg_ctx, NULL, MSG_SMB_BREAK_RESPONSE,
|
||||
process_oplock_break_response);
|
||||
messaging_register(msg_ctx, NULL, MSG_SMB_KERNEL_BREAK,
|
||||
process_kernel_oplock_break);
|
||||
messaging_register(msg_ctx, NULL, MSG_SMB_OPEN_RETRY,
|
||||
process_open_retry_message);
|
||||
|
||||
if (lp_kernel_oplocks()) {
|
||||
#if HAVE_KERNEL_OPLOCKS_IRIX
|
||||
|
@ -301,7 +301,7 @@ static void async_processing(fd_set *pfds)
|
||||
|
||||
process_aio_queue();
|
||||
|
||||
process_kernel_oplocks(pfds);
|
||||
process_kernel_oplocks(smbd_messaging_context(), pfds);
|
||||
|
||||
/* Do the aio check again after receive_local_message as it does a
|
||||
select and may have eaten our signal. */
|
||||
@ -574,7 +574,7 @@ void respond_to_all_remaining_local_messages(void)
|
||||
return;
|
||||
}
|
||||
|
||||
process_kernel_oplocks(NULL);
|
||||
process_kernel_oplocks(smbd_messaging_context(), NULL);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1415,7 +1415,7 @@ machine %s in domain %s.\n", global_myname(), lp_workgroup()));
|
||||
|
||||
/* Send any queued printer notify message to interested smbd's. */
|
||||
|
||||
print_notify_send_messages(0);
|
||||
print_notify_send_messages(smbd_messaging_context(), 0);
|
||||
|
||||
/*
|
||||
* Modify the select timeout depending upon
|
||||
|
@ -646,7 +646,8 @@ static void exit_server_common(enum server_exit_reason how,
|
||||
|
||||
invalidate_all_vuids();
|
||||
|
||||
print_notify_send_messages(3); /* 3 second timeout. */
|
||||
/* 3 second timeout. */
|
||||
print_notify_send_messages(smbd_messaging_context(), 3);
|
||||
|
||||
/* delete our entry in the connections database. */
|
||||
yield_connection(NULL,"");
|
||||
@ -755,7 +756,8 @@ static BOOL deadtime_fn(const struct timeval *now, void *private_data)
|
||||
if ((conn_num_open() == 0)
|
||||
|| (conn_idle_all(now->tv_sec))) {
|
||||
DEBUG( 2, ( "Closing idle connection\n" ) );
|
||||
message_send_pid(procid_self(), MSG_SHUTDOWN, NULL, 0, False);
|
||||
messaging_send(smbd_messaging_context(), procid_self(),
|
||||
MSG_SHUTDOWN, &data_blob_null);
|
||||
return False;
|
||||
}
|
||||
|
||||
@ -1062,7 +1064,7 @@ extern void build_options(BOOL screen);
|
||||
}
|
||||
|
||||
/* Setup oplocks */
|
||||
if (!init_oplocks())
|
||||
if (!init_oplocks(smbd_messaging_context()))
|
||||
exit(1);
|
||||
|
||||
/* Setup aio signal handler. */
|
||||
|
@ -1192,8 +1192,8 @@ static int shutdown_other_smbds(TDB_CONTEXT *tdb, TDB_DATA kbuf, TDB_DATA dbuf,
|
||||
return 0;
|
||||
}
|
||||
|
||||
message_send_pid(sessionid->pid, MSG_SHUTDOWN,
|
||||
NULL, 0, True);
|
||||
messaging_send(smbd_messaging_context(), sessionid->pid, MSG_SHUTDOWN,
|
||||
&data_blob_null);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,8 @@ static void print_string_cb(int msg_type, struct server_id pid,
|
||||
|
||||
/* Send no message. Useful for testing. */
|
||||
|
||||
static BOOL do_noop(const struct server_id pid,
|
||||
static BOOL do_noop(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
if (argc != 1) {
|
||||
@ -122,7 +123,8 @@ static BOOL do_noop(const struct server_id pid,
|
||||
|
||||
/* Send a debug string */
|
||||
|
||||
static BOOL do_debug(const struct server_id pid,
|
||||
static BOOL do_debug(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
if (argc != 2) {
|
||||
@ -245,7 +247,8 @@ static int stack_trace_connection(TDB_CONTEXT * tdb,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static BOOL do_daemon_stack_trace(const struct server_id pid,
|
||||
static BOOL do_daemon_stack_trace(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
fprintf(stderr,
|
||||
@ -278,7 +281,8 @@ static BOOL do_daemon_stack_trace(const struct server_id pid,
|
||||
|
||||
#else /* defined(HAVE_LIBUNWIND_PTRACE) && defined(HAVE_LINUX_PTRACE) */
|
||||
|
||||
static BOOL do_daemon_stack_trace(const struct server_id pid,
|
||||
static BOOL do_daemon_stack_trace(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
fprintf(stderr,
|
||||
@ -290,7 +294,8 @@ static BOOL do_daemon_stack_trace(const struct server_id pid,
|
||||
|
||||
/* Inject a fault (fatal signal) into a running smbd */
|
||||
|
||||
static BOOL do_inject_fault(const struct server_id pid,
|
||||
static BOOL do_inject_fault(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
if (argc != 2) {
|
||||
@ -331,7 +336,8 @@ static BOOL do_inject_fault(const struct server_id pid,
|
||||
|
||||
/* Force a browser election */
|
||||
|
||||
static BOOL do_election(const struct server_id pid,
|
||||
static BOOL do_election(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
if (argc != 1) {
|
||||
@ -354,7 +360,9 @@ static void pong_cb(int msg_type, struct server_id pid, void *buf,
|
||||
num_replies++;
|
||||
}
|
||||
|
||||
static BOOL do_ping(const struct server_id pid, const int argc, const char **argv)
|
||||
static BOOL do_ping(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
if (argc != 1) {
|
||||
fprintf(stderr, "Usage: smbcontrol <dest> ping\n");
|
||||
@ -382,7 +390,8 @@ static BOOL do_ping(const struct server_id pid, const int argc, const char **arg
|
||||
|
||||
/* Set profiling options */
|
||||
|
||||
static BOOL do_profile(const struct server_id pid,
|
||||
static BOOL do_profile(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
int v;
|
||||
@ -458,7 +467,8 @@ static void profilelevel_rqst(int msg_type, struct server_id pid,
|
||||
send_message(pid, MSG_PROFILELEVEL, &v, sizeof(int), False);
|
||||
}
|
||||
|
||||
static BOOL do_profilelevel(const struct server_id pid,
|
||||
static BOOL do_profilelevel(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
if (argc != 1) {
|
||||
@ -488,7 +498,8 @@ static BOOL do_profilelevel(const struct server_id pid,
|
||||
|
||||
/* Display debug level settings */
|
||||
|
||||
static BOOL do_debuglevel(const struct server_id pid,
|
||||
static BOOL do_debuglevel(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
if (argc != 1) {
|
||||
@ -517,7 +528,8 @@ static BOOL do_debuglevel(const struct server_id pid,
|
||||
|
||||
/* Send a print notify message */
|
||||
|
||||
static BOOL do_printnotify(const struct server_id pid,
|
||||
static BOOL do_printnotify(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
const char *cmd;
|
||||
@ -651,13 +663,14 @@ static BOOL do_printnotify(const struct server_id pid,
|
||||
return False;
|
||||
|
||||
send:
|
||||
print_notify_send_messages(0);
|
||||
print_notify_send_messages(msg_ctx, 0);
|
||||
return True;
|
||||
}
|
||||
|
||||
/* Close a share */
|
||||
|
||||
static BOOL do_closeshare(const struct server_id pid,
|
||||
static BOOL do_closeshare(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
if (argc != 2) {
|
||||
@ -672,7 +685,8 @@ static BOOL do_closeshare(const struct server_id pid,
|
||||
|
||||
/* Force a SAM synchronisation */
|
||||
|
||||
static BOOL do_samsync(const struct server_id pid,
|
||||
static BOOL do_samsync(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
if (argc != 1) {
|
||||
@ -686,7 +700,8 @@ static BOOL do_samsync(const struct server_id pid,
|
||||
|
||||
/* Force a SAM replication */
|
||||
|
||||
static BOOL do_samrepl(const struct server_id pid,
|
||||
static BOOL do_samrepl(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
if (argc != 1) {
|
||||
@ -700,7 +715,8 @@ static BOOL do_samrepl(const struct server_id pid,
|
||||
|
||||
/* Display talloc pool usage */
|
||||
|
||||
static BOOL do_poolusage(const struct server_id pid,
|
||||
static BOOL do_poolusage(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
if (argc != 1) {
|
||||
@ -729,7 +745,8 @@ static BOOL do_poolusage(const struct server_id pid,
|
||||
|
||||
/* Perform a dmalloc mark */
|
||||
|
||||
static BOOL do_dmalloc_mark(const struct server_id pid,
|
||||
static BOOL do_dmalloc_mark(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
if (argc != 1) {
|
||||
@ -743,7 +760,8 @@ static BOOL do_dmalloc_mark(const struct server_id pid,
|
||||
|
||||
/* Perform a dmalloc changed */
|
||||
|
||||
static BOOL do_dmalloc_changed(const struct server_id pid,
|
||||
static BOOL do_dmalloc_changed(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
if (argc != 1) {
|
||||
@ -758,7 +776,8 @@ static BOOL do_dmalloc_changed(const struct server_id pid,
|
||||
|
||||
/* Shutdown a server process */
|
||||
|
||||
static BOOL do_shutdown(const struct server_id pid,
|
||||
static BOOL do_shutdown(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
if (argc != 1) {
|
||||
@ -771,7 +790,8 @@ static BOOL do_shutdown(const struct server_id pid,
|
||||
|
||||
/* Notify a driver upgrade */
|
||||
|
||||
static BOOL do_drvupgrade(const struct server_id pid,
|
||||
static BOOL do_drvupgrade(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
if (argc != 2) {
|
||||
@ -784,7 +804,8 @@ static BOOL do_drvupgrade(const struct server_id pid,
|
||||
pid, MSG_DEBUG, argv[1], strlen(argv[1]) + 1, False);
|
||||
}
|
||||
|
||||
static BOOL do_winbind_online(const struct server_id pid,
|
||||
static BOOL do_winbind_online(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
TDB_CONTEXT *tdb;
|
||||
@ -817,7 +838,8 @@ static BOOL do_winbind_online(const struct server_id pid,
|
||||
return send_message(pid, MSG_WINBIND_ONLINE, NULL, 0, False);
|
||||
}
|
||||
|
||||
static BOOL do_winbind_offline(const struct server_id pid,
|
||||
static BOOL do_winbind_offline(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
TDB_CONTEXT *tdb;
|
||||
@ -887,7 +909,8 @@ static BOOL do_winbind_offline(const struct server_id pid,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static BOOL do_winbind_onlinestatus(const struct server_id pid,
|
||||
static BOOL do_winbind_onlinestatus(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
struct server_id myid;
|
||||
@ -917,7 +940,8 @@ static BOOL do_winbind_onlinestatus(const struct server_id pid,
|
||||
}
|
||||
|
||||
|
||||
static BOOL do_reload_config(const struct server_id pid,
|
||||
static BOOL do_reload_config(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
if (argc != 1) {
|
||||
@ -939,7 +963,8 @@ static void my_make_nmb_name( struct nmb_name *n, const char *name, int type)
|
||||
push_ascii(n->scope, global_scope(), 64, STR_TERMINATE);
|
||||
}
|
||||
|
||||
static BOOL do_nodestatus(const struct server_id pid,
|
||||
static BOOL do_nodestatus(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv)
|
||||
{
|
||||
struct packet_struct p;
|
||||
@ -979,7 +1004,8 @@ static BOOL do_nodestatus(const struct server_id pid,
|
||||
|
||||
static const struct {
|
||||
const char *name; /* Option name */
|
||||
BOOL (*fn)(const struct server_id pid,
|
||||
BOOL (*fn)(struct messaging_context *msg_ctx,
|
||||
const struct server_id pid,
|
||||
const int argc, const char **argv);
|
||||
const char *help; /* Short help text */
|
||||
} msg_types[] = {
|
||||
@ -1085,7 +1111,8 @@ static struct server_id parse_dest(const char *dest)
|
||||
|
||||
/* Execute smbcontrol command */
|
||||
|
||||
static BOOL do_command(int argc, const char **argv)
|
||||
static BOOL do_command(struct messaging_context *msg_ctx,
|
||||
int argc, const char **argv)
|
||||
{
|
||||
const char *dest = argv[0], *command = argv[1];
|
||||
struct server_id pid;
|
||||
@ -1102,7 +1129,8 @@ static BOOL do_command(int argc, const char **argv)
|
||||
|
||||
for (i = 0; msg_types[i].name; i++) {
|
||||
if (strequal(command, msg_types[i].name))
|
||||
return msg_types[i].fn(pid, argc - 1, argv + 1);
|
||||
return msg_types[i].fn(msg_ctx, pid,
|
||||
argc - 1, argv + 1);
|
||||
}
|
||||
|
||||
fprintf(stderr, "smbcontrol: unknown command '%s'\n", command);
|
||||
@ -1116,6 +1144,8 @@ int main(int argc, const char **argv)
|
||||
{
|
||||
poptContext pc;
|
||||
int opt;
|
||||
struct event_context *evt_ctx;
|
||||
struct messaging_context *msg_ctx;
|
||||
|
||||
static struct poptOption long_options[] = {
|
||||
POPT_AUTOHELP
|
||||
@ -1171,5 +1201,11 @@ int main(int argc, const char **argv)
|
||||
* routines mostly return True==1 for success, but
|
||||
* shell needs 0. */
|
||||
|
||||
return !do_command(argc, argv);
|
||||
if (!(evt_ctx = event_context_init(NULL)) ||
|
||||
!(msg_ctx = messaging_init(NULL, server_id_self(), evt_ctx))) {
|
||||
fprintf(stderr, "could not init messaging context\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return !do_command(msg_ctx, argc, argv);
|
||||
}
|
||||
|
Reference in New Issue
Block a user