Fix restart of restconf processes

This commit is contained in:
Olof hagsand 2021-02-01 10:44:50 +01:00
parent f65efa3e5e
commit 40008f182e
5 changed files with 77 additions and 35 deletions

View file

@ -529,24 +529,6 @@ restconf_pseudo_process_commit(clicon_handle h,
return retval;
}
static int
restconf_pseudo_reset(clicon_handle h,
const char *db)
{
int retval = -1;
cxobj *xt = NULL;
/* Get data as xml from db1 */
if (xmldb_get(h, (char*)db, NULL, "/restconf[enable='true']", &xt) < 0)
goto done;
if (xt && xml_child_nr(xt))
if (clixon_process_operation(h, RESTCONF_PROCESS, "start", 0, NULL) < 0)
goto done;
retval = 0;
done:
return retval;
}
/*! Register start/stop restconf RPC and create pseudo-plugin to monitor enable flag
* @param[in] h Clixon handle
*/
@ -559,7 +541,6 @@ restconf_pseudo_process_reg(clicon_handle h,
if (clixon_pseudo_plugin(h, "restconf pseudo plugin", &cp) < 0)
goto done;
cp->cp_api.ca_reset = restconf_pseudo_reset;
cp->cp_api.ca_trans_commit = restconf_pseudo_process_commit;
cp->cp_api.ca_trans_validate = restconf_pseudo_process_validate;
@ -1054,6 +1035,8 @@ main(int argc,
goto done;
case SM_NONE: /* Fall through *
* Load plugins and call plugin_init() */
if (clixon_plugin_reset_all(h, "running") < 0)
goto done;
status = STARTUP_OK;
break;
case SM_RUNNING: /* Use running as startup */
@ -1099,7 +1082,10 @@ main(int argc,
*/
if (status == STARTUP_OK){
if (startup_mode == SM_NONE){
if (clixon_plugin_reset_all(h, "running") < 0)
/* Special case for mode none: no commits are made therefore need to run
* start all processes
*/
if (clixon_process_start_all(h) < 0)
goto done;
}
else {

View file

@ -645,6 +645,7 @@ restconf_socket_init(const char *netns0,
size_t sin_len;
const char *netns;
clicon_debug(1, "%s %s %s %s", __FUNCTION__, netns0, addrtype, addr);
/* netns default -> NULL */
if (netns0 != NULL && strcmp(netns0, "default")==0)
netns = NULL;
@ -674,6 +675,7 @@ restconf_socket_init(const char *netns0,
goto done;
retval = 0;
done:
clicon_debug(1, "%s %d", __FUNCTION__, retval);
return retval;
}
@ -854,6 +856,7 @@ cx_evhtp_socket(clicon_handle h,
int ss = -1;
evhtp_t *htp = NULL;
clicon_debug(1, "%s", __FUNCTION__);
/* This is socket create a new evhtp_t instance */
if ((htp = evhtp_new(eh->eh_evbase, NULL)) == NULL){
clicon_err(OE_UNIX, errno, "evhtp_new");
@ -911,6 +914,7 @@ cx_evhtp_socket(clicon_handle h,
goto done;
retval = 0;
done:
clicon_debug(1, "%s %d", __FUNCTION__, retval);
return retval;
}
@ -920,7 +924,7 @@ cx_evhtp_socket(clicon_handle h,
* @param[in] nsc Namespace context
* @param[in] eh Evhtp handle
* @retval -1 Error
* @retval 0 OK, but restconf disenabled, proceed with other if possible
* @retval 0 OK, but restconf disabled, proceed with other if possible
* @retval 1 OK
*/
static int
@ -942,10 +946,13 @@ cx_evhtp_init(clicon_handle h,
cxobj *x;
int i;
clicon_debug(1, "%s", __FUNCTION__);
if ((x = xpath_first(xrestconf, nsc, "enable")) != NULL &&
(enable = xml_body(x)) != NULL){
if (strcmp(enable, "false") == 0)
if (strcmp(enable, "false") == 0){
clicon_debug(1, "%s restconf disabled", __FUNCTION__);
goto disable;
}
}
/* If at least one socket has ssl then enable global ssl_enable */
ssl_enable = xpath_first(xrestconf, nsc, "socket[ssl='true']") != NULL;
@ -997,6 +1004,7 @@ cx_evhtp_init(clicon_handle h,
}
retval = 1;
done:
clicon_debug(1, "%s %d", __FUNCTION__, retval);
if (vec)
free(vec);
return retval;