diff --git a/apps/restconf/restconf_main_native.c b/apps/restconf/restconf_main_native.c index acc889d0..e257ac34 100644 --- a/apps/restconf/restconf_main_native.c +++ b/apps/restconf/restconf_main_native.c @@ -591,15 +591,7 @@ restconf_close_ssl_socket(restconf_conn *rc, { int retval = -1; int ret; -#ifdef HAVE_LIBEVHTP - evhtp_connection_t *evconn; - if ((evconn = rc->rc_evconn) != NULL){ - clicon_debug(1, "%s evconn-free (%p)", __FUNCTION__, evconn); - if (evconn) - evhtp_connection_free(evconn); /* evhtp */ - } -#endif /* HAVE_LIBEVHTP */ if (rc->rc_ssl != NULL){ if (shutdown && (ret = SSL_shutdown(rc->rc_ssl)) < 0){ #if 0 @@ -762,7 +754,6 @@ restconf_connection(int s, clixon_event_unreg_fd(rc->rc_s, restconf_connection); clicon_debug(1, "%s evconn-free (%p) 2", __FUNCTION__, evconn); restconf_conn_free(rc); - evhtp_connection_free(evconn); goto ok; } /* connection_parse_nobev */ clicon_debug(1, "%s connection_parse OK", __FUNCTION__); @@ -998,15 +989,7 @@ ssl_alpn_check(clicon_handle h, /* XXX Sending badrequest here gives a segv in SSL_shutdown() later or a SIGPIPE here */ clicon_log(LOG_NOTICE, "Warning: ALPN: No protocol selected"); } - restconf_conn_free(rc); -#ifdef HAVE_LIBEVHTP - { - evhtp_connection_t *evconn; - if ((evconn = rc->rc_evconn) != NULL) - evhtp_connection_free(evconn); /* evhtp */ - } -#endif /* HAVE_LIBEVHTP */ if (rc->rc_ssl){ /* nmap ssl-known-key SEGV at s->method->ssl_shutdown(s); * OR OpenSSL error: : SSL_shutdown, err: SSL_ERROR_SYSCALL(5) @@ -1024,6 +1007,7 @@ ssl_alpn_check(clicon_handle h, } SSL_free(rc->rc_ssl); } + restconf_conn_free(rc); } retval = 0; /* ALPN not OK */ done: diff --git a/apps/restconf/restconf_native.c b/apps/restconf/restconf_native.c index 9bd1ff86..92cb3a3c 100644 --- a/apps/restconf/restconf_native.c +++ b/apps/restconf/restconf_native.c @@ -177,6 +177,14 @@ restconf_conn_free(restconf_conn *rc) clicon_err(OE_RESTCONF, EINVAL, "rc is NULL"); return -1; } +#ifdef HAVE_LIBNGHTTP2 + if (rc->rc_ngsession) + nghttp2_session_del(rc->rc_ngsession); +#endif +#ifdef HAVE_LIBEVHTP + if (rc->rc_evconn) + evhtp_connection_free(rc->rc_evconn); /* evhtp */ +#endif /* Free all streams */ while ((sd = rc->rc_streams) != NULL) { DELQ(sd, rc->rc_streams, restconf_stream_data *); diff --git a/apps/restconf/restconf_nghttp2.c b/apps/restconf/restconf_nghttp2.c index d990b592..9360de89 100644 --- a/apps/restconf/restconf_nghttp2.c +++ b/apps/restconf/restconf_nghttp2.c @@ -397,7 +397,7 @@ restconf_submit_response(nghttp2_session *session, nghttp2_data_provider data_prd; nghttp2_error ngerr; cg_var *cv; - nghttp2_nv *hdrs; + nghttp2_nv *hdrs = NULL; nghttp2_nv *hdr; int i = 0; char valstr[16]; @@ -437,6 +437,8 @@ restconf_submit_response(nghttp2_session *session, retval = 0; done: clicon_debug(1, "%s retval:%d", __FUNCTION__, retval); + if (hdrs) + free(hdrs); return retval; } @@ -933,7 +935,7 @@ http2_session_init(restconf_conn *rc) nghttp2_session_callbacks_set_error_callback2(callbacks, error_callback2); /* Create session for server use, register callbacks */ - if ((ngerr = nghttp2_session_server_new(&session, callbacks, rc)) < 0){ + if ((ngerr = nghttp2_session_server_new3(&session, callbacks, rc, NULL, NULL)) < 0){ clicon_err(OE_NGHTTP2, ngerr, "nghttp2_session_server_new"); goto done; } diff --git a/test/all.sh b/test/all.sh index 15785356..4580b734 100755 --- a/test/all.sh +++ b/test/all.sh @@ -32,6 +32,7 @@ for test in $pattern; do testfile=$test . ./$test errcode=$? + endsuite if [ $errcode -ne 0 ]; then allerr=1 echo -e "\e[31mError in $test errcode=$errcode" diff --git a/test/lib.sh b/test/lib.sh index a2c35fc8..258d5cd5 100755 --- a/test/lib.sh +++ b/test/lib.sh @@ -432,6 +432,7 @@ function wait_restconf_stopped(){ } # End of test, final tests before normal exit of test +# Note this is a single test started by new, not a total test suite function endtest() { if [ $valgrindtest -eq 1 ]; then @@ -448,6 +449,12 @@ function new(){ >&2 echo "Test $testi($testnr) [$1]" } +# End of complete test-suite, eg a test file +function endsuite() +{ + unset CURLOPTS +} + # Evaluate and return # Example: expectpart $(fn arg) 0 "my return" -- "foo" # - evaluated expression diff --git a/test/mem.sh b/test/mem.sh index 30648a09..42e2667e 100755 --- a/test/mem.sh +++ b/test/mem.sh @@ -58,6 +58,7 @@ function memonce(){ testfile=$test . ./$test errcode=$? + endsuite if [ $errcode -ne 0 ]; then memerr=1 echo -e "\e[31mError in $test errcode=$errcode" diff --git a/test/test_restconf_nmap.sh b/test/test_restconf_nmap.sh index 6aff68ea..bdea1c59 100755 --- a/test/test_restconf_nmap.sh +++ b/test/test_restconf_nmap.sh @@ -116,12 +116,7 @@ fi new "wait backend" wait_backend -#new "netconf edit config" -#expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO$RESTCONFIG]]>]]>" "^]]>]]>$" - -#new "netconf commit" -#expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" - +# Explicit start of restconf for easier debugging if [ $RC -ne 0 ]; then new "kill old restconf daemon" stop_restconf_pre