Github user parthchandra commented on a diff in the pull request:

    https://github.com/apache/drill/pull/950#discussion_r142830326
  
    --- Diff: contrib/native/client/src/clientlib/drillClientImpl.cpp ---
    @@ -250,7 +205,15 @@ void DrillClientImpl::doWriteToSocket(const char* 
dataPtr, size_t bytesToWrite,
         // Write all the bytes to socket. In case of error when all bytes are 
not successfully written
         // proper errorCode will be set.
         while(1) {
    -        size_t bytesWritten = 
m_socket.write_some(boost::asio::buffer(dataPtr, bytesToWrite), errorCode);
    +        size_t bytesWritten;
    +        {
    +            boost::lock_guard<boost::mutex> lock(m_channelMutex);
    --- End diff --
    
    Oh this was found by Rob Wu. The problem occurs when the heartbeat timer 
has gone off and we are in the handler which is about to send off a heartbeat. 
Before the heartbeat is sent if the caller deletes DrillClientImpl (via 
DrillClient) then the channel may be closed and the pointer to the channel may 
be set to null causing the heartbeat send to crash. This did not occur 
previously because the socket was not a pointer and/or boost was able to handle 
it quite nicely. 


---

Reply via email to