From 1acb16d1cc7281265da9c82fc873656acdcc354e Mon Sep 17 00:00:00 2001 From: kmook Date: Thu, 22 Dec 2016 13:50:50 +0900 Subject: [PATCH] Fixed mismatch alloc/dealloc, thread id checking routine Change-Id: I5aaa95714b92d47af507d8cb635afce4bb689513 Signed-off-by: kmook --- msf_tizen_client/include/Channel.h | 2 +- msf_tizen_client/src/Channel.cpp | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/msf_tizen_client/include/Channel.h b/msf_tizen_client/include/Channel.h index b2c6e30..d3def87 100755 --- a/msf_tizen_client/include/Channel.h +++ b/msf_tizen_client/include/Channel.h @@ -277,7 +277,7 @@ private: SendBufList sendBufQueue; bool closeRequest; - pthread_t serverThreadId; + pthread_t socketThreadId; static int msgId; static pthread_t connect_thread; diff --git a/msf_tizen_client/src/Channel.cpp b/msf_tizen_client/src/Channel.cpp index 31979ef..814fd74 100755 --- a/msf_tizen_client/src/Channel.cpp +++ b/msf_tizen_client/src/Channel.cpp @@ -94,7 +94,7 @@ Channel::Channel() { eventType = ""; resultobj = NULL; pthread_mutex_init(&sendBufMutex, NULL); - serverThreadId = pthread_self(); + socketThreadId = -1; closeRequest = false; } @@ -122,7 +122,7 @@ Channel::Channel(Service *service1, string uri1) { eventType = ""; resultobj = NULL; pthread_mutex_init(&sendBufMutex, NULL); - serverThreadId = pthread_self(); + socketThreadId = -1; closeRequest = false; } @@ -179,7 +179,7 @@ Channel::~Channel() { // cleanup write buffer if ((sendBuf != NULL)) { - free(sendBuf); + delete[] sendBuf; sendBuf = NULL; } } @@ -863,7 +863,7 @@ int Channel::writeSocket(Channel* ch_p) } // cleanup write buffer if ((sendBuf != NULL)) { - free(sendBuf); + delete[] sendBuf; sendBuf = NULL; } } @@ -1362,6 +1362,8 @@ void Channel::createWebsocket(void *att) { info.options = (1 << 12); info.user = this; + socketThreadId = pthread_self(); + #ifndef LWS_NO_EXTENSIONS // info.extensions = lws_get_internal_extensions(); #endif @@ -1431,8 +1433,8 @@ void Channel::createWebsocket(void *att) { void Channel::writeRequest() { lws_callback_on_writable(wsi_mirror); - if (pthread_self() != serverThreadId) { - MSF_DBG("current thread is different from websocket server thread => lws_cancel_service()"); + if (pthread_self() != socketThreadId) { + MSF_DBG("current thread is different from websocket thread => lws_cancel_service()"); lws_cancel_service(lws_get_context(wsi_mirror)); // to exit from poll() inside of lws_service() } } -- 2.7.4