Merge branch 'devel' of https://github.com/cesnet/libnetconf2 into devel
diff --git a/.travis.yml b/.travis.yml
index 5ddb977..3375cd7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -27,11 +27,11 @@
script:
- if [ "$TRAVIS_OS_NAME" = "osx" ]; then export OPENSSLFLAGS="-DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib -DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl/include"; fi
- - cd $TRAVIS_BUILD_DIR && mkdir build_none && cd build_none ; cmake -DENABLE_TLS=OFF -DENABLE_SSH=OFF -DENABLE_DNSSEC=OFF .. && make -j2 && ctest -V
- - cd $TRAVIS_BUILD_DIR && mkdir build_tls && cd build_tls ; cmake $OPENSSLFLAGS -DENABLE_TLS=ON -DENABLE_SSH=OFF -DENABLE_DNSSEC=OFF .. && make -j2 && ctest -V
- - cd $TRAVIS_BUILD_DIR && mkdir build_ssh && cd build_ssh ; cmake $OPENSSLFLAGS -DENABLE_TLS=OFF -DENABLE_SSH=ON -DENABLE_DNSSEC=OFF .. && make -j2 && ctest -V
- - cd $TRAVIS_BUILD_DIR && mkdir build_ssh_tls && cd build_ssh_tls ; cmake $OPENSSLFLAGS -DENABLE_TLS=ON -DENABLE_SSH=ON -DENABLE_DNSSEC=OFF .. && make -j2 && ctest -V
- - cd $TRAVIS_BUILD_DIR && mkdir build_all && cd build_all ; cmake $OPENSSLFLAGS -DENABLE_TLS=ON -DENABLE_SSH=ON -DENABLE_DNSSEC=ON .. && make -j2 && ctest -V
+ - cd $TRAVIS_BUILD_DIR && mkdir build_none && cd build_none ; cmake -DENABLE_TLS=OFF -DENABLE_SSH=OFF -DENABLE_DNSSEC=OFF .. && make -j2 && ctest --output-on-failure
+ - cd $TRAVIS_BUILD_DIR && mkdir build_tls && cd build_tls ; cmake $OPENSSLFLAGS -DENABLE_TLS=ON -DENABLE_SSH=OFF -DENABLE_DNSSEC=OFF .. && make -j2 && ctest --output-on-failure
+ - cd $TRAVIS_BUILD_DIR && mkdir build_ssh && cd build_ssh ; cmake $OPENSSLFLAGS -DENABLE_TLS=OFF -DENABLE_SSH=ON -DENABLE_DNSSEC=OFF .. && make -j2 && ctest --output-on-failure
+ - cd $TRAVIS_BUILD_DIR && mkdir build_ssh_tls && cd build_ssh_tls ; cmake $OPENSSLFLAGS -DENABLE_TLS=ON -DENABLE_SSH=ON -DENABLE_DNSSEC=OFF .. && make -j2 && ctest --output-on-failure
+ - cd $TRAVIS_BUILD_DIR && mkdir build_all && cd build_all ; cmake $OPENSSLFLAGS -DENABLE_TLS=ON -DENABLE_SSH=ON -DENABLE_DNSSEC=ON .. && make -j2 && ctest --output-on-failure
- cd -
after_success:
diff --git a/src/session.c b/src/session.c
index 0a8db0e..0b11ee2 100644
--- a/src/session.c
+++ b/src/session.c
@@ -3,7 +3,7 @@
* \author Michal Vasko <mvasko@cesnet.cz>
* \brief libnetconf2 - general session functions
*
- * Copyright (c) 2015 - 2017 CESNET, z.s.p.o.
+ * Copyright (c) 2015 - 2018 CESNET, z.s.p.o.
*
* This source code is licensed under BSD 3-Clause License (the "License").
* You may not use this file except in compliance with the License.
@@ -11,11 +11,13 @@
*
* https://opensource.org/licenses/BSD-3-Clause
*/
+#define _DEFAULT_SOURCE
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include <pthread.h>
#include <sys/time.h>
#include <time.h>
@@ -450,7 +452,7 @@
API void
nc_session_free(struct nc_session *session, void (*data_free)(void *))
{
- int r, i, locked;
+ int r, i, locked, sock = -1;
int connected; /* flag to indicate whether the transport socket is still connected */
int multisession = 0; /* flag for more NETCONF sessions on a single SSH session */
pthread_t tid;
@@ -630,6 +632,8 @@
free(siter);
} while (session->ti.libssh.next != session);
}
+ /* remember sock so we can close it */
+ sock = ssh_get_fd(session->ti.libssh.session);
if (connected) {
ssh_disconnect(session->ti.libssh.session);
}
@@ -661,6 +665,9 @@
#ifdef NC_ENABLED_TLS
case NC_TI_OPENSSL:
+ /* remember sock so we can close it */
+ sock = SSL_get_fd(session->ti.tls);
+
if (connected) {
SSL_shutdown(session->ti.tls);
}
@@ -676,6 +683,11 @@
break;
}
+ /* close socket separately */
+ if (sock > -1) {
+ close(sock);
+ }
+
lydict_remove(session->ctx, session->username);
lydict_remove(session->ctx, session->host);