From f3d13966afe27a805effba926eafbcc04fd1fd0f Mon Sep 17 00:00:00 2001 From: Alexander Vdolainen Date: Sat, 25 Jul 2015 02:37:21 +0300 Subject: [PATCH] added connection_close; --- include/sntl/sntllv2.h | 2 ++ lib/sntllv2.c | 18 ++++++++++++++++++ tests/lv2sc.c | 2 ++ 3 files changed, 22 insertions(+) diff --git a/include/sntl/sntllv2.h b/include/sntl/sntllv2.h index d8c2494..9486481 100644 --- a/include/sntl/sntllv2.h +++ b/include/sntl/sntllv2.h @@ -195,6 +195,8 @@ extern "C" { #endif /* API */ +int sntl_init(void); + int connections_init(conn_sys_t *ssys); conn_sys_t *connections_create(void); diff --git a/lib/sntllv2.c b/lib/sntllv2.c index a7f7dff..f701311 100644 --- a/lib/sntllv2.c +++ b/lib/sntllv2.c @@ -746,6 +746,7 @@ static void *__sntll_thread(void *b) } __finish: + co->flags |= SNSX_CLOSED; __connection_destroy(co); __sntll_bundle_destroy(b); /* destroy bundle */ return NULL; @@ -1143,3 +1144,20 @@ conn_t *connection_link(conn_sys_t *ssys, const char *host, return NULL; } +int connection_close(conn_t *co) +{ + sntllv2_head_t mhead; + + memset(&mhead, 0, sizeof(sntllv2_head_t)); + /* setup header */ + mhead.attr = SXMSG_LINK | SXMSG_CLOSED; + + pthread_mutex_lock(&(co->sslinout[1])); + __conn_write(co, &mhead, sizeof(sntllv2_head_t)); + pthread_mutex_unlock(&(co->sslinout[1])); + + /* we will not wait anything */ + co->flags |= SNSX_CLOSED; + + return SNE_SUCCESS; +} diff --git a/tests/lv2sc.c b/tests/lv2sc.c index b2e11b9..5e1cf4a 100644 --- a/tests/lv2sc.c +++ b/tests/lv2sc.c @@ -275,6 +275,8 @@ int main(int argc, char **argv) __wait_completion(&trd); + connection_close(co); + return 0; }