The branch, master has been updated via c5e242b1a39f0bb26c8c922f25cf7b072e5e834c (commit) via 240762aefe1af16d56a0a1bc4880702a006fe050 (commit) via 7a07fcdc1e1f01483ae9d509a9d42eea4d454529 (commit) via cf53e48fecf2a4410ff641eb6e0edd8578cccb15 (commit) via 4d413381a2496a4d73e4d406efbfd68c28fee3b4 (commit) via 830b31a41aeadf6b688c5f60f114f6137ea13afb (commit) via a4d605344bcd16d01b7049c477d99f8d9841f13c (commit) via c44a0ae87aef333570ce588fc9b46392dd528030 (commit) via f029b2b05872f6cfe214241a614081f81c43c7bd (commit) via 196028ab7b578526179d4fcff42a5d73ba07ccbb (commit) via 048f8dba141c2f9898aad67e09925f03394a946e (commit) via f9dcd3d2b79e4c1e19ac1c81e3e75370c8716586 (commit) from 3b34486f6aaeb81376d9522a01bc6b69d34b4572 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit c5e242b1a39f0bb26c8c922f25cf7b072e5e834c Author: Stefan Metzmacher <me...@samba.org> Date: Wed Jan 21 07:39:28 2009 +0100 s3:printing: make some functions static and use tevent functions metze commit 240762aefe1af16d56a0a1bc4880702a006fe050 Author: Stefan Metzmacher <me...@samba.org> Date: Wed Jan 21 07:39:56 2009 +0100 s3:messages: finally make message_dispatch() static metze commit 7a07fcdc1e1f01483ae9d509a9d42eea4d454529 Author: Stefan Metzmacher <me...@samba.org> Date: Wed Jan 21 07:37:07 2009 +0100 s3:printing: handle tevent_context events in the sys_select() call metze commit cf53e48fecf2a4410ff641eb6e0edd8578cccb15 Author: Stefan Metzmacher <me...@samba.org> Date: Wed Jan 21 07:35:07 2009 +0100 s3:winbindd: we don't need to call message_dispatch() anymore it's event triggered now metze commit 4d413381a2496a4d73e4d406efbfd68c28fee3b4 Author: Stefan Metzmacher <me...@samba.org> Date: Wed Jan 21 07:34:49 2009 +0100 s3:nmbd: we don't need to call message_dispatch() anymore it's event triggered now metze commit 830b31a41aeadf6b688c5f60f114f6137ea13afb Author: Stefan Metzmacher <me...@samba.org> Date: Wed Jan 21 07:33:19 2009 +0100 s3:smbd: we don't need to call message_dispatch() anymore it's event triggered now metze commit a4d605344bcd16d01b7049c477d99f8d9841f13c Author: Stefan Metzmacher <me...@samba.org> Date: Wed Jan 21 07:31:33 2009 +0100 s3:msgtest: don't call message_dispatch() anymore, use tevent_loop_once() instead metze commit c44a0ae87aef333570ce588fc9b46392dd528030 Author: Stefan Metzmacher <me...@samba.org> Date: Wed Jan 21 07:30:13 2009 +0100 s3:smbcontrol: don't call message_dispatch() anymore, it's triggered by tevent_loop_once() metze commit f029b2b05872f6cfe214241a614081f81c43c7bd Author: Stefan Metzmacher <me...@samba.org> Date: Mon Jan 12 18:14:04 2009 +0100 s3:messaging: start with to use signal events instead of the raw signal interfaces metze commit 196028ab7b578526179d4fcff42a5d73ba07ccbb Author: Stefan Metzmacher <me...@samba.org> Date: Fri Jan 9 14:02:18 2009 +0100 s3:smbd: restructure kernel oplocks code This converts the irix oplocks code to use a fd event and removes the last special case for file descriptors for the main sys_select(). metze commit 048f8dba141c2f9898aad67e09925f03394a946e Author: Stefan Metzmacher <me...@samba.org> Date: Tue Jan 20 04:14:20 2009 +0100 s3: always call run_events() before and after sys_select() And always setup the fd events. metze commit f9dcd3d2b79e4c1e19ac1c81e3e75370c8716586 Author: Stefan Metzmacher <me...@samba.org> Date: Tue Jan 20 01:58:04 2009 +0100 s3:events: always run_events() before sys_select() We might have pending signal events not only timed events. metze ----------------------------------------------------------------------- Summary of changes: source3/include/messages.h | 1 - source3/include/proto.h | 10 +-- source3/include/smb.h | 19 ++++-- source3/lib/events.c | 9 +-- source3/lib/messages_local.c | 105 +++++++++++++++++++++------------ source3/nmbd/nmbd.c | 4 - source3/nmbd/nmbd_packets.c | 16 ++--- source3/printing/notify.c | 20 ++++--- source3/printing/printing.c | 58 +++++++++++++----- source3/smbd/globals.c | 13 +---- source3/smbd/globals.h | 9 +--- source3/smbd/oplock.c | 33 +++------- source3/smbd/oplock_irix.c | 118 ++++++++++++++++++++++++-------------- source3/smbd/oplock_linux.c | 36 ++++++++---- source3/smbd/process.c | 79 ++++--------------------- source3/smbd/server.c | 15 +++-- source3/torture/msgtest.c | 27 ++++++--- source3/utils/smbcontrol.c | 29 +++++---- source3/winbindd/winbindd.c | 8 +-- source3/winbindd/winbindd_dual.c | 29 +++++++--- 20 files changed, 337 insertions(+), 301 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/include/messages.h b/source3/include/messages.h index 785f116..2e42fc6 100644 --- a/source3/include/messages.h +++ b/source3/include/messages.h @@ -109,7 +109,6 @@ struct messaging_backend { NTSTATUS messaging_tdb_init(struct messaging_context *msg_ctx, TALLOC_CTX *mem_ctx, struct messaging_backend **presult); -void message_dispatch(struct messaging_context *msg_ctx); NTSTATUS messaging_ctdbd_init(struct messaging_context *msg_ctx, TALLOC_CTX *mem_ctx, diff --git a/source3/include/proto.h b/source3/include/proto.h index 632f820..40ced54 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -4722,7 +4722,6 @@ bool parse_lpq_entry(enum printing_types printing_type,char *line, /* The following definitions come from printing/notify.c */ int print_queue_snum(const char *qname); -bool print_notify_messages_pending(void); void print_notify_send_messages(struct messaging_context *msg_ctx, unsigned int timeout); void notify_printer_status_byname(const char *sharename, uint32 status); @@ -4745,7 +4744,6 @@ void notify_printer_printername(int snum, char *printername); void notify_printer_port(int snum, char *port_name); void notify_printer_location(int snum, char *location); void notify_printer_byname( const char *printername, uint32 change, const char *value ); -bool print_notify_pid_list(const char *printername, TALLOC_CTX *mem_ctx, size_t *p_num_pids, pid_t **pp_pid_list); /* The following definitions come from printing/nt_printing.c */ @@ -7026,8 +7024,8 @@ NTSTATUS get_relative_fid_filename(connection_struct *conn, /* The following definitions come from smbd/oplock.c */ int32 get_number_of_exclusive_open_oplocks(void); -bool oplock_message_waiting(fd_set *fds); -void process_kernel_oplocks(struct messaging_context *msg_ctx, fd_set *pfds); +bool oplock_message_waiting(); +void process_kernel_oplocks(struct messaging_context *msg_ctx); bool set_file_oplock(files_struct *fsp, int oplock_type); void release_file_oplock(files_struct *fsp); bool remove_oplock(files_struct *fsp); @@ -7041,14 +7039,14 @@ bool init_oplocks(struct messaging_context *msg_ctx); /* The following definitions come from smbd/oplock_irix.c */ -struct kernel_oplocks *irix_init_kernel_oplocks(void) ; +struct kernel_oplocks *irix_init_kernel_oplocks(TALLOC_CTX *mem_ctx) ; /* The following definitions come from smbd/oplock_linux.c */ void linux_set_lease_capability(void); int linux_set_lease_sighandler(int fd); int linux_setlease(int fd, int leasetype); -struct kernel_oplocks *linux_init_kernel_oplocks(void) ; +struct kernel_oplocks *linux_init_kernel_oplocks(TALLOC_CTX *mem_ctx) ; /* The following definitions come from smbd/password.c */ diff --git a/source3/include/smb.h b/source3/include/smb.h index 799ffe1..19d2208 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -1671,14 +1671,21 @@ enum smbd_capability { LEASE_CAPABILITY }; +struct kernel_oplocks_ops; +struct kernel_oplocks { + const struct kernel_oplocks_ops *ops; + void *private_data; +}; + /* if a kernel does support oplocks then a structure of the following typee is used to describe how to interact with the kernel */ -struct kernel_oplocks { - files_struct * (*receive_message)(fd_set *fds); - bool (*set_oplock)(files_struct *fsp, int oplock_type); - void (*release_oplock)(files_struct *fsp); - bool (*msg_waiting)(fd_set *fds); - int notification_fd; +struct kernel_oplocks_ops { + files_struct * (*receive_message)(struct kernel_oplocks *ctx); + bool (*set_oplock)(struct kernel_oplocks *ctx, + files_struct *fsp, int oplock_type); + void (*release_oplock)(struct kernel_oplocks *ctx, + files_struct *fsp); + bool (*msg_waiting)(struct kernel_oplocks *ctx); }; #include "smb_macros.h" diff --git a/source3/lib/events.c b/source3/lib/events.c index 74f30a7..4484d53 100644 --- a/source3/lib/events.c +++ b/source3/lib/events.c @@ -180,17 +180,16 @@ static int s3_event_loop_once(struct tevent_context *ev) to.tv_sec = 9999; /* Max timeout */ to.tv_usec = 0; + if (run_events(ev, 0, NULL, NULL)) { + return 0; + } + GetTimeOfDay(&now); if (!event_add_to_select_args(ev, &now, &r_fds, &w_fds, &to, &maxfd)) { return -1; } - if (timeval_is_zero(&to)) { - run_events(ev, 0, NULL, NULL); - return 0; - } - ret = sys_select(maxfd+1, &r_fds, &w_fds, NULL, &to); if (ret == -1 && errno != EINTR) { diff --git a/source3/lib/messages_local.c b/source3/lib/messages_local.c index 9f7f88f..be848ac 100644 --- a/source3/lib/messages_local.c +++ b/source3/lib/messages_local.c @@ -46,28 +46,33 @@ #include "librpc/gen_ndr/messaging.h" #include "librpc/gen_ndr/ndr_messaging.h" -static sig_atomic_t received_signal; +struct messaging_tdb_context { + struct messaging_context *msg_ctx; + struct tdb_wrap *tdb; + struct tevent_signal *se; + int received_messages; +}; static NTSTATUS messaging_tdb_send(struct messaging_context *msg_ctx, struct server_id pid, int msg_type, const DATA_BLOB *data, struct messaging_backend *backend); +static void message_dispatch(struct messaging_context *msg_ctx); -/**************************************************************************** - Notifications come in as signals. -****************************************************************************/ - -static void sig_usr1(void) +static void messaging_tdb_signal_handler(struct tevent_context *ev_ctx, + struct tevent_signal *se, + int signum, int count, + void *_info, void *private_data) { - received_signal = 1; - sys_select_signal(SIGUSR1); -} + struct messaging_tdb_context *ctx = talloc_get_type(private_data, + struct messaging_tdb_context); -static int messaging_tdb_destructor(struct messaging_backend *tdb_ctx) -{ - struct tdb_wrap *tdb = (struct tdb_wrap *)tdb_ctx->private_data; - TALLOC_FREE(tdb); - return 0; + ctx->received_messages++; + + DEBUG(10, ("messaging_tdb_signal_handler: sig[%d] count[%d] msgs[%d]\n", + signum, count, ctx->received_messages)); + + message_dispatch(ctx->msg_ctx); } /**************************************************************************** @@ -79,18 +84,29 @@ NTSTATUS messaging_tdb_init(struct messaging_context *msg_ctx, struct messaging_backend **presult) { struct messaging_backend *result; - struct tdb_wrap *tdb; + struct messaging_tdb_context *ctx; if (!(result = TALLOC_P(mem_ctx, struct messaging_backend))) { DEBUG(0, ("talloc failed\n")); return NT_STATUS_NO_MEMORY; } - tdb = tdb_wrap_open(result, lock_path("messages.tdb"), - 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT, - O_RDWR|O_CREAT,0600); + ctx = TALLOC_ZERO_P(result, struct messaging_tdb_context); + if (!ctx) { + DEBUG(0, ("talloc failed\n")); + TALLOC_FREE(result); + return NT_STATUS_NO_MEMORY; + } + result->private_data = ctx; + result->send_fn = messaging_tdb_send; + + ctx->msg_ctx = msg_ctx; + + ctx->tdb = tdb_wrap_open(ctx, lock_path("messages.tdb"), + 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT, + O_RDWR|O_CREAT,0600); - if (!tdb) { + if (!ctx->tdb) { NTSTATUS status = map_nt_error_from_unix(errno); DEBUG(0, ("ERROR: Failed to initialise messages database: " "%s\n", strerror(errno))); @@ -98,17 +114,23 @@ NTSTATUS messaging_tdb_init(struct messaging_context *msg_ctx, return status; } + ctx->se = tevent_add_signal(msg_ctx->event_ctx, + ctx, + SIGUSR1, 0, + messaging_tdb_signal_handler, + ctx); + if (!ctx->se) { + NTSTATUS status = map_nt_error_from_unix(errno); + DEBUG(0, ("ERROR: Failed to initialise messages signal handler: " + "%s\n", strerror(errno))); + TALLOC_FREE(result); + return status; + } + sec_init(); /* Activate the per-hashchain freelist */ - tdb_set_max_dead(tdb->tdb, 5); - - CatchSignal(SIGUSR1, SIGNAL_CAST sig_usr1); - - result->private_data = (void *)tdb; - result->send_fn = messaging_tdb_send; - - talloc_set_destructor(result, messaging_tdb_destructor); + tdb_set_max_dead(ctx->tdb->tdb, 5); *presult = result; return NT_STATUS_OK; @@ -289,11 +311,13 @@ static NTSTATUS messaging_tdb_send(struct messaging_context *msg_ctx, const DATA_BLOB *data, struct messaging_backend *backend) { + struct messaging_tdb_context *ctx = talloc_get_type(backend->private_data, + struct messaging_tdb_context); struct messaging_array *msg_array; struct messaging_rec *rec; NTSTATUS status; TDB_DATA key; - struct tdb_wrap *tdb = (struct tdb_wrap *)backend->private_data; + struct tdb_wrap *tdb = ctx->tdb; TALLOC_CTX *frame = talloc_stackframe(); /* NULL pointer means implicit length zero. */ @@ -406,26 +430,31 @@ static NTSTATUS retrieve_all_messages(TDB_CONTEXT *msg_tdb, messages on an *odd* byte boundary. ****************************************************************************/ -void message_dispatch(struct messaging_context *msg_ctx) +static void message_dispatch(struct messaging_context *msg_ctx) { + struct messaging_tdb_context *ctx = talloc_get_type(msg_ctx->local->private_data, + struct messaging_tdb_context); struct messaging_array *msg_array = NULL; - struct tdb_wrap *tdb = (struct tdb_wrap *) - (msg_ctx->local->private_data); + struct tdb_wrap *tdb = ctx->tdb; + NTSTATUS status; uint32 i; - if (!received_signal) + if (ctx->received_messages == 0) { return; + } - DEBUG(10, ("message_dispatch: received_signal = %d\n", - received_signal)); - - received_signal = 0; + DEBUG(10, ("message_dispatch: received_messages = %d\n", + ctx->received_messages)); - if (!NT_STATUS_IS_OK(retrieve_all_messages(tdb->tdb, NULL, - &msg_array))) { + status = retrieve_all_messages(tdb->tdb, NULL, &msg_array); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("message_dispatch: failed to retrieve messages: %s\n", + nt_errstr(status))); return; } + ctx->received_messages = 0; + for (i=0; i<msg_array->num_messages; i++) { messaging_dispatch_rec(msg_ctx, &msg_array->messages[i]); } diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c index 10d6fe2..0922e45 100644 --- a/source3/nmbd/nmbd.c +++ b/source3/nmbd/nmbd.c @@ -441,10 +441,6 @@ static void process(void) time_t t = time(NULL); TALLOC_CTX *frame = talloc_stackframe(); - /* Check for internal messages */ - - message_dispatch(nmbd_messaging_context()); - /* * Check all broadcast subnets to see if * we need to run an election on any of them. diff --git a/source3/nmbd/nmbd_packets.c b/source3/nmbd/nmbd_packets.c index 66b584a..4890348 100644 --- a/source3/nmbd/nmbd_packets.c +++ b/source3/nmbd/nmbd_packets.c @@ -1773,6 +1773,11 @@ bool listen_for_packets(bool run_election) } #endif + /* Process a signal and timer events now... */ + if (run_events(nmbd_event_context(), 0, NULL, NULL)) { + return False; + } + /* * During elections and when expecting a netbios response packet we * need to send election packets at tighter intervals. @@ -1789,13 +1794,6 @@ bool listen_for_packets(bool run_election) &r_fds, &w_fds, &timeout, &maxfd); } - if (timeval_is_zero(&timeout)) { - /* Process a timed event now... */ - if (run_events(nmbd_event_context(), 0, NULL, NULL)) { - return False; - } - } - /* Prepare for the select - allow certain signals. */ BlockSignals(False, SIGTERM); @@ -1806,11 +1804,11 @@ bool listen_for_packets(bool run_election) BlockSignals(True, SIGTERM); - if(selrtn == -1) { + if (run_events(nmbd_event_context(), selrtn, &r_fds, &w_fds)) { return False; } - if (run_events(nmbd_event_context(), selrtn, &r_fds, &w_fds)) { + if (selrtn == -1) { return False; } diff --git a/source3/printing/notify.c b/source3/printing/notify.c index 860a400..d478b86 100644 --- a/source3/printing/notify.c +++ b/source3/printing/notify.c @@ -34,7 +34,10 @@ static struct notify_queue { size_t buflen; } *notify_queue_head = NULL; -static struct timed_event *notify_event; +static struct tevent_timer *notify_event; + +static bool print_notify_pid_list(const char *printername, TALLOC_CTX *mem_ctx, + size_t *p_num_pids, pid_t **pp_pid_list); static bool create_send_ctx(void) { @@ -63,7 +66,7 @@ int print_queue_snum(const char *qname) Used to decide if we need a short select timeout. *******************************************************************/ -bool print_notify_messages_pending(void) +static bool print_notify_messages_pending(void) { return (notify_queue_head != NULL); } @@ -219,10 +222,10 @@ void print_notify_send_messages(struct messaging_context *msg_ctx, Event handler to send the messages. *******************************************************************/ -static void print_notify_event_send_messages(struct event_context *event_ctx, - struct timed_event *te, - struct timeval now, - void *private_data) +static void print_notify_event_send_messages(struct tevent_context *event_ctx, + struct tevent_timer *te, + struct timeval now, + void *private_data) { /* Remove this timed event handler. */ TALLOC_FREE(notify_event); @@ -324,7 +327,7 @@ to notify_queue_head\n", msg->type, msg->field, msg->printer)); if ((notify_event == NULL) && (smbd_event_context() != NULL)) { /* Add an event for 1 second's time to send this queue. */ - notify_event = event_add_timed(smbd_event_context(), NULL, + notify_event = tevent_add_timer(smbd_event_context(), NULL, timeval_current_ofs(1,0), print_notify_event_send_messages, NULL); } @@ -535,7 +538,8 @@ void notify_printer_byname( const char *printername, uint32 change, const char * messages on this print queue. Used in printing/notify to send the messages. ****************************************************************************/ -bool print_notify_pid_list(const char *printername, TALLOC_CTX *mem_ctx, size_t *p_num_pids, pid_t **pp_pid_list) +static bool print_notify_pid_list(const char *printername, TALLOC_CTX *mem_ctx, + size_t *p_num_pids, pid_t **pp_pid_list) { struct tdb_print_db *pdb = NULL; TDB_CONTEXT *tdb = NULL; diff --git a/source3/printing/printing.c b/source3/printing/printing.c index fffe917..bb29380 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -1439,15 +1439,47 @@ void start_background_queue(void) DEBUG(5,("start_background_queue: background LPQ thread waiting for messages\n")); while (1) { - fd_set pause_fds; - int pause_select; + fd_set r_fds, w_fds; + int ret; + struct timeval to; + int maxfd = 0; - FD_ZERO(&pause_fds); - FD_SET(pause_pipe[1], &pause_fds); - pause_select = sys_select(pause_pipe[1]+1, &pause_fds, NULL, NULL, NULL); - /* If pause_pipe[0] is closed it means the parent smbd + /* Process a signal and timed events now... */ + if (run_events(smbd_event_context(), 0, NULL, NULL)) { + continue; + } + + to.tv_sec = SMBD_SELECT_TIMEOUT; + to.tv_usec = 0; + + /* + * Setup the select fd sets. + */ + + FD_ZERO(&r_fds); + FD_ZERO(&w_fds); + + /* + * Are there any timed events waiting ? If so, ensure we don't + * select for longer than it would take to wait for them. + */ + + { + struct timeval now; + GetTimeOfDay(&now); + + event_add_to_select_args(smbd_event_context(), &now, + &r_fds, &w_fds, &to, &maxfd); + } + + FD_SET(pause_pipe[1], &r_fds); + maxfd = MAX(pause_pipe[1], maxfd); + + ret = sys_select(maxfd, &r_fds, &w_fds, NULL, &to); + + /* If pause_pipe[1] is closed it means the parent smbd * and children exited or aborted. */ - if (pause_select == 1) { + if (ret == 1 && FD_ISSET(pause_pipe[1], &r_fds)) { exit_server_cleanly(NULL); } @@ -1464,15 +1496,9 @@ void start_background_queue(void) reload_after_sighup = 0; } - /* now check for messages */ - - DEBUG(10,("start_background_queue: background LPQ thread got a message\n")); - message_dispatch(smbd_messaging_context()); - - /* process any pending print change notify messages */ - - print_notify_send_messages(smbd_messaging_context(), - 0); + if (run_events(smbd_event_context(), ret, &r_fds, &w_fds)) { + continue; + } } } diff --git a/source3/smbd/globals.c b/source3/smbd/globals.c index 6fcf18d..c568122 100644 --- a/source3/smbd/globals.c +++ b/source3/smbd/globals.c @@ -175,20 +175,13 @@ char *LastDir = NULL; #if HAVE_KERNEL_OPLOCKS_LINUX SIG_ATOMIC_T oplock_signals_received = 0; SIG_ATOMIC_T fd_pending_array[FD_PENDING_SIZE]; -struct kernel_oplocks linux_koplocks; -#endif -- Samba Shared Repository