* Event exit API changed to a single decrementing counter where 1 means exit.
* Removed: `clicon_exit_reset()` * Changed: `clicon_exit_set()` --> `clixon_exit_set(int nr)` * Changed: `clicon_exit_get()` --> `clixon_exit_get()` * native restconf special case upgrade handling from http/1 -> http/2 and restconf restart: delay the restart using event exit counter
This commit is contained in:
parent
4f513385e9
commit
b40dafb691
10 changed files with 63 additions and 36 deletions
|
|
@ -154,7 +154,7 @@ backend_sig_term(int arg)
|
|||
if (i++ == 0)
|
||||
clicon_log(LOG_NOTICE, "%s: %s: pid: %u Signal %d",
|
||||
__PROGRAM__, __FUNCTION__, getpid(), arg);
|
||||
clicon_exit_set(); /* checked in clixon_event_loop() */
|
||||
clixon_exit_set(1); /* checked in clixon_event_loop() */
|
||||
}
|
||||
|
||||
/*! wait for killed child
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ restconf_sig_term(int arg)
|
|||
* is entered, it will terminate.
|
||||
* However there may be a case of sockets closing rather abruptly for clients
|
||||
*/
|
||||
clicon_exit_set();
|
||||
clixon_exit_set(1);
|
||||
close(_MYSOCK);
|
||||
}
|
||||
|
||||
|
|
@ -623,7 +623,7 @@ main(int argc,
|
|||
goto done;
|
||||
if (finish)
|
||||
FCGX_Finish_r(req);
|
||||
else if (clicon_exit_get()){
|
||||
else if (clixon_exit_get()){
|
||||
FCGX_Finish_r(req);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -849,6 +849,17 @@ restconf_connection(int s,
|
|||
/* Use params from original http/1 session to http/2 stream */
|
||||
if (http2_exec(rc, sd, rc->rc_ngsession, 1) < 0)
|
||||
goto done;
|
||||
/*
|
||||
* Very special case for http/1->http/2 upgrade and restconf "restart"
|
||||
* That is, the restconf daemon is restarted under the hood, and the session
|
||||
* is closed in mid-step: it needs a couple of extra rounds to complete the http/2
|
||||
* settings before it completes.
|
||||
* Maybe a more precise way would be to encode that semantics using recieved http/2
|
||||
* frames instead of just postponing nrof events?
|
||||
*/
|
||||
if (clixon_exit_get() == 1){
|
||||
clixon_exit_set(4);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
|
@ -1790,7 +1801,7 @@ restconf_sig_term(int arg)
|
|||
* is entered, it will terminate.
|
||||
* However there may be a case of sockets closing rather abruptly for clients
|
||||
*/
|
||||
clicon_exit_set();
|
||||
clixon_exit_set(1);
|
||||
}
|
||||
|
||||
/*! Usage help routine
|
||||
|
|
|
|||
|
|
@ -402,7 +402,6 @@ restconf_submit_response(nghttp2_session *session,
|
|||
int i = 0;
|
||||
char valstr[16];
|
||||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
data_prd.source.ptr = sd;
|
||||
data_prd.read_callback = restconf_sd_read;
|
||||
if ((hdrs = (nghttp2_nv*)calloc(1+cvec_len(sd->sd_outp_hdrs), sizeof(nghttp2_nv))) == NULL){
|
||||
|
|
@ -412,6 +411,7 @@ restconf_submit_response(nghttp2_session *session,
|
|||
hdr = &hdrs[i++];
|
||||
hdr->name = (uint8_t*)":status";
|
||||
snprintf(valstr, 15, "%u", sd->sd_code);
|
||||
clicon_debug(1, "%s status %d", __FUNCTION__, sd->sd_code);
|
||||
hdr->value = (uint8_t*)valstr;
|
||||
hdr->namelen = strlen(":status");
|
||||
hdr->valuelen = strlen(valstr);
|
||||
|
|
@ -421,6 +421,7 @@ restconf_submit_response(nghttp2_session *session,
|
|||
while ((cv = cvec_each(sd->sd_outp_hdrs, cv)) != NULL){
|
||||
hdr = &hdrs[i++];
|
||||
hdr->name = (uint8_t*)cv_name_get(cv);
|
||||
clicon_debug(1, "%s hdr: %s", __FUNCTION__, hdr->name);
|
||||
hdr->value = (uint8_t*)cv_string_get(cv);
|
||||
hdr->namelen = strlen(cv_name_get(cv));
|
||||
hdr->valuelen = strlen(cv_string_get(cv));
|
||||
|
|
@ -435,6 +436,7 @@ restconf_submit_response(nghttp2_session *session,
|
|||
}
|
||||
retval = 0;
|
||||
done:
|
||||
clicon_debug(1, "%s retval:%d", __FUNCTION__, retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
@ -448,6 +450,7 @@ http2_exec(restconf_conn *rc,
|
|||
{
|
||||
int retval = -1;
|
||||
|
||||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
if ((sd->sd_path = restconf_uripath(rc->rc_h)) == NULL)
|
||||
goto done;
|
||||
sd->sd_proto = HTTP_2; /* XXX is this necessary? */
|
||||
|
|
@ -475,9 +478,9 @@ http2_exec(restconf_conn *rc,
|
|||
else {
|
||||
/* 500 Internal server error ? */
|
||||
}
|
||||
|
||||
retval = 0;
|
||||
done:
|
||||
clicon_debug(1, "%s retval:%d", __FUNCTION__, retval);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -190,7 +190,7 @@ restconf_stream_cb(int s,
|
|||
FCGX_FPrintF(r->out, "SHUTDOWN\r\n");
|
||||
FCGX_FPrintF(r->out, "\r\n");
|
||||
FCGX_FFlush(r->out);
|
||||
clicon_exit_set();
|
||||
clixon_exit_set(1);
|
||||
goto done;
|
||||
}
|
||||
if ((ret = clicon_msg_decode(reply, NULL, NULL, &xtop, NULL)) < 0) /* XXX pass yang_spec */
|
||||
|
|
@ -335,7 +335,7 @@ stream_checkuplink(int s,
|
|||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
if (FCGX_GetError(r->out) != 0){ /* break loop */
|
||||
clicon_debug(1, "%s FCGX_GetError upstream", __FUNCTION__);
|
||||
clicon_exit_set();
|
||||
clixon_exit_set(1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -351,7 +351,7 @@ stream_timeout(int s,
|
|||
clicon_debug(1, "%s", __FUNCTION__);
|
||||
if (FCGX_GetError(r->out) != 0){ /* break loop */
|
||||
clicon_debug(1, "%s FCGX_GetError upstream", __FUNCTION__);
|
||||
clicon_exit_set();
|
||||
clixon_exit_set(1);
|
||||
}
|
||||
else{
|
||||
gettimeofday(&t, NULL);
|
||||
|
|
@ -485,7 +485,7 @@ api_stream(clicon_handle h,
|
|||
clixon_event_unreg_fd(rfcgi->listen_sock,
|
||||
restconf_stream_cb);
|
||||
clixon_event_unreg_timeout(stream_timeout, (void*)req);
|
||||
clicon_exit_reset();
|
||||
clixon_exit_set(0); /* reset */
|
||||
#ifdef STREAM_FORK
|
||||
FCGX_Finish_r(rfcgi);
|
||||
FCGX_Free(rfcgi, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue