1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-27 22:50:26 +03:00

s3:events: change event_add_timed() prototype to match samba4

metze
This commit is contained in:
Stefan Metzmacher 2009-01-05 10:22:50 +01:00
parent ee5be748e6
commit c34d5f445a
18 changed files with 60 additions and 80 deletions

View File

@ -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,

View File

@ -103,12 +103,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);
@ -139,7 +139,7 @@ bool async_post_status(struct async_req *req, struct event_context *ev,
{
req->status = status;
if (event_add_timed(ev, req, timeval_zero(), "async_trigger",
if (event_add_timed(ev, req, timeval_zero(),
async_trigger, req) == NULL) {
return false;
}
@ -197,7 +197,7 @@ NTSTATUS async_req_simple_recv(struct async_req *req)
static void async_req_timedout(struct event_context *ev,
struct timed_event *te,
const struct timeval *now,
struct timeval now,
void *priv)
{
struct async_req *req = talloc_get_type_abort(
@ -211,7 +211,7 @@ bool async_req_set_timeout(struct async_req *req, struct event_context *ev,
{
return (event_add_timed(ev, req,
timeval_current_ofs(to.tv_sec, to.tv_usec),
"async_req_timedout", async_req_timedout, req)
async_req_timedout, req)
!= NULL);
}
@ -268,7 +268,7 @@ static int async_queue_entry_destructor(struct async_queue_entry *e)
static void async_req_immediate_trigger(struct event_context *ev,
struct timed_event *te,
const struct timeval *now,
struct timeval now,
void *priv)
{
struct async_queue_entry *e = talloc_get_type_abort(
@ -303,7 +303,6 @@ bool async_req_enqueue(struct async_req_queue *queue, struct event_context *ev,
struct timed_event *te;
te = event_add_timed(ev, e, timeval_zero(),
"async_req_immediate_trigger",
async_req_immediate_trigger,
e);
if (te == NULL) {

View File

@ -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(
@ -383,7 +383,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) {

View File

@ -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;

View File

@ -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;
}

View File

@ -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);

View File

@ -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 {

View File

@ -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);
}

View File

@ -457,7 +457,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;
@ -486,7 +486,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);
}

View File

@ -68,7 +68,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);
@ -123,7 +123,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;
}

View File

@ -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);
}

View File

@ -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) {

View File

@ -583,26 +583,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);
@ -637,14 +644,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;
}

View File

@ -248,7 +248,7 @@ static int evt_userdata_tostring(lua_State *L) {
static void evt_userdata_sleep_done(struct event_context *event_ctx,
struct timed_event *te,
const struct timeval *now,
struct timeval now,
void *priv)
{
struct thread_reference *ref = talloc_get_type_abort(
@ -279,7 +279,7 @@ static int evt_userdata_sleep(lua_State *L)
}
te = event_add_timed(p->ev, ref, timeval_current_ofs(0, usecs),
"evt_userdata_sleep", evt_userdata_sleep_done,
evt_userdata_sleep_done,
ref);
if (te == NULL) {

View File

@ -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;
}

View File

@ -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);

View File

@ -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 =
@ -163,7 +163,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;
@ -242,7 +241,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;
@ -275,7 +273,6 @@ done:
expire_time -= 10;
entry->event = event_add_timed(winbind_event_context(), entry,
timeval_set(expire_time, 0),
"krb5_ticket_gain_handler",
krb5_ticket_gain_handler,
entry);
return;
@ -286,7 +283,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);
@ -299,7 +295,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 =
@ -375,7 +371,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);
@ -395,7 +390,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);
@ -419,14 +413,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);
}
@ -556,7 +548,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 {
@ -569,7 +560,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);
}
@ -644,7 +634,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 {
@ -660,7 +649,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);
}

View File

@ -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);
}