Fix crash in onMessageProcess 68/71368/1
authorKyungwook Tak <k.tak@samsung.com>
Wed, 25 May 2016 06:33:18 +0000 (15:33 +0900)
committerKyungwook Tak <k.tak@samsung.com>
Wed, 25 May 2016 06:54:46 +0000 (15:54 +0900)
Crash rarely occured when bind dtor in onMessageProcess.
Traced by gdb and there's crash when dtor std::vector(RawBuffer)
parameter.

So don't write code tightly in order to value used as rvalue for
automatically moved. Assign lvalues to inbuf/outbuf/task and move it by
std::move when needed manually.

Change-Id: I2b381331546f1b24c0c500851725376cf100a1cc
Signed-off-by: Kyungwook Tak <k.tak@samsung.com>
src/framework/service/server-service.cpp

index c8f5eb7..ac0a98a 100644 (file)
@@ -363,10 +363,16 @@ void ServerService::onMessageProcess(const ConnShPtr &connection)
                ThrowExc(InternalError, "Message from unknown sock id");
        }
 
-       m_workqueue.submit(std::bind([this, &connection, process](RawBuffer &buffer) {
-               connection->send((*process)(connection, buffer));
+       auto inbuf = connection->receive();
+       auto task = [this, &connection, process](RawBuffer &buffer) {
+               auto outbuf = (*process)(connection, buffer);
+
+               connection->send(outbuf);
+
                CpuUsageManager::reset();
-       }, connection->receive()));
+       };
+
+       m_workqueue.submit(std::bind(task, std::move(inbuf)));
 }
 
 }