FST: Make fst_global_deinit() more robust
Verify that fst_global_init() has been called before deinitializing the global FST context. This makes it a bit easier to handle failure paths from initialization. Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
0b1b2044cc
commit
976dfb3237
1 changed files with 6 additions and 0 deletions
|
@ -15,6 +15,7 @@
|
||||||
#include "fst/fst_defs.h"
|
#include "fst/fst_defs.h"
|
||||||
#include "fst/fst_ctrl_iface.h"
|
#include "fst/fst_ctrl_iface.h"
|
||||||
|
|
||||||
|
static int fst_global_initialized = 0;
|
||||||
struct dl_list fst_global_ctrls_list;
|
struct dl_list fst_global_ctrls_list;
|
||||||
|
|
||||||
|
|
||||||
|
@ -106,6 +107,7 @@ int fst_global_init(void)
|
||||||
dl_list_init(&fst_global_groups_list);
|
dl_list_init(&fst_global_groups_list);
|
||||||
dl_list_init(&fst_global_ctrls_list);
|
dl_list_init(&fst_global_ctrls_list);
|
||||||
fst_session_global_init();
|
fst_session_global_init();
|
||||||
|
fst_global_initialized = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +117,9 @@ void fst_global_deinit(void)
|
||||||
struct fst_group *group;
|
struct fst_group *group;
|
||||||
struct fst_ctrl_handle *h;
|
struct fst_ctrl_handle *h;
|
||||||
|
|
||||||
|
if (!fst_global_initialized)
|
||||||
|
return;
|
||||||
|
|
||||||
fst_session_global_deinit();
|
fst_session_global_deinit();
|
||||||
while ((group = fst_first_group()) != NULL)
|
while ((group = fst_first_group()) != NULL)
|
||||||
fst_group_delete(group);
|
fst_group_delete(group);
|
||||||
|
@ -122,6 +127,7 @@ void fst_global_deinit(void)
|
||||||
struct fst_ctrl_handle,
|
struct fst_ctrl_handle,
|
||||||
global_ctrls_lentry)))
|
global_ctrls_lentry)))
|
||||||
fst_global_del_ctrl(h);
|
fst_global_del_ctrl(h);
|
||||||
|
fst_global_initialized = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue