Skip to content

Commit

Permalink
ldpd: Do not explicitly set the thread pointer to NULL
Browse files Browse the repository at this point in the history
FRR should only ever use the appropriate THREAD_ON/THREAD_OFF
semantics.  This is espacially true for the functions we
end up calling the thread for.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
  • Loading branch information
ton31337 committed Oct 4, 2021
1 parent c34d552 commit dc4a902
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 21 deletions.
4 changes: 0 additions & 4 deletions ldpd/accept.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ accept_add(int fd, int (*cb)(struct thread *), void *arg)
av->arg = arg;
LIST_INSERT_HEAD(&accept_queue.queue, av, entry);

av->ev = NULL;
thread_add_read(master, accept_cb, av, av->fd, &av->ev);

log_debug("%s: accepting on fd %d", __func__, fd);
Expand Down Expand Up @@ -86,7 +85,6 @@ accept_pause(void)
{
log_debug(__func__);
accept_unarm();
accept_queue.evt = NULL;
thread_add_timer(master, accept_timeout, NULL, 1, &accept_queue.evt);
}

Expand All @@ -105,7 +103,6 @@ accept_arm(void)
{
struct accept_ev *av;
LIST_FOREACH(av, &accept_queue.queue, entry) {
av->ev = NULL;
thread_add_read(master, accept_cb, av, av->fd, &av->ev);
}
}
Expand All @@ -122,7 +119,6 @@ static int
accept_cb(struct thread *thread)
{
struct accept_ev *av = THREAD_ARG(thread);
av->ev = NULL;
thread_add_read(master, accept_cb, av, av->fd, &av->ev);
av->accept_cb(thread);

Expand Down
1 change: 0 additions & 1 deletion ldpd/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,6 @@ static void
if_start_hello_timer(struct iface_af *ia)
{
thread_cancel(&ia->hello_timer);
ia->hello_timer = NULL;
thread_add_timer(master, if_hello_timer, ia, if_get_hello_interval(ia),
&ia->hello_timer);
}
Expand Down
2 changes: 0 additions & 2 deletions ldpd/lde.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ lde(void)
fatal(NULL);
imsg_init(&iev_main->ibuf, LDPD_FD_ASYNC);
iev_main->handler_read = lde_dispatch_parent;
iev_main->ev_read = NULL;
thread_add_read(master, iev_main->handler_read, iev_main, iev_main->ibuf.fd,
&iev_main->ev_read);
iev_main->handler_write = ldp_write_handler;
Expand Down Expand Up @@ -555,7 +554,6 @@ lde_dispatch_parent(struct thread *thread)
fatal(NULL);
imsg_init(&iev_ldpe->ibuf, fd);
iev_ldpe->handler_read = lde_dispatch_imsg;
iev_ldpe->ev_read = NULL;
thread_add_read(master, iev_ldpe->handler_read, iev_ldpe, iev_ldpe->ibuf.fd,
&iev_ldpe->ev_read);
iev_ldpe->handler_write = ldp_write_handler;
Expand Down
1 change: 0 additions & 1 deletion ldpd/lde_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,6 @@ void
lde_gc_start_timer(void)
{
thread_cancel(&gc_timer);
gc_timer = NULL;
thread_add_timer(master, lde_gc_timer, NULL, LDE_GC_INTERVAL,
&gc_timer);
}
Expand Down
4 changes: 0 additions & 4 deletions ldpd/ldpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,28 +403,24 @@ main(int argc, char *argv[])
fatal(NULL);
imsg_init(&iev_ldpe->ibuf, pipe_parent2ldpe[0]);
iev_ldpe->handler_read = main_dispatch_ldpe;
iev_ldpe->ev_read = NULL;
thread_add_read(master, iev_ldpe->handler_read, iev_ldpe, iev_ldpe->ibuf.fd,
&iev_ldpe->ev_read);
iev_ldpe->handler_write = ldp_write_handler;

imsg_init(&iev_ldpe_sync->ibuf, pipe_parent2ldpe_sync[0]);
iev_ldpe_sync->handler_read = main_dispatch_ldpe;
iev_ldpe_sync->ev_read = NULL;
thread_add_read(master, iev_ldpe_sync->handler_read, iev_ldpe_sync, iev_ldpe_sync->ibuf.fd,
&iev_ldpe_sync->ev_read);
iev_ldpe_sync->handler_write = ldp_write_handler;

imsg_init(&iev_lde->ibuf, pipe_parent2lde[0]);
iev_lde->handler_read = main_dispatch_lde;
iev_lde->ev_read = NULL;
thread_add_read(master, iev_lde->handler_read, iev_lde, iev_lde->ibuf.fd,
&iev_lde->ev_read);
iev_lde->handler_write = ldp_write_handler;

imsg_init(&iev_lde_sync->ibuf, pipe_parent2lde_sync[0]);
iev_lde_sync->handler_read = main_dispatch_lde;
iev_lde_sync->ev_read = NULL;
thread_add_read(master, iev_lde_sync->handler_read, iev_lde_sync, iev_lde_sync->ibuf.fd,
&iev_lde_sync->ev_read);
iev_lde_sync->handler_write = ldp_write_handler;
Expand Down
6 changes: 0 additions & 6 deletions ldpd/ldpe.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ ldpe(void)
fatal(NULL);
imsg_init(&iev_main->ibuf, LDPD_FD_ASYNC);
iev_main->handler_read = ldpe_dispatch_main;
iev_main->ev_read = NULL;
thread_add_read(master, iev_main->handler_read, iev_main, iev_main->ibuf.fd,
&iev_main->ev_read);
iev_main->handler_write = ldp_write_handler;
Expand All @@ -149,7 +148,6 @@ ldpe_init(struct ldpd_init *init)
/* This socket must be open before dropping privileges. */
global.pfkeysock = pfkey_init();
if (sysdep.no_pfkey == 0) {
pfkey_ev = NULL;
thread_add_read(master, ldpe_dispatch_pfkey, NULL, global.pfkeysock,
&pfkey_ev);
}
Expand Down Expand Up @@ -377,7 +375,6 @@ ldpe_dispatch_main(struct thread *thread)
fatal(NULL);
imsg_init(&iev_lde->ibuf, fd);
iev_lde->handler_read = ldpe_dispatch_lde;
iev_lde->ev_read = NULL;
thread_add_read(master, iev_lde->handler_read, iev_lde, iev_lde->ibuf.fd,
&iev_lde->ev_read);
iev_lde->handler_write = ldp_write_handler;
Expand Down Expand Up @@ -784,7 +781,6 @@ ldpe_dispatch_pfkey(struct thread *thread)
{
int fd = THREAD_FD(thread);

pfkey_ev = NULL;
thread_add_read(master, ldpe_dispatch_pfkey, NULL, global.pfkeysock,
&pfkey_ev);

Expand All @@ -805,13 +801,11 @@ ldpe_setup_sockets(int af, int disc_socket, int edisc_socket,

/* discovery socket */
af_global->ldp_disc_socket = disc_socket;
af_global->disc_ev = NULL;
thread_add_read(master, disc_recv_packet, &af_global->disc_ev, af_global->ldp_disc_socket,
&af_global->disc_ev);

/* extended discovery socket */
af_global->ldp_edisc_socket = edisc_socket;
af_global->edisc_ev = NULL;
thread_add_read(master, disc_recv_packet, &af_global->edisc_ev, af_global->ldp_edisc_socket,
&af_global->edisc_ev);

Expand Down
3 changes: 0 additions & 3 deletions ldpd/packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ disc_recv_packet(struct thread *thread)
struct in_addr lsr_id;

/* reschedule read */
*threadp = NULL;
thread_add_read(master, disc_recv_packet, threadp, fd, threadp);

/* setup buffer */
Expand Down Expand Up @@ -425,7 +424,6 @@ session_read(struct thread *thread)
uint16_t pdu_len, msg_len, msg_size, max_pdu_len;
int ret;

tcp->rev = NULL;
thread_add_read(master, session_read, nbr, fd, &tcp->rev);

if ((n = read(fd, tcp->rbuf->buf + tcp->rbuf->wpos,
Expand Down Expand Up @@ -745,7 +743,6 @@ tcp_new(int fd, struct nbr *nbr)
if ((tcp->rbuf = calloc(1, sizeof(struct ibuf_read))) == NULL)
fatal(__func__);

tcp->rev = NULL;
thread_add_read(master, session_read, nbr, tcp->fd, &tcp->rev);
tcp->nbr = nbr;
}
Expand Down

0 comments on commit dc4a902

Please sign in to comment.