void Socket::WantToDisconnect() { sLog.outError(" Socket::WantToDisconnect() entered"); if(!m_bConnected || m_bWantToDisconnect) { sLog.outError(" already \"in waiting\" or \"disconnected\""); return; } m_bWantToDisconnect = true; sLog.outError(" m_bWantToDisconnect = true"); sLog.outError(" try LockWriting"); LockWriting(); sLog.outError(" Locked"); if(m_SendAllowed) { sLog.outError(" sending allowed."); if(event_add(&m_ev_write, NULL) == -1) { sLog.outError(" Couldn't disconnect socket.", GetSocket()); UnlockWriting(); // Disconnect();//Forcibly return; } else { m_SendAllowed = false; sLog.outError(" we add send event."); } } else { sLog.outError(" sending is not allowed."); } sLog.outError(" try UnlockWriting"); UnlockWriting(); sLog.outError(" Unlocked"); sLog.outError(" Socket::WantToDisconnect() finished"); }