From: John L. <jr...@us...> - 2007-05-19 17:14:17
|
Update of /cvsroot/wxlua/wxLua/modules/wxluasocket/src In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv1533/wxLua/modules/wxluasocket/src Modified Files: wxldserv.cpp wxldtarg.cpp wxlsock.cpp Log Message: Fix server to work in MSW for the wxLua IDE Index: wxldtarg.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/src/wxldtarg.cpp,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** wxldtarg.cpp 19 May 2007 02:05:47 -0000 1.34 --- wxldtarg.cpp 19 May 2007 17:14:13 -0000 1.35 *************** *** 34,38 **** { m_pTarget->ThreadFunction(); ! m_pTarget->m_pThread = NULL; return 0; } --- 34,38 ---- { m_pTarget->ThreadFunction(); ! //m_pTarget->m_pThread = NULL; return 0; } Index: wxldserv.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/src/wxldserv.cpp,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** wxldserv.cpp 19 May 2007 02:05:47 -0000 1.37 --- wxldserv.cpp 19 May 2007 17:14:13 -0000 1.38 *************** *** 216,220 **** m_port_number); ! m_debuggeeProcessID = wxExecute(command, wxEXEC_ASYNC|wxEXEC_MAKE_GROUP_LEADER, m_debuggeeProcess); if (m_debuggeeProcessID < 1) --- 216,220 ---- m_port_number); ! m_debuggeeProcessID = wxExecute(command, wxEXEC_ASYNC, m_debuggeeProcess); if (m_debuggeeProcessID < 1) *************** *** 360,367 **** --- 360,373 ---- } + //extern wxString wxLuaSocketCmdEventMsg(int val); + int wxLuaDebuggerBase::HandleDebuggeeEvent(int event_type) { wxCHECK_MSG(GetSocketBase(), event_type, wxT("Invalid socket")); + //wxLuaDebuggerEvent d(wxEVT_WXLUA_DEBUGGER_PRINT, this); + //d.SetMessage(wxT("wxLuaDebugger : ") + wxLuaSocketCmdEventMsg(event_type)); + //SendEvent(d); + switch (event_type) { *************** *** 756,766 **** m_fShutdown = true; ! // close the session socket ! if (m_acceptedSocket != NULL) { ! if (!m_acceptedSocket->Shutdown(SD_BOTH)) { wxLuaDebuggerEvent debugEvent(wxEVT_WXLUA_DEBUGGER_ERROR, this); ! debugEvent.SetMessage(m_acceptedSocket->GetErrorMsg(true)); AddPendingEvent(debugEvent); } --- 762,776 ---- m_fShutdown = true; ! // close the session socket, but first NULL it so we won't try to use it ! m_acceptSockCritSect.Enter(); ! wxLuaSocket *acceptedSocket = m_acceptedSocket; ! m_acceptedSocket = NULL; ! m_acceptSockCritSect.Leave(); ! if (acceptedSocket != NULL) { ! if (!acceptedSocket->Shutdown(SD_BOTH)) { wxLuaDebuggerEvent debugEvent(wxEVT_WXLUA_DEBUGGER_ERROR, this); ! debugEvent.SetMessage(acceptedSocket->GetErrorMsg(true)); AddPendingEvent(debugEvent); } *************** *** 768,773 **** wxMilliSleep(100); - wxLuaSocket *acceptedSocket = m_acceptedSocket; - m_acceptedSocket = NULL; delete acceptedSocket; } --- 778,781 ---- *************** *** 777,780 **** --- 785,791 ---- if (m_serverSocket != NULL) { + wxLuaSocket *serverSocket = m_serverSocket; + m_serverSocket = NULL; + // close the server socket by connecting to the socket, thus // completing the 'accept'. If a client has not connected, this *************** *** 789,793 **** { wxLuaDebuggerEvent debugEvent(wxEVT_WXLUA_DEBUGGER_ERROR, this); ! debugEvent.SetMessage(m_acceptedSocket->GetErrorMsg(true)); AddPendingEvent(debugEvent); } --- 800,804 ---- { wxLuaDebuggerEvent debugEvent(wxEVT_WXLUA_DEBUGGER_ERROR, this); ! debugEvent.SetMessage(serverSocket->GetErrorMsg(true)); AddPendingEvent(debugEvent); } *************** *** 795,805 **** wxMilliSleep(100); - wxLuaSocket *serverSocket = m_serverSocket; - m_serverSocket = NULL; delete serverSocket; } // One of the above two operations terminates the thread. Wait for it to stop. ! if ((m_pThread != NULL))// && m_pThread->IsRunning()) m_pThread->Wait(); --- 806,814 ---- wxMilliSleep(100); delete serverSocket; } // One of the above two operations terminates the thread. Wait for it to stop. ! if ((m_pThread != NULL) && m_pThread->IsRunning()) m_pThread->Wait(); *************** *** 830,834 **** delete serverSocket; ! wxMilliSleep(500); // why ?? // Notify that a client has connected and we are ready to debug --- 839,843 ---- delete serverSocket; ! wxThread::Sleep(500); // why ?? // Notify that a client has connected and we are ready to debug *************** *** 841,855 **** while (!m_pThread->TestDestroy() && !m_fShutdown && m_acceptedSocket) { ! debug_event = 0; ! if (m_acceptedSocket->ReadCmd(debug_event) && ! ((debug_event == wxLUASOCKET_DEBUGGEE_EVENT_EXIT) || ! (HandleDebuggeeEvent(debug_event) != -1))) { // don't send exit event until we've closed the socket if (debug_event == wxLUASOCKET_DEBUGGEE_EVENT_EXIT) m_fShutdown = true; } } // delete the accepted socket if (m_acceptedSocket != NULL) --- 850,878 ---- while (!m_pThread->TestDestroy() && !m_fShutdown && m_acceptedSocket) { ! debug_event = wxLUASOCKET_DEBUGGEE_EVENT_EXIT; ! ! ! { ! // lock the critical section while we access it ! wxCriticalSectionLocker locker(m_acceptSockCritSect); ! if ((m_acceptedSocket == NULL) || !m_acceptedSocket->ReadCmd(debug_event)) ! { ! m_fShutdown = true; ! } ! } ! ! if((debug_event == wxLUASOCKET_DEBUGGEE_EVENT_EXIT) || ! (HandleDebuggeeEvent(debug_event) != -1)) { // don't send exit event until we've closed the socket if (debug_event == wxLUASOCKET_DEBUGGEE_EVENT_EXIT) + { m_fShutdown = true; + } } } + + wxCriticalSectionLocker locker(m_acceptSockCritSect); // delete the accepted socket if (m_acceptedSocket != NULL) *************** *** 869,873 **** } - wxString wxLuaDebuggerCServer::GetSocketErrorMsg() { --- 892,895 ---- Index: wxlsock.cpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/modules/wxluasocket/src/wxlsock.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** wxlsock.cpp 19 May 2007 02:05:47 -0000 1.24 --- wxlsock.cpp 19 May 2007 17:14:13 -0000 1.25 *************** *** 31,38 **** // cmd/event and the socket read/write //#define DEBUG_WXLUASOCKET - #ifdef DEBUG_WXLUASOCKET ! static char* s_wxlsocket_event[] = { "wxLUASOCKET_DEBUGGEE_EVENT_NONE", "wxLUASOCKET_DEBUGGEE_EVENT_BREAK", --- 31,37 ---- // cmd/event and the socket read/write //#define DEBUG_WXLUASOCKET #ifdef DEBUG_WXLUASOCKET ! char* s_wxlsocket_event[] = { "wxLUASOCKET_DEBUGGEE_EVENT_NONE", "wxLUASOCKET_DEBUGGEE_EVENT_BREAK", *************** *** 48,52 **** }; ! static char* s_wxlsocket_cmd[] = { "wxLUASOCKET_DEBUGGER_CMD_NONE", "wxLUASOCKET_DEBUGGER_CMD_ADD_BREAKPOINT", --- 47,51 ---- }; ! char* s_wxlsocket_cmd[] = { "wxLUASOCKET_DEBUGGER_CMD_NONE", "wxLUASOCKET_DEBUGGER_CMD_ADD_BREAKPOINT", *************** *** 82,85 **** --- 81,85 ---- } + void wxLuaSocketDebugMsg(const wxString& title, const wxString& msg) { |