Fixed mismatch alloc/dealloc, thread id checking routine 44/106544/1 accepted/tizen/common/20161227.192155 accepted/tizen/mobile/20161226.131420 accepted/tizen/tv/20161226.131433 accepted/tizen/wearable/20161226.131452 submit/tizen/20161226.041041
authorkmook <kmook.choi@samsung.com>
Thu, 22 Dec 2016 04:50:50 +0000 (13:50 +0900)
committerkmook <kmook.choi@samsung.com>
Thu, 22 Dec 2016 04:50:50 +0000 (13:50 +0900)
Change-Id: I5aaa95714b92d47af507d8cb635afce4bb689513
Signed-off-by: kmook <kmook.choi@samsung.com>
msf_tizen_client/include/Channel.h
msf_tizen_client/src/Channel.cpp

index b2c6e30..d3def87 100755 (executable)
@@ -277,7 +277,7 @@ private:
        SendBufList sendBufQueue;
 
        bool closeRequest;
-       pthread_t serverThreadId;
+       pthread_t socketThreadId;
        static int msgId;
 
        static pthread_t connect_thread;
index 31979ef..814fd74 100755 (executable)
@@ -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()
        }
 }