1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

r23015: Make message_(de)register static to messages.c

This commit is contained in:
Volker Lendecke 2007-05-19 21:53:28 +00:00 committed by Gerald (Jerry) Carter
parent fa18fc25a5
commit a8082a3c7c
9 changed files with 130 additions and 71 deletions

View File

@ -35,10 +35,11 @@ static unsigned long our_dm_mark = 0;
* Respond to a POOL_USAGE message by sending back string form of memory
* usage stats.
**/
static void msg_req_dmalloc_mark(int UNUSED(msg_type),
struct server_id UNUSED(src_pid),
void *UNUSED(buf), size_t UNUSED(len),
void *private_data)
static void msg_req_dmalloc_mark(struct messaging_context *msg,
void *private_data,
uint32_t msg_type,
struct server_id server_id,
DATA_BLOB *data)
{
#ifdef ENABLE_DMALLOC
our_dm_mark = dmalloc_mark();
@ -50,10 +51,11 @@ static void msg_req_dmalloc_mark(int UNUSED(msg_type),
static void msg_req_dmalloc_log_changed(int UNUSED(msg_type),
struct server_id UNUSED(src_pid),
void *UNUSED(buf), size_t UNUSED(len),
void *private_data)
static void msg_req_dmalloc_log_changed(struct messaging_context *msg,
void *private_data,
uint32_t msg_type,
struct server_id server_id,
DATA_BLOB *data)
{
#ifdef ENABLE_DMALLOC
dmalloc_log_changed(our_dm_mark, True, True, True);
@ -67,10 +69,11 @@ static void msg_req_dmalloc_log_changed(int UNUSED(msg_type),
/**
* Register handler for MSG_REQ_POOL_USAGE
**/
void register_dmalloc_msgs(void)
void register_dmalloc_msgs(struct messaging_context *msg_ctx)
{
message_register(MSG_REQ_DMALLOC_MARK, msg_req_dmalloc_mark, NULL);
message_register(MSG_REQ_DMALLOC_LOG_CHANGED,
msg_req_dmalloc_log_changed, NULL);
messaging_register(msg_ctx, NULL, MSG_REQ_DMALLOC_MARK,
msg_req_dmalloc_mark);
messaging_register(msg_ctx, NULL, MSG_REQ_DMALLOC_LOG_CHANGED,
msg_req_dmalloc_log_changed);
DEBUG(2, ("Registered MSG_REQ_DMALLOC_MARK and LOG_CHANGED\n"));
}

View File

@ -224,6 +224,21 @@ BOOL event_add_to_select_args(struct event_context *event_ctx,
return True;
}
BOOL events_pending(struct event_context *event_ctx)
{
struct fd_event *fde;
if (event_ctx->timed_events != NULL) {
return True;
}
for (fde = event_ctx->fd_events; fde; fde = fde->next) {
if (fde->flags & (EVENT_FD_READ|EVENT_FD_WRITE)) {
return True;
}
}
return False;
}
BOOL run_events(struct event_context *event_ctx,
int selrtn, fd_set *read_fds, fd_set *write_fds)
{

View File

@ -71,6 +71,12 @@ static struct dispatch_fns {
void *private_data;
} *dispatch_fns;
static void message_register(int msg_type,
void (*fn)(int msg_type, struct server_id pid,
void *buf, size_t len,
void *private_data),
void *private_data);
/****************************************************************************
Free global objects.
****************************************************************************/
@ -147,7 +153,7 @@ static BOOL message_init(struct messaging_context *msg_ctx)
/* Register some debugging related messages */
register_msg_pool_usage(msg_ctx);
register_dmalloc_msgs();
register_dmalloc_msgs(msg_ctx);
debug_register_msgs(msg_ctx);
return True;
@ -545,7 +551,7 @@ void message_dispatch(void)
messages on an *odd* byte boundary.
****************************************************************************/
void message_register(int msg_type,
static void message_register(int msg_type,
void (*fn)(int msg_type, struct server_id pid,
void *buf, size_t len,
void *private_data),
@ -582,7 +588,7 @@ void message_register(int msg_type,
De-register the function for a particular message type.
****************************************************************************/
void message_deregister(int msg_type)
static void message_deregister(int msg_type)
{
struct dispatch_fns *dfn, *next;

View File

@ -88,8 +88,11 @@ static void terminate(void)
Handle a SHUTDOWN message from smbcontrol.
**************************************************************************** */
static void nmbd_terminate(int msg_type, struct server_id src,
void *buf, size_t len, void *private_data)
static void nmbd_terminate(struct messaging_context *msg,
void *private_data,
uint32_t msg_type,
struct server_id server_id,
DATA_BLOB *data)
{
terminate();
}
@ -283,33 +286,39 @@ static BOOL reload_nmbd_services(BOOL test)
* detects that there are no subnets.
**************************************************************************** */
static void msg_reload_nmbd_services(int msg_type, struct server_id src,
void *buf, size_t len, void *private_data)
static void msg_reload_nmbd_services(struct messaging_context *msg,
void *private_data,
uint32_t msg_type,
struct server_id server_id,
DATA_BLOB *data)
{
write_browse_list( 0, True );
dump_all_namelists();
reload_nmbd_services( True );
reopen_logs();
if(buf) {
if (data->data) {
/* We were called from process() */
/* If reload_interfaces() returned True */
/* we need to shutdown if there are no subnets... */
/* pass this info back to process() */
*((BOOL*)buf) = reload_interfaces(0);
*((BOOL*)data->data) = reload_interfaces(0);
}
}
static void msg_nmbd_send_packet(int msg_type, struct server_id src,
void *buf, size_t len, void *private_data)
static void msg_nmbd_send_packet(struct messaging_context *msg,
void *private_data,
uint32_t msg_type,
struct server_id src,
DATA_BLOB *data)
{
struct packet_struct *p = (struct packet_struct *)buf;
struct packet_struct *p = (struct packet_struct *)data->data;
struct subnet_record *subrec;
struct in_addr *local_ip;
DEBUG(10, ("Received send_packet from %d\n", procid_to_pid(&src)));
if (len != sizeof(struct packet_struct)) {
if (data->length != sizeof(struct packet_struct)) {
DEBUG(2, ("Discarding invalid packet length from %d\n",
procid_to_pid(&src)));
return;
@ -568,9 +577,13 @@ static void process(void)
*/
if(reload_after_sighup) {
DATA_BLOB blob = data_blob_const(&no_subnets,
sizeof(no_subnets));
DEBUG( 0, ( "Got SIGHUP dumping debug info.\n" ) );
msg_reload_nmbd_services(MSG_SMB_CONF_UPDATED,
pid_to_procid(0), (void*) &no_subnets, 0, NULL);
msg_reload_nmbd_services(nmbd_messaging_context(),
NULL, MSG_SMB_CONF_UPDATED,
procid_self(), &blob);
if(no_subnets)
return;
reload_after_sighup = 0;
@ -770,14 +783,19 @@ static BOOL open_sockets(enum smb_server_mode server_mode, int port)
}
pidfile_create("nmbd");
message_register(MSG_FORCE_ELECTION, nmbd_message_election, NULL);
messaging_register(nmbd_messaging_context(), NULL,
MSG_FORCE_ELECTION, nmbd_message_election);
#if 0
/* Until winsrepl is done. */
message_register(MSG_WINS_NEW_ENTRY, nmbd_wins_new_entry, NULL);
messaging_register(nmbd_messaging_context(), NULL,
MSG_WINS_NEW_ENTRY, nmbd_wins_new_entry);
#endif
message_register(MSG_SHUTDOWN, nmbd_terminate, NULL);
message_register(MSG_SMB_CONF_UPDATED, msg_reload_nmbd_services, NULL);
message_register(MSG_SEND_PACKET, msg_nmbd_send_packet, NULL);
messaging_register(nmbd_messaging_context(), NULL,
MSG_SHUTDOWN, nmbd_terminate);
messaging_register(nmbd_messaging_context(), NULL,
MSG_SMB_CONF_UPDATED, msg_reload_nmbd_services);
messaging_register(nmbd_messaging_context(), NULL,
MSG_SEND_PACKET, msg_nmbd_send_packet);
TimeInit();

View File

@ -378,8 +378,11 @@ yet registered on subnet %s\n", nmb_namestr(&nmbname), subrec->subnet_name ));
Process a internal Samba message forcing an election.
***************************************************************************/
void nmbd_message_election(int msg_type, struct server_id src,
void *buf, size_t len, void *private_data)
void nmbd_message_election(struct messaging_context *msg,
void *private_data,
uint32_t msg_type,
struct server_id server_id,
DATA_BLOB *data)
{
struct subnet_record *subrec;

View File

@ -2370,8 +2370,11 @@ void wins_write_database(time_t t, BOOL background)
Process a internal Samba message receiving a wins record.
***************************************************************************/
void nmbd_wins_new_entry(int msg_type, struct server_id src,
void *buf, size_t len, void *private_data)
void nmbd_wins_new_entry(struct messaging_context *msg,
void *private_data,
uint32_t msg_type,
struct server_id server_id,
DATA_BLOB *data)
{
WINS_RECORD *record;
struct name_record *namerec = NULL;

View File

@ -435,8 +435,10 @@ static void set_domain_online(struct winbindd_domain *domain)
}
/* Ensure we ignore any pending child messages. */
message_deregister(MSG_WINBIND_TRY_TO_GO_ONLINE);
message_deregister(MSG_WINBIND_FAILED_TO_GO_ONLINE);
messaging_deregister(winbind_messaging_context(),
MSG_WINBIND_TRY_TO_GO_ONLINE, NULL);
messaging_deregister(winbind_messaging_context(),
MSG_WINBIND_FAILED_TO_GO_ONLINE, NULL);
domain->online = True;

View File

@ -166,7 +166,8 @@ static void srv_spoolss_replycloseprinter(int snum, POLICY_HND *handle)
cli_shutdown( notify_cli_pipe->cli );
notify_cli_pipe = NULL; /* The above call shuts downn the pipe also. */
message_deregister(MSG_PRINTER_NOTIFY2);
messaging_deregister(smbd_messaging_context(),
MSG_PRINTER_NOTIFY2, NULL);
/* Tell the connections db we're no longer interested in
* printer notify messages. */
@ -1110,19 +1111,21 @@ static BOOL notify2_unpack_msg( SPOOLSS_NOTIFY_MSG *msg, struct timeval *tv, voi
Receive a notify2 message list
********************************************************************/
static void receive_notify2_message_list(int msg_type, struct server_id src,
void *msg, size_t len,
void *private_data)
static void receive_notify2_message_list(struct messaging_context *msg,
void *private_data,
uint32_t msg_type,
struct server_id server_id,
DATA_BLOB *data)
{
size_t msg_count, i;
char *buf = (char *)msg;
char *buf = (char *)data->data;
char *msg_ptr;
size_t msg_len;
SPOOLSS_NOTIFY_MSG notify;
SPOOLSS_NOTIFY_MSG_CTR messages;
int num_groups;
if (len < 4) {
if (data->length < 4) {
DEBUG(0,("receive_notify2_message_list: bad message format (len < 4)!\n"));
return;
}
@ -1152,7 +1155,7 @@ static void receive_notify2_message_list(int msg_type, struct server_id src,
for ( i=0; i<msg_count; i++ ) {
struct timeval msg_tv;
if (msg_ptr + 4 - buf > len) {
if (msg_ptr + 4 - buf > data->length) {
DEBUG(0,("receive_notify2_message_list: bad message format (len > buf_size) !\n"));
return;
}
@ -1160,7 +1163,7 @@ static void receive_notify2_message_list(int msg_type, struct server_id src,
msg_len = IVAL(msg_ptr,0);
msg_ptr += 4;
if (msg_ptr + msg_len - buf > len) {
if (msg_ptr + msg_len - buf > data->length) {
DEBUG(0,("receive_notify2_message_list: bad message format (bad len) !\n"));
return;
}
@ -2616,8 +2619,9 @@ static BOOL srv_spoolss_replyopenprinter(int snum, const char *printer,
if ( !spoolss_connect_to_client( &notify_cli_pipe, client_ip, unix_printer ))
return False;
message_register(MSG_PRINTER_NOTIFY2,
receive_notify2_message_list, NULL);
messaging_register(smbd_messaging_context(), NULL,
MSG_PRINTER_NOTIFY2,
receive_notify2_message_list);
/* Tell the connections db we're now interested in printer
* notify messages. */
register_message_flags( True, FLAG_MSG_PRINT_NOTIFY );

View File

@ -74,9 +74,11 @@ static BOOL in_chained_smb(void)
return (chain_size != 0);
}
static void received_unlock_msg(int msg_type, struct server_id src,
void *buf, size_t len,
void *private_data);
static void received_unlock_msg(struct messaging_context *msg,
void *private_data,
uint32_t msg_type,
struct server_id server_id,
DATA_BLOB *data);
static void process_blocking_lock_queue(void);
static void brl_timeout_fn(struct event_context *event_ctx,
@ -231,8 +233,8 @@ BOOL push_blocking_lock_request( struct byte_range_lock *br_lck,
/* Ensure we'll receive messages when this is unlocked. */
if (!set_lock_msg) {
message_register(MSG_SMB_UNLOCK, received_unlock_msg,
NULL);
messaging_register(smbd_messaging_context(), NULL,
MSG_SMB_UNLOCK, received_unlock_msg);
set_lock_msg = True;
}
@ -665,9 +667,11 @@ BOOL blocking_lock_was_deferred(int mid)
Set a flag as an unlock request affects one of our pending locks.
*****************************************************************************/
static void received_unlock_msg(int msg_type, struct server_id src,
void *buf, size_t len,
void *private_data)
static void received_unlock_msg(struct messaging_context *msg,
void *private_data,
uint32_t msg_type,
struct server_id server_id,
DATA_BLOB *data)
{
DEBUG(10,("received_unlock_msg\n"));
process_blocking_lock_queue();
@ -826,22 +830,23 @@ static void process_blocking_lock_queue(void)
#define MSG_BLOCKING_LOCK_CANCEL_SIZE (sizeof(blocking_lock_record *) + sizeof(NTSTATUS))
static void process_blocking_lock_cancel_message(int msg_type,
struct server_id src,
void *buf, size_t len,
void *private_data)
static void process_blocking_lock_cancel_message(struct messaging_context *ctx,
void *private_data,
uint32_t msg_type,
struct server_id server_id,
DATA_BLOB *data)
{
NTSTATUS err;
const char *msg = (const char *)buf;
const char *msg = (const char *)data->data;
blocking_lock_record *blr;
if (buf == NULL) {
if (data->data == NULL) {
smb_panic("process_blocking_lock_cancel_message: null msg\n");
}
if (len != MSG_BLOCKING_LOCK_CANCEL_SIZE) {
if (data->length != MSG_BLOCKING_LOCK_CANCEL_SIZE) {
DEBUG(0, ("process_blocking_lock_cancel_message: "
"Got invalid msg len %d\n", (int)len));
"Got invalid msg len %d\n", (int)data->length));
smb_panic("process_blocking_lock_cancel_message: bad msg\n");
}
@ -874,9 +879,9 @@ BOOL blocking_lock_cancel(files_struct *fsp,
if (!initialized) {
/* Register our message. */
message_register(MSG_SMB_BLOCKING_LOCK_CANCEL,
process_blocking_lock_cancel_message,
NULL);
messaging_register(smbd_messaging_context(), NULL,
MSG_SMB_BLOCKING_LOCK_CANCEL,
process_blocking_lock_cancel_message);
initialized = True;
}