summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>2021-08-12 14:05:38 +0700
committerSaya Sugiura <39760799+ssugiura@users.noreply.github.com>2021-10-05 11:19:26 +0900
commitbca4804feaed8e5a5363972a6ac05e0f9586cee9 (patch)
treeb3342418735cef504c7bace52e4a9bef994d8821
parent031e7e596c0d34ff5e7b9da2d430679b3013cc91 (diff)
downloadDLT-daemon-bca4804feaed8e5a5363972a6ac05e0f9586cee9.tar.gz
dlt-control-common: shutdown and close socket
Before cancelling the listening thread, try to shutdown and close the socket so that the listening thread is terminated intentionally Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
-rw-r--r--src/console/dlt-control-common.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/console/dlt-control-common.c b/src/console/dlt-control-common.c
index 96a15a2..abcaf92 100644
--- a/src/console/dlt-control-common.c
+++ b/src/console/dlt-control-common.c
@@ -630,6 +630,15 @@ int dlt_control_init(int (*response_analyzer)(char *, void *, int),
*/
int dlt_control_deinit(void)
{
+ /* At this stage, we want to stop sending/receiving
+ * from dlt-daemon. So in order to avoid cancellation
+ * at recv(), shutdown and close the socket
+ */
+ if (g_client.receiver.fd) {
+ shutdown(g_client.receiver.fd, SHUT_RDWR);
+ close(g_client.receiver.fd);
+ g_client.receiver.fd = -1;
+ }
/* Stopping the listener thread */
pthread_cancel(daemon_connect_thread);
pthread_join(daemon_connect_thread, NULL);