Skip to content

Commit

Permalink
*: Convert thread_add_XXX functions to event_add_XXX
Browse files Browse the repository at this point in the history
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
  • Loading branch information
donaldsharp committed Mar 24, 2023
1 parent e668514 commit 907a239
Show file tree
Hide file tree
Showing 201 changed files with 1,554 additions and 1,580 deletions.
12 changes: 8 additions & 4 deletions babeld/babeld.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,11 @@ babel_create_routing_process (void)
}

/* Threads. */
thread_add_read(master, babel_read_protocol, NULL, protocol_socket, &babel_routing_process->t_read);
event_add_read(master, babel_read_protocol, NULL, protocol_socket,
&babel_routing_process->t_read);
/* wait a little: zebra will announce interfaces, addresses, routes... */
thread_add_timer_msec(master, babel_init_routing_process, NULL, 200L, &babel_routing_process->t_update);
event_add_timer_msec(master, babel_init_routing_process, NULL, 200L,
&babel_routing_process->t_update);

/* Distribute list install. */
babel_routing_process->distribute_ctx = distribute_list_ctx_create (vrf_lookup_by_id(VRF_DEFAULT));
Expand Down Expand Up @@ -193,7 +195,8 @@ static void babel_read_protocol(struct event *thread)
}

/* re-add thread */
thread_add_read(master, &babel_read_protocol, NULL, protocol_socket, &babel_routing_process->t_read);
event_add_read(master, &babel_read_protocol, NULL, protocol_socket,
&babel_routing_process->t_read);
}

/* Zebra will give some information, especially about interfaces. This function
Expand Down Expand Up @@ -483,7 +486,8 @@ babel_set_timer(struct timeval *timeout)
{
long msecs = timeout->tv_sec * 1000 + timeout->tv_usec / 1000;
thread_cancel(&(babel_routing_process->t_update));
thread_add_timer_msec(master, babel_main_loop, NULL, msecs, &babel_routing_process->t_update);
event_add_timer_msec(master, babel_main_loop, NULL, msecs,
&babel_routing_process->t_update);
}

void
Expand Down
24 changes: 12 additions & 12 deletions bfdd/bfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1957,23 +1957,23 @@ static int bfd_vrf_enable(struct vrf *vrf)
bvrf->bg_echov6 = bp_echov6_socket(vrf);

if (!bvrf->bg_ev[0] && bvrf->bg_shop != -1)
thread_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_shop,
&bvrf->bg_ev[0]);
event_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_shop,
&bvrf->bg_ev[0]);
if (!bvrf->bg_ev[1] && bvrf->bg_mhop != -1)
thread_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_mhop,
&bvrf->bg_ev[1]);
event_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_mhop,
&bvrf->bg_ev[1]);
if (!bvrf->bg_ev[2] && bvrf->bg_shop6 != -1)
thread_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_shop6,
&bvrf->bg_ev[2]);
event_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_shop6,
&bvrf->bg_ev[2]);
if (!bvrf->bg_ev[3] && bvrf->bg_mhop6 != -1)
thread_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_mhop6,
&bvrf->bg_ev[3]);
event_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_mhop6,
&bvrf->bg_ev[3]);
if (!bvrf->bg_ev[4] && bvrf->bg_echo != -1)
thread_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_echo,
&bvrf->bg_ev[4]);
event_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_echo,
&bvrf->bg_ev[4]);
if (!bvrf->bg_ev[5] && bvrf->bg_echov6 != -1)
thread_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_echov6,
&bvrf->bg_ev[5]);
event_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_echov6,
&bvrf->bg_ev[5]);

if (vrf->vrf_id != VRF_DEFAULT) {
bfdd_zclient_register(vrf->vrf_id);
Expand Down
24 changes: 12 additions & 12 deletions bfdd/bfd_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,28 +702,28 @@ static void bfd_sd_reschedule(struct bfd_vrf_global *bvrf, int sd)
{
if (sd == bvrf->bg_shop) {
THREAD_OFF(bvrf->bg_ev[0]);
thread_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_shop,
&bvrf->bg_ev[0]);
event_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_shop,
&bvrf->bg_ev[0]);
} else if (sd == bvrf->bg_mhop) {
THREAD_OFF(bvrf->bg_ev[1]);
thread_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_mhop,
&bvrf->bg_ev[1]);
event_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_mhop,
&bvrf->bg_ev[1]);
} else if (sd == bvrf->bg_shop6) {
THREAD_OFF(bvrf->bg_ev[2]);
thread_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_shop6,
&bvrf->bg_ev[2]);
event_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_shop6,
&bvrf->bg_ev[2]);
} else if (sd == bvrf->bg_mhop6) {
THREAD_OFF(bvrf->bg_ev[3]);
thread_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_mhop6,
&bvrf->bg_ev[3]);
event_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_mhop6,
&bvrf->bg_ev[3]);
} else if (sd == bvrf->bg_echo) {
THREAD_OFF(bvrf->bg_ev[4]);
thread_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_echo,
&bvrf->bg_ev[4]);
event_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_echo,
&bvrf->bg_ev[4]);
} else if (sd == bvrf->bg_echov6) {
THREAD_OFF(bvrf->bg_ev[5]);
thread_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_echov6,
&bvrf->bg_ev[5]);
event_add_read(master, bfd_recv_cb, bvrf, bvrf->bg_echov6,
&bvrf->bg_ev[5]);
}
}

Expand Down
4 changes: 2 additions & 2 deletions bfdd/bfdd.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ int main(int argc, char *argv[])
/* Initialize zebra connection. */
bfdd_zclient_init(&bglobal.bfdd_privs);

thread_add_read(master, control_accept, NULL, bglobal.bg_csock,
&bglobal.bg_csockev);
event_add_read(master, control_accept, NULL, bglobal.bg_csock,
&bglobal.bg_csockev);

/* Install commands. */
bfdd_vty_init();
Expand Down
22 changes: 11 additions & 11 deletions bfdd/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void control_accept(struct event *t)

control_new(csock);

thread_add_read(master, control_accept, NULL, sd, &bglobal.bg_csockev);
event_add_read(master, control_accept, NULL, sd, &bglobal.bg_csockev);
}


Expand All @@ -171,7 +171,7 @@ struct bfd_control_socket *control_new(int sd)
bcs->bcs_notify = 0;

bcs->bcs_sd = sd;
thread_add_read(master, control_read, bcs, sd, &bcs->bcs_ev);
event_add_read(master, control_read, bcs, sd, &bcs->bcs_ev);

TAILQ_INIT(&bcs->bcs_bcqueue);
TAILQ_INIT(&bcs->bcs_bnplist);
Expand Down Expand Up @@ -286,8 +286,8 @@ static int control_queue_dequeue(struct bfd_control_socket *bcs)
bcs->bcs_bout = &bcq->bcq_bcb;

bcs->bcs_outev = NULL;
thread_add_write(master, control_write, bcs, bcs->bcs_sd,
&bcs->bcs_outev);
event_add_write(master, control_write, bcs, bcs->bcs_sd,
&bcs->bcs_outev);

return 1;

Expand Down Expand Up @@ -315,8 +315,8 @@ static int control_queue_enqueue(struct bfd_control_socket *bcs,
bcs->bcs_bout = bcb;

/* New messages, active write events. */
thread_add_write(master, control_write, bcs, bcs->bcs_sd,
&bcs->bcs_outev);
event_add_write(master, control_write, bcs, bcs->bcs_sd,
&bcs->bcs_outev);
}

return 0;
Expand Down Expand Up @@ -511,7 +511,7 @@ static void control_read(struct event *t)

schedule_next_read:
bcs->bcs_ev = NULL;
thread_add_read(master, control_read, bcs, sd, &bcs->bcs_ev);
event_add_read(master, control_read, bcs, sd, &bcs->bcs_ev);
}

static void control_write(struct event *t)
Expand All @@ -529,8 +529,8 @@ static void control_write(struct event *t)
if (bwrite < 0) {
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) {
bcs->bcs_outev = NULL;
thread_add_write(master, control_write, bcs,
bcs->bcs_sd, &bcs->bcs_outev);
event_add_write(master, control_write, bcs, bcs->bcs_sd,
&bcs->bcs_outev);
return;
}

Expand All @@ -543,8 +543,8 @@ static void control_write(struct event *t)
bcb->bcb_left -= bwrite;
if (bcb->bcb_left > 0) {
bcs->bcs_outev = NULL;
thread_add_write(master, control_write, bcs, bcs->bcs_sd,
&bcs->bcs_outev);
event_add_write(master, control_write, bcs, bcs->bcs_sd,
&bcs->bcs_outev);
return;
}

Expand Down
34 changes: 17 additions & 17 deletions bfdd/dplane.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,8 @@ static int bfd_dplane_enqueue(struct bfd_dplane_ctx *bdc, const void *buf,

/* Schedule if it is not yet. */
if (bdc->outbufev == NULL)
thread_add_write(master, bfd_dplane_write, bdc, bdc->sock,
&bdc->outbufev);
event_add_write(master, bfd_dplane_write, bdc, bdc->sock,
&bdc->outbufev);

return 0;
}
Expand Down Expand Up @@ -609,7 +609,7 @@ static void bfd_dplane_read(struct event *t)
return;

stream_pulldown(bdc->inbuf);
thread_add_read(master, bfd_dplane_read, bdc, bdc->sock, &bdc->inbufev);
event_add_read(master, bfd_dplane_read, bdc, bdc->sock, &bdc->inbufev);
}

static void _bfd_session_register_dplane(struct hash_bucket *hb, void *arg)
Expand Down Expand Up @@ -641,7 +641,7 @@ static struct bfd_dplane_ctx *bfd_dplane_ctx_new(int sock)
if (sock == -1)
return bdc;

thread_add_read(master, bfd_dplane_read, bdc, sock, &bdc->inbufev);
event_add_read(master, bfd_dplane_read, bdc, sock, &bdc->inbufev);

/* Register all unattached sessions. */
bfd_key_iterate(_bfd_session_register_dplane, bdc);
Expand Down Expand Up @@ -682,8 +682,8 @@ static void bfd_dplane_ctx_free(struct bfd_dplane_ctx *bdc)
socket_close(&bdc->sock);
THREAD_OFF(bdc->inbufev);
THREAD_OFF(bdc->outbufev);
thread_add_timer(master, bfd_dplane_client_connect, bdc, 3,
&bdc->connectev);
event_add_timer(master, bfd_dplane_client_connect, bdc, 3,
&bdc->connectev);
return;
}

Expand Down Expand Up @@ -840,8 +840,8 @@ static void bfd_dplane_accept(struct event *t)
zlog_debug("%s: new data plane client connected", __func__);

reschedule_and_return:
thread_add_read(master, bfd_dplane_accept, bg, bg->bg_dplane_sock,
&bglobal.bg_dplane_sockev);
event_add_read(master, bfd_dplane_accept, bg, bg->bg_dplane_sock,
&bglobal.bg_dplane_sockev);
}

/*
Expand All @@ -856,7 +856,7 @@ static void _bfd_dplane_client_bootstrap(struct bfd_dplane_ctx *bdc)
stream_reset(bdc->outbuf);

/* Ask for read notifications. */
thread_add_read(master, bfd_dplane_read, bdc, bdc->sock, &bdc->inbufev);
event_add_read(master, bfd_dplane_read, bdc, bdc->sock, &bdc->inbufev);

/* Remove all sessions then register again to send them all. */
bfd_key_iterate(_bfd_session_unregister_dplane, bdc);
Expand Down Expand Up @@ -938,8 +938,8 @@ static void bfd_dplane_client_connect(struct event *t)

/* If we are not connected yet, ask for write notifications. */
bdc->connecting = true;
thread_add_write(master, bfd_dplane_write, bdc, bdc->sock,
&bdc->outbufev);
event_add_write(master, bfd_dplane_write, bdc, bdc->sock,
&bdc->outbufev);
} else {
if (bglobal.debug_dplane)
zlog_debug("%s: server connection: %d", __func__, sock);
Expand All @@ -952,8 +952,8 @@ static void bfd_dplane_client_connect(struct event *t)
THREAD_OFF(bdc->inbufev);
THREAD_OFF(bdc->outbufev);
socket_close(&sock);
thread_add_timer(master, bfd_dplane_client_connect, bdc, 3,
&bdc->connectev);
event_add_timer(master, bfd_dplane_client_connect, bdc, 3,
&bdc->connectev);
}

static void bfd_dplane_client_init(const struct sockaddr *sa, socklen_t salen)
Expand All @@ -974,8 +974,8 @@ static void bfd_dplane_client_init(const struct sockaddr *sa, socklen_t salen)

bdc->client = true;

thread_add_timer(master, bfd_dplane_client_connect, bdc, 0,
&bdc->connectev);
event_add_timer(master, bfd_dplane_client_connect, bdc, 0,
&bdc->connectev);

/* Insert into data plane lists. */
TAILQ_INSERT_TAIL(&bglobal.bg_dplaneq, bdc, entry);
Expand Down Expand Up @@ -1067,8 +1067,8 @@ void bfd_dplane_init(const struct sockaddr *sa, socklen_t salen, bool client)
}

bglobal.bg_dplane_sock = sock;
thread_add_read(master, bfd_dplane_accept, &bglobal, sock,
&bglobal.bg_dplane_sockev);
event_add_read(master, bfd_dplane_accept, &bglobal, sock,
&bglobal.bg_dplane_sockev);
}

int bfd_dplane_add_session(struct bfd_session *bs)
Expand Down
14 changes: 7 additions & 7 deletions bfdd/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ void bfd_recvtimer_update(struct bfd_session *bs)

tv_normalize(&tv);

thread_add_timer_tv(master, bfd_recvtimer_cb, bs, &tv,
&bs->recvtimer_ev);
event_add_timer_tv(master, bfd_recvtimer_cb, bs, &tv,
&bs->recvtimer_ev);
}

void bfd_echo_recvtimer_update(struct bfd_session *bs)
Expand All @@ -54,8 +54,8 @@ void bfd_echo_recvtimer_update(struct bfd_session *bs)

tv_normalize(&tv);

thread_add_timer_tv(master, bfd_echo_recvtimer_cb, bs, &tv,
&bs->echo_recvtimer_ev);
event_add_timer_tv(master, bfd_echo_recvtimer_cb, bs, &tv,
&bs->echo_recvtimer_ev);
}

void bfd_xmttimer_update(struct bfd_session *bs, uint64_t jitter)
Expand All @@ -72,7 +72,7 @@ void bfd_xmttimer_update(struct bfd_session *bs, uint64_t jitter)

tv_normalize(&tv);

thread_add_timer_tv(master, bfd_xmt_cb, bs, &tv, &bs->xmttimer_ev);
event_add_timer_tv(master, bfd_xmt_cb, bs, &tv, &bs->xmttimer_ev);
}

void bfd_echo_xmttimer_update(struct bfd_session *bs, uint64_t jitter)
Expand All @@ -89,8 +89,8 @@ void bfd_echo_xmttimer_update(struct bfd_session *bs, uint64_t jitter)

tv_normalize(&tv);

thread_add_timer_tv(master, bfd_echo_xmt_cb, bs, &tv,
&bs->echo_xmttimer_ev);
event_add_timer_tv(master, bfd_echo_xmt_cb, bs, &tv,
&bs->echo_xmttimer_ev);
}

void bfd_recvtimer_delete(struct bfd_session *bs)
Expand Down
Loading

0 comments on commit 907a239

Please sign in to comment.