summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>2021-08-12 14:05:38 +0700
committerSaya Sugiura <ssugiura@jp.adit-jv.com>2021-10-05 11:07:37 +0900
commitd438bca9d53afb524ca07bf8b323faa7c2be654b (patch)
treeb3342418735cef504c7bace52e4a9bef994d8821
parenteb5a25459021b1ea8e188592f128a6ddc1604e87 (diff)
downloadDLT-daemon-d438bca9d53afb524ca07bf8b323faa7c2be654b.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);