Skip to content

Commit

Permalink
Merge pull request FRRouting#13847 from opensourcerouting/fix/free_zc…
Browse files Browse the repository at this point in the history
…lient_sync_on_destroy

Stop and free synchronous Zebra client on destroy
  • Loading branch information
donaldsharp authored Jul 1, 2023
2 parents 69a826c + a5c9e19 commit 1f322e4
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ldpd/lde.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static struct list *label_chunk_list;
static struct listnode *current_label_chunk;

/* Synchronous zclient to request labels */
static struct zclient *zclient_sync;
struct zclient *zclient_sync;

/* SIGINT / SIGTERM handler. */
static void
Expand Down
7 changes: 7 additions & 0 deletions ldpd/ldp_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ static int ldp_zebra_opaque_msg_handler(ZAPI_CALLBACK_ARGS);
static void ldp_sync_zebra_init(void);

static struct zclient *zclient;
extern struct zclient *zclient_sync;
static bool zebra_registered = false;

static void
Expand Down Expand Up @@ -703,4 +704,10 @@ ldp_zebra_destroy(void)
zclient_stop(zclient);
zclient_free(zclient);
zclient = NULL;

if (zclient_sync == NULL)
return;
zclient_stop(zclient_sync);
zclient_free(zclient_sync);
zclient_sync = NULL;
}
2 changes: 1 addition & 1 deletion ospfd/ospf_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ DEFINE_MTYPE_STATIC(OSPFD, OSPF_REDISTRIBUTE, "OSPF Redistriute");
/* Zebra structure to hold current status. */
struct zclient *zclient = NULL;
/* and for the Synchronous connection to the Label Manager */
static struct zclient *zclient_sync;
struct zclient *zclient_sync;

/* For registering threads. */
extern struct event_loop *master;
Expand Down
3 changes: 3 additions & 0 deletions ospfd/ospfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ struct ospf_master *om;
unsigned short ospf_instance;

extern struct zclient *zclient;
extern struct zclient *zclient_sync;

/* OSPF config processing timer thread */
struct event *t_ospf_cfg;
Expand Down Expand Up @@ -683,6 +684,8 @@ void ospf_terminate(void)
*/
zclient_stop(zclient);
zclient_free(zclient);
zclient_stop(zclient_sync);
zclient_free(zclient_sync);

done:
frr_fini();
Expand Down
2 changes: 2 additions & 0 deletions pathd/path_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,6 @@ void path_zebra_stop(void)
{
zclient_stop(zclient);
zclient_free(zclient);
zclient_stop(zclient_sync);
zclient_free(zclient_sync);
}

0 comments on commit 1f322e4

Please sign in to comment.