datastore handles

This commit is contained in:
Olof hagsand 2017-04-15 19:42:35 +02:00
parent d8fa7bc033
commit 540cd96e74
21 changed files with 286 additions and 146 deletions

View file

@ -77,7 +77,7 @@
/*! Terminate. Cannot use h after this */
static int
config_terminate(clicon_handle h)
backend_terminate(clicon_handle h)
{
yang_spec *yspec;
char *pidfile = clicon_backend_pidfile(h);
@ -91,6 +91,7 @@ config_terminate(clicon_handle h)
unlink(pidfile);
if (sockpath)
unlink(sockpath);
xmldb_plugin_unload(h); /* unload storage plugin */
backend_handle_exit(h); /* Cannot use h after this */
event_exit();
clicon_log_register_callback(NULL, NULL);
@ -101,7 +102,7 @@ config_terminate(clicon_handle h)
/*! Unlink pidfile and quit
*/
static void
config_sig_term(int arg)
backend_sig_term(int arg)
{
static int i=0;
@ -238,11 +239,11 @@ server_socket(clicon_handle h)
int ss;
/* Open control socket */
if ((ss = config_socket_init(h)) < 0)
if ((ss = backend_socket_init(h)) < 0)
return -1;
/* ss is a server socket that the clients connect to. The callback
therefore accepts clients on ss */
if (event_reg_fd(ss, config_accept_client, h, "server socket") < 0) {
if (event_reg_fd(ss, backend_accept_client, h, "server socket") < 0) {
close(ss);
return -1;
}
@ -254,9 +255,9 @@ server_socket(clicon_handle h)
* log event.
*/
static int
config_log_cb(int level,
char *msg,
void *arg)
backend_log_cb(int level,
char *msg,
void *arg)
{
int retval = -1;
size_t n;
@ -320,7 +321,7 @@ main(int argc, char **argv)
/* Initiate CLICON handle */
if ((h = backend_handle_init()) == NULL)
return -1;
if (config_plugin_init(h) != 0)
if (backend_plugin_init(h) != 0)
return -1;
foreground = 0;
once = 0;
@ -623,14 +624,14 @@ main(int argc, char **argv)
goto done;
/* Register log notifications */
if (clicon_log_register_callback(config_log_cb, h) < 0)
if (clicon_log_register_callback(backend_log_cb, h) < 0)
goto done;
clicon_log(LOG_NOTICE, "%s: %u Started", __PROGRAM__, getpid());
if (set_signal(SIGTERM, config_sig_term, NULL) < 0){
if (set_signal(SIGTERM, backend_sig_term, NULL) < 0){
clicon_err(OE_DEMON, errno, "Setting signal");
goto done;
}
if (set_signal(SIGINT, config_sig_term, NULL) < 0){
if (set_signal(SIGINT, backend_sig_term, NULL) < 0){
clicon_err(OE_DEMON, errno, "Setting signal");
goto done;
}
@ -646,7 +647,7 @@ main(int argc, char **argv)
goto done;
done:
clicon_log(LOG_NOTICE, "%s: %u Terminated", __PROGRAM__, getpid());
config_terminate(h); /* Cannot use h after this */
backend_terminate(h); /* Cannot use h after this */
return 0;
}

View file

@ -132,7 +132,7 @@ config_find_plugin(clicon_handle h,
* @retval -1 Error
*/
int
config_plugin_init(clicon_handle h)
backend_plugin_init(clicon_handle h)
{
find_plugin_t *fp = config_find_plugin;
clicon_hash_t *data = clicon_data(h);

View file

@ -62,7 +62,7 @@ typedef struct {
/*
* Prototypes
*/
int config_plugin_init(clicon_handle h);
int backend_plugin_init(clicon_handle h);
int plugin_initiate(clicon_handle h);
int plugin_finish(clicon_handle h);

View file

@ -174,7 +174,7 @@ config_socket_init_unix(clicon_handle h, char *sock)
}
int
config_socket_init(clicon_handle h)
backend_socket_init(clicon_handle h)
{
char *sock;
@ -197,7 +197,7 @@ config_socket_init(clicon_handle h)
* XXX: credentials not properly implemented
*/
int
config_accept_client(int fd,
backend_accept_client(int fd,
void *arg)
{
int retval = -1;

View file

@ -40,7 +40,7 @@
/*
* Prototypes
*/
int config_socket_init(clicon_handle h);
int config_accept_client(int fd, void *arg);
int backend_socket_init(clicon_handle h);
int backend_accept_client(int fd, void *arg);
#endif /* _BACKEND_SOCKET_H_ */

View file

@ -85,7 +85,6 @@ struct backend_handle {
int bh_magic; /* magic (HDR)*/
clicon_hash_t *bh_copt; /* clicon option list (HDR) */
clicon_hash_t *bh_data; /* internal clicon data (HDR) */
void *bh_xmldb; /* XMLDB storage handle, uie xmldb_handle */
/* ------ end of common handle ------ */
struct client_entry *bh_ce_list; /* The client list */
int bh_ce_nr; /* Number of clients, just increment */