From a632a1bcd694cff03de3456dac582800e94c451e Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 6 Jan 2009 11:22:08 -0800 Subject: [PATCH] s3:events: change event_add_timed() prototype to match samba4 metze --- source/include/event.h | 6 ++++-- source/lib/async_req.c | 5 ++--- source/lib/ctdbd_conn.c | 3 +-- source/lib/events.c | 8 ++++---- source/lib/smbldap.c | 12 ++++++------ source/modules/vfs_aio_fork.c | 6 ++---- source/nmbd/nmbd_processlogon.c | 3 +-- source/printing/notify.c | 3 +-- source/rpc_server/srv_samr_nt.c | 3 +-- source/smbd/blocking.c | 4 ++-- source/smbd/fileio.c | 3 +-- source/smbd/oplock.c | 3 +-- source/smbd/process.c | 27 +++++++++++++++++---------- source/utils/smbcontrol.c | 7 +++---- source/winbindd/winbindd_cm.c | 6 ++---- source/winbindd/winbindd_cred_cache.c | 18 +++--------------- source/winbindd/winbindd_dual.c | 11 +++-------- 17 files changed, 54 insertions(+), 74 deletions(-) diff --git a/source/include/event.h b/source/include/event.h index 0d5e559fb7c..3d40000cb84 100644 --- a/source/include/event.h +++ b/source/include/event.h @@ -28,15 +28,17 @@ struct timed_event; /* The following definitions come from lib/events.c */ -struct timed_event *event_add_timed(struct event_context *event_ctx, +struct timed_event *_event_add_timed(struct event_context *event_ctx, TALLOC_CTX *mem_ctx, struct timeval when, const char *event_name, void (*handler)(struct event_context *event_ctx, struct timed_event *te, - const struct timeval *now, + struct timeval now, void *private_data), void *private_data); +#define event_add_timed(event_ctx, mem_ctx, when, handler, private_data) \ + _event_add_timed(event_ctx, mem_ctx, when, #handler, handler, private_data) struct fd_event *event_add_fd(struct event_context *event_ctx, TALLOC_CTX *mem_ctx, int fd, uint16_t flags, diff --git a/source/lib/async_req.c b/source/lib/async_req.c index 501a6b5524f..e8c1935a773 100644 --- a/source/lib/async_req.c +++ b/source/lib/async_req.c @@ -104,12 +104,12 @@ void async_req_error(struct async_req *req, NTSTATUS status) * @brief Timed event callback * @param[in] ev Event context * @param[in] te The timed event - * @param[in] now current time + * @param[in] now zero time * @param[in] priv The async request to be finished */ static void async_trigger(struct event_context *ev, struct timed_event *te, - const struct timeval *now, void *priv) + struct timeval now, void *priv) { struct async_req *req = talloc_get_type_abort(priv, struct async_req); @@ -140,7 +140,6 @@ bool async_post_status(struct async_req *req, NTSTATUS status) req->status = status; if (event_add_timed(req->event_ctx, req, timeval_zero(), - "async_trigger", async_trigger, req) == NULL) { return false; } diff --git a/source/lib/ctdbd_conn.c b/source/lib/ctdbd_conn.c index 424c316f931..1b07fd407a5 100644 --- a/source/lib/ctdbd_conn.c +++ b/source/lib/ctdbd_conn.c @@ -200,7 +200,7 @@ struct deferred_msg_state { static void deferred_message_dispatch(struct event_context *event_ctx, struct timed_event *te, - const struct timeval *now, + struct timeval now, void *private_data) { struct deferred_msg_state *state = talloc_get_type_abort( @@ -386,7 +386,6 @@ static NTSTATUS ctdb_read_req(struct ctdbd_connection *conn, uint32 reqid, evt = event_add_timed(conn->msg_ctx->event_ctx, conn->msg_ctx->event_ctx, timeval_zero(), - "deferred_message_dispatch", deferred_message_dispatch, msg_state); if (evt == NULL) { diff --git a/source/lib/events.c b/source/lib/events.c index d4b9648609e..0dd87279088 100644 --- a/source/lib/events.c +++ b/source/lib/events.c @@ -27,7 +27,7 @@ struct timed_event { const char *event_name; void (*handler)(struct event_context *event_ctx, struct timed_event *te, - const struct timeval *now, + struct timeval now, void *private_data); void *private_data; }; @@ -88,13 +88,13 @@ static void add_event_by_time(struct timed_event *te) handed to it. ****************************************************************************/ -struct timed_event *event_add_timed(struct event_context *event_ctx, +struct timed_event *_event_add_timed(struct event_context *event_ctx, TALLOC_CTX *mem_ctx, struct timeval when, const char *event_name, void (*handler)(struct event_context *event_ctx, struct timed_event *te, - const struct timeval *now, + struct timeval now, void *private_data), void *private_data) { @@ -241,7 +241,7 @@ bool run_events(struct event_context *event_ctx, event_ctx->timed_events->handler( event_ctx, - event_ctx->timed_events, &now, + event_ctx->timed_events, now, event_ctx->timed_events->private_data); fired = True; diff --git a/source/lib/smbldap.c b/source/lib/smbldap.c index 9c2ee3aecd3..8e7ecdfcb04 100644 --- a/source/lib/smbldap.c +++ b/source/lib/smbldap.c @@ -1014,7 +1014,7 @@ static int smbldap_connect_system(struct smbldap_state *ldap_state, LDAP * ldap_ static void smbldap_idle_fn(struct event_context *event_ctx, struct timed_event *te, - const struct timeval *now, + struct timeval now, void *private_data); /********************************************************************** @@ -1079,7 +1079,7 @@ static int smbldap_open(struct smbldap_state *ldap_state) ldap_state->idle_event = event_add_timed( ldap_state->event_context, NULL, timeval_current_ofs(SMBLDAP_IDLE_TIME, 0), - "smbldap_idle_fn", smbldap_idle_fn, ldap_state); + smbldap_idle_fn, ldap_state); } DEBUG(4,("The LDAP server is successfully connected\n")); @@ -1572,7 +1572,7 @@ int smbldap_search_suffix (struct smbldap_state *ldap_state, static void smbldap_idle_fn(struct event_context *event_ctx, struct timed_event *te, - const struct timeval *now, + struct timeval now, void *private_data) { struct smbldap_state *state = (struct smbldap_state *)private_data; @@ -1584,13 +1584,13 @@ static void smbldap_idle_fn(struct event_context *event_ctx, return; } - if ((state->last_use+SMBLDAP_IDLE_TIME) > now->tv_sec) { + if ((state->last_use+SMBLDAP_IDLE_TIME) > now.tv_sec) { DEBUG(10,("ldap connection not idle...\n")); state->idle_event = event_add_timed( event_ctx, NULL, - timeval_add(now, SMBLDAP_IDLE_TIME, 0), - "smbldap_idle_fn", smbldap_idle_fn, + timeval_add(&now, SMBLDAP_IDLE_TIME, 0), + smbldap_idle_fn, private_data); return; } diff --git a/source/modules/vfs_aio_fork.c b/source/modules/vfs_aio_fork.c index 7914e8f4014..30b14f280f2 100644 --- a/source/modules/vfs_aio_fork.c +++ b/source/modules/vfs_aio_fork.c @@ -216,7 +216,7 @@ static ssize_t write_fd(int fd, void *ptr, size_t nbytes, int sendfd) static void aio_child_cleanup(struct event_context *event_ctx, struct timed_event *te, - const struct timeval *now, + struct timeval now, void *private_data) { struct aio_child_list *list = talloc_get_type_abort( @@ -252,8 +252,7 @@ static void aio_child_cleanup(struct event_context *event_ctx, * Re-schedule the next cleanup round */ list->cleanup_event = event_add_timed(smbd_event_context(), list, - timeval_add(now, 30, 0), - "aio_child_cleanup", + timeval_add(&now, 30, 0), aio_child_cleanup, list); } @@ -284,7 +283,6 @@ static struct aio_child_list *init_aio_children(struct vfs_handle_struct *handle if (data->cleanup_event == NULL) { data->cleanup_event = event_add_timed(smbd_event_context(), data, timeval_current_ofs(30, 0), - "aio_child_cleanup", aio_child_cleanup, data); if (data->cleanup_event == NULL) { TALLOC_FREE(data); diff --git a/source/nmbd/nmbd_processlogon.c b/source/nmbd/nmbd_processlogon.c index 814eaf7ca84..54e868ac299 100644 --- a/source/nmbd/nmbd_processlogon.c +++ b/source/nmbd/nmbd_processlogon.c @@ -52,7 +52,7 @@ static bool delay_logon(const char *peer_name, const char *peer_addr) static void delayed_init_logon_handler(struct event_context *event_ctx, struct timed_event *te, - const struct timeval *now, + struct timeval now, void *private_data) { struct packet_struct *p = (struct packet_struct *)private_data; @@ -657,7 +657,6 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n", event_add_timed(nmbd_event_context(), NULL, when, - "delayed_init_logon", delayed_init_logon_handler, p); } else { diff --git a/source/printing/notify.c b/source/printing/notify.c index b24a8a52f59..860a400d649 100644 --- a/source/printing/notify.c +++ b/source/printing/notify.c @@ -221,7 +221,7 @@ void print_notify_send_messages(struct messaging_context *msg_ctx, static void print_notify_event_send_messages(struct event_context *event_ctx, struct timed_event *te, - const struct timeval *now, + struct timeval now, void *private_data) { /* Remove this timed event handler. */ @@ -326,7 +326,6 @@ to notify_queue_head\n", msg->type, msg->field, msg->printer)); /* Add an event for 1 second's time to send this queue. */ notify_event = event_add_timed(smbd_event_context(), NULL, timeval_current_ofs(1,0), - "print_notify", print_notify_event_send_messages, NULL); } diff --git a/source/rpc_server/srv_samr_nt.c b/source/rpc_server/srv_samr_nt.c index 2c27f309a78..7b2fe6fd824 100644 --- a/source/rpc_server/srv_samr_nt.c +++ b/source/rpc_server/srv_samr_nt.c @@ -454,7 +454,7 @@ static void free_samr_info(void *ptr) static void disp_info_cache_idle_timeout_handler(struct event_context *ev_ctx, struct timed_event *te, - const struct timeval *now, + struct timeval now, void *private_data) { DISP_INFO *disp_info = (DISP_INFO *)private_data; @@ -483,7 +483,6 @@ static void set_disp_info_cache_timeout(DISP_INFO *disp_info, time_t secs_fromno disp_info->cache_timeout_event = event_add_timed( smbd_event_context(), NULL, timeval_current_ofs(secs_fromnow, 0), - "disp_info_cache_idle_timeout_handler", disp_info_cache_idle_timeout_handler, (void *)disp_info); } diff --git a/source/smbd/blocking.c b/source/smbd/blocking.c index 479361a8c10..2c37fea496d 100644 --- a/source/smbd/blocking.c +++ b/source/smbd/blocking.c @@ -81,7 +81,7 @@ static void process_blocking_lock_queue(void); static void brl_timeout_fn(struct event_context *event_ctx, struct timed_event *te, - const struct timeval *now, + struct timeval now, void *private_data) { SMB_ASSERT(brl_timeout == te); @@ -136,7 +136,7 @@ static bool recalc_brl_timeout(void) } if (!(brl_timeout = event_add_timed(smbd_event_context(), NULL, - next_timeout, "brl_timeout", + next_timeout, brl_timeout_fn, NULL))) { return False; } diff --git a/source/smbd/fileio.c b/source/smbd/fileio.c index e67f926a049..30253d44664 100644 --- a/source/smbd/fileio.c +++ b/source/smbd/fileio.c @@ -173,7 +173,7 @@ static int wcp_file_size_change(files_struct *fsp) static void update_write_time_handler(struct event_context *ctx, struct timed_event *te, - const struct timeval *now, + struct timeval now, void *private_data) { files_struct *fsp = (files_struct *)private_data; @@ -221,7 +221,6 @@ void trigger_write_time_update(struct files_struct *fsp) fsp->update_write_time_event = event_add_timed(smbd_event_context(), NULL, timeval_current_ofs(0, delay), - "update_write_time_handler", update_write_time_handler, fsp); } diff --git a/source/smbd/oplock.c b/source/smbd/oplock.c index 4b3ab962f90..37747c728ac 100644 --- a/source/smbd/oplock.c +++ b/source/smbd/oplock.c @@ -346,7 +346,7 @@ static files_struct *initial_break_processing(struct file_id id, unsigned long f static void oplock_timeout_handler(struct event_context *ctx, struct timed_event *te, - const struct timeval *now, + struct timeval now, void *private_data) { files_struct *fsp = (files_struct *)private_data; @@ -373,7 +373,6 @@ static void add_oplock_timeout_handler(files_struct *fsp) fsp->oplock_timeout = event_add_timed(smbd_event_context(), NULL, timeval_current_ofs(OPLOCK_BREAK_TIMEOUT, 0), - "oplock_timeout_handler", oplock_timeout_handler, fsp); if (fsp->oplock_timeout == NULL) { diff --git a/source/smbd/process.c b/source/smbd/process.c index 31840634625..aeb0fc48a3d 100644 --- a/source/smbd/process.c +++ b/source/smbd/process.c @@ -578,26 +578,33 @@ struct idle_event { void *private_data; }; -static void idle_event_handler(struct event_context *ctx, - struct timed_event *te, - const struct timeval *now, - void *private_data) +static void smbd_idle_event_handler(struct event_context *ctx, + struct timed_event *te, + struct timeval now, + void *private_data) { struct idle_event *event = talloc_get_type_abort(private_data, struct idle_event); TALLOC_FREE(event->te); - if (!event->handler(now, event->private_data)) { + DEBUG(10,("smbd_idle_event_handler: %s %p called\n", + event->name, event->te)); + + if (!event->handler(&now, event->private_data)) { + DEBUG(10,("smbd_idle_event_handler: %s %p stopped\n", + event->name, event->te)); /* Don't repeat, delete ourselves */ TALLOC_FREE(event); return; } + DEBUG(10,("smbd_idle_event_handler: %s %p rescheduled\n", + event->name, event->te)); + event->te = event_add_timed(ctx, event, - timeval_sum(now, &event->interval), - event->name, - idle_event_handler, event); + timeval_sum(&now, &event->interval), + smbd_idle_event_handler, event); /* We can't do much but fail here. */ SMB_ASSERT(event->te != NULL); @@ -632,14 +639,14 @@ struct idle_event *event_add_idle(struct event_context *event_ctx, result->te = event_add_timed(event_ctx, result, timeval_sum(&now, &interval), - result->name, - idle_event_handler, result); + smbd_idle_event_handler, result); if (result->te == NULL) { DEBUG(0, ("event_add_timed failed\n")); TALLOC_FREE(result); return NULL; } + DEBUG(10,("event_add_idle: %s %p\n", result->name, result->te)); return result; } diff --git a/source/utils/smbcontrol.c b/source/utils/smbcontrol.c index 750030d9166..962d1191727 100644 --- a/source/utils/smbcontrol.c +++ b/source/utils/smbcontrol.c @@ -65,9 +65,9 @@ static bool send_message(struct messaging_context *msg_ctx, return ret; } -static void timeout_handler(struct event_context *event_ctx, +static void smbcontrol_timeout(struct event_context *event_ctx, struct timed_event *te, - const struct timeval *now, + struct timeval now, void *private_data) { bool *timed_out = (bool *)private_data; @@ -85,8 +85,7 @@ static void wait_replies(struct messaging_context *msg_ctx, if (!(te = event_add_timed(messaging_event_context(msg_ctx), NULL, timeval_current_ofs(timeout, 0), - "smbcontrol_timeout", - timeout_handler, (void *)&timed_out))) { + smbcontrol_timeout, (void *)&timed_out))) { DEBUG(0, ("event_add_timed failed\n")); return; } diff --git a/source/winbindd/winbindd_cm.c b/source/winbindd/winbindd_cm.c index c22beb42d24..c2b7fdbc593 100644 --- a/source/winbindd/winbindd_cm.c +++ b/source/winbindd/winbindd_cm.c @@ -272,7 +272,7 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain) static void check_domain_online_handler(struct event_context *ctx, struct timed_event *te, - const struct timeval *now, + struct timeval now, void *private_data) { struct winbindd_domain *domain = @@ -286,7 +286,7 @@ static void check_domain_online_handler(struct event_context *ctx, /* Are we still in "startup" mode ? */ - if (domain->startup && (now->tv_sec > domain->startup_time + 30)) { + if (domain->startup && (now.tv_sec > domain->startup_time + 30)) { /* No longer in "startup" mode. */ DEBUG(10,("check_domain_online_handler: domain %s no longer in 'startup' mode.\n", domain->name )); @@ -367,7 +367,6 @@ void set_domain_offline(struct winbindd_domain *domain) domain->check_online_event = event_add_timed(winbind_event_context(), NULL, timeval_current_ofs(domain->check_online_timeout,0), - "check_domain_online_handler", check_domain_online_handler, domain); @@ -518,7 +517,6 @@ void set_domain_online_request(struct winbindd_domain *domain) domain->check_online_event = event_add_timed(winbind_event_context(), NULL, tev, - "check_domain_online_handler", check_domain_online_handler, domain); diff --git a/source/winbindd/winbindd_cred_cache.c b/source/winbindd/winbindd_cred_cache.c index 15e948c7419..a922a04894f 100644 --- a/source/winbindd/winbindd_cred_cache.c +++ b/source/winbindd/winbindd_cred_cache.c @@ -36,7 +36,7 @@ static struct WINBINDD_CCACHE_ENTRY *ccache_list; static void krb5_ticket_gain_handler(struct event_context *, struct timed_event *, - const struct timeval *, + struct timeval, void *); /* The Krb5 ticket refresh handler should be scheduled @@ -95,7 +95,7 @@ void ccache_remove_all_after_fork(void) static void krb5_ticket_refresh_handler(struct event_context *event_ctx, struct timed_event *te, - const struct timeval *now, + struct timeval now, void *private_data) { struct WINBINDD_CCACHE_ENTRY *entry = @@ -165,7 +165,6 @@ rekinit: entry->event = event_add_timed(winbind_event_context(), entry, timeval_set(new_start, 0), - "krb5_ticket_gain_handler", krb5_ticket_gain_handler, entry); return; @@ -246,7 +245,6 @@ rekinit: entry->event = event_add_timed(winbind_event_context(), entry, timeval_set(new_start, 0), - "krb5_ticket_gain_handler", krb5_ticket_gain_handler, entry); return; @@ -280,7 +278,6 @@ done: entry->refresh_time = 0; entry->event = event_add_timed(winbind_event_context(), entry, timeval_set(expire_time, 0), - "krb5_ticket_gain_handler", krb5_ticket_gain_handler, entry); return; @@ -291,7 +288,6 @@ done: } entry->event = event_add_timed(winbind_event_context(), entry, timeval_set(new_start, 0), - "krb5_ticket_refresh_handler", krb5_ticket_refresh_handler, entry); @@ -304,7 +300,7 @@ done: static void krb5_ticket_gain_handler(struct event_context *event_ctx, struct timed_event *te, - const struct timeval *now, + struct timeval now, void *private_data) { struct WINBINDD_CCACHE_ENTRY *entry = @@ -380,7 +376,6 @@ static void krb5_ticket_gain_handler(struct event_context *event_ctx, entry->event = event_add_timed(winbind_event_context(), entry, t, - "krb5_ticket_gain_handler", krb5_ticket_gain_handler, entry); @@ -400,7 +395,6 @@ static void krb5_ticket_gain_handler(struct event_context *event_ctx, entry->event = event_add_timed(winbind_event_context(), entry, t, - "krb5_ticket_refresh_handler", krb5_ticket_refresh_handler, entry); @@ -424,14 +418,12 @@ void ccache_regain_all_now(void) new_event = event_add_timed(winbind_event_context(), cur, t, - "krb5_ticket_gain_handler", krb5_ticket_gain_handler, cur); } else { new_event = event_add_timed(winbind_event_context(), cur, t, - "krb5_ticket_refresh_handler", krb5_ticket_refresh_handler, cur); } @@ -562,7 +554,6 @@ NTSTATUS add_ccache_to_list(const char *princ_name, entry->event = event_add_timed(winbind_event_context(), entry, t, - "krb5_ticket_gain_handler", krb5_ticket_gain_handler, entry); } else { @@ -578,7 +569,6 @@ NTSTATUS add_ccache_to_list(const char *princ_name, entry->event = event_add_timed(winbind_event_context(), entry, t, - "krb5_ticket_refresh_handler", krb5_ticket_refresh_handler, entry); } @@ -653,7 +643,6 @@ NTSTATUS add_ccache_to_list(const char *princ_name, entry->event = event_add_timed(winbind_event_context(), entry, t, - "krb5_ticket_gain_handler", krb5_ticket_gain_handler, entry); } else { @@ -669,7 +658,6 @@ NTSTATUS add_ccache_to_list(const char *princ_name, entry->event = event_add_timed(winbind_event_context(), entry, t, - "krb5_ticket_refresh_handler", krb5_ticket_refresh_handler, entry); } diff --git a/source/winbindd/winbindd_dual.c b/source/winbindd/winbindd_dual.c index 7fe003b173f..96ce673d8cf 100644 --- a/source/winbindd/winbindd_dual.c +++ b/source/winbindd/winbindd_dual.c @@ -175,7 +175,7 @@ static void async_main_request_sent(void *private_data, bool success) static void async_request_timeout_handler(struct event_context *ctx, struct timed_event *te, - const struct timeval *now, + struct timeval now, void *private_data) { struct winbindd_async_request *state = @@ -247,7 +247,6 @@ static void async_request_sent(void *private_data_data, bool success) state->reply_timeout_event = event_add_timed(winbind_event_context(), NULL, timeval_current_ofs(300,0), - "async_request_timeout", async_request_timeout_handler, state); if (!state->reply_timeout_event) { @@ -827,7 +826,7 @@ void winbind_msg_dump_domain_list(struct messaging_context *msg_ctx, static void account_lockout_policy_handler(struct event_context *ctx, struct timed_event *te, - const struct timeval *now, + struct timeval now, void *private_data) { struct winbindd_child *child = @@ -866,7 +865,6 @@ static void account_lockout_policy_handler(struct event_context *ctx, child->lockout_policy_event = event_add_timed(winbind_event_context(), NULL, timeval_current_ofs(3600, 0), - "account_lockout_policy_handler", account_lockout_policy_handler, child); } @@ -919,7 +917,7 @@ static bool calculate_next_machine_pwd_change(const char *domain, static void machine_password_change_handler(struct event_context *ctx, struct timed_event *te, - const struct timeval *now, + struct timeval now, void *private_data) { struct winbindd_child *child = @@ -971,7 +969,6 @@ static void machine_password_change_handler(struct event_context *ctx, child->machine_password_change_event = event_add_timed(winbind_event_context(), NULL, next_change, - "machine_password_change_handler", machine_password_change_handler, child); } @@ -1293,7 +1290,6 @@ static bool fork_domain_child(struct winbindd_child *child) child->lockout_policy_event = event_add_timed( winbind_event_context(), NULL, timeval_zero(), - "account_lockout_policy_handler", account_lockout_policy_handler, child); } @@ -1308,7 +1304,6 @@ static bool fork_domain_child(struct winbindd_child *child) &next_change)) { child->machine_password_change_event = event_add_timed( winbind_event_context(), NULL, next_change, - "machine_password_change_handler", machine_password_change_handler, child); } -- 2.11.4.GIT