# HG changeset patch # User Chad Peckham # Date 1253571524 18000 # Node ID f815991516d207a14d907c34f6f203b7d133a538 # Parent 44dbbc3220b88714f33ce35c3092017840208e46# Parent 4fcf839f8ca1d13aa7fcce82aaeae11ba1d68615 merge heads diff -r 4fcf839f8ca1 -r f815991516d2 connectivity/com.nokia.tcf/native/TCFNative/TCFClient/ClientManager.cpp --- a/connectivity/com.nokia.tcf/native/TCFNative/TCFClient/ClientManager.cpp Mon Sep 21 10:37:58 2009 -0500 +++ b/connectivity/com.nokia.tcf/native/TCFNative/TCFClient/ClientManager.cpp Mon Sep 21 17:18:44 2009 -0500 @@ -640,8 +640,8 @@ void CClientManager::DeleteFromLockFile(DWORD serverProcessId) { - DWORD callingId[10]; - DWORD serverId[10]; + DWORD creatorIds[10]; + DWORD serverIds[10]; int numIds = 0; DWORD ourProcessId = ::GetCurrentProcessId(); @@ -663,16 +663,16 @@ BOOL done = FALSE; while (!done) { - DWORD cId = 0xffffffff; - DWORD sId = 0xffffffff; - int n = fscanf(f, "%ld %ld\n", &cId, &sId); + DWORD creatorId = 0xffffffff; + DWORD serverId = 0xffffffff; + int n = fscanf(f, "%ld %ld\n", &creatorId, &serverId); if (n == 2) { - TCDEBUGLOGA3("CClientManager::DeleteFromLockFile numIds=%d sId=%d pId=%d\n", numIds, cId, sId); - if (cId != ourProcessId || sId != serverProcessId) + TCDEBUGLOGA3("CClientManager::DeleteFromLockFile numIds=%d creatorId=%d serverId=%d\n", numIds, creatorId, serverId); + if (creatorId != ourProcessId || serverId != serverProcessId) { - callingId[numIds] = cId; - serverId[numIds] = sId; + creatorIds[numIds] = creatorId; + serverIds[numIds] = serverId; numIds++; if (numIds > 9) done = TRUE; @@ -695,7 +695,7 @@ { for (int i = 0; i < numIds; i++) { - fprintf(f, "%ld %ld\n", callingId[i], serverId[i]); + fprintf(f, "%ld %ld\n", creatorIds[i], serverIds[i]); } fclose(f); } @@ -708,8 +708,8 @@ // we should not have more than a few Carbide processes connecting to the same TCFServer void CClientManager::TerminateServerThroughLockFile(pServerProcessData pData) { - DWORD callingId[10]; - DWORD serverId[10]; + DWORD creatorIds[10]; + DWORD serverIds[10]; BOOL liveCaller[10]; int numIds = 0; if (m_ServerLockFile != NULL) @@ -729,14 +729,14 @@ BOOL done = FALSE; while (!done) { - DWORD cId = 0xffffffff; - DWORD sId = 0xffffffff; - int n = fscanf(f, "%ld %ld\n", &cId, &sId); + DWORD creatorId = 0xffffffff; + DWORD serverId = 0xffffffff; + int n = fscanf(f, "%ld %ld\n", &creatorId, &serverId); if (n == 2) { - TCDEBUGLOGA3("CClientManager::TerminateServerThroughLockFile n=%d sId=%d pId=%d\n", n, cId, sId); - callingId[numIds] = cId; - serverId[numIds] = sId; + TCDEBUGLOGA3("CClientManager::TerminateServerThroughLockFile n=%d creatorId=%d serverId=%d\n", n, creatorId, serverId); + creatorIds[numIds] = creatorId; + serverIds[numIds] = serverId; numIds++; if (numIds > 9) done = TRUE; @@ -751,20 +751,31 @@ int numDeadCallers = 0; for (int i = 0; i < numIds; i++) { - HANDLE h = ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, callingId[i]); + HANDLE h = ::OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, creatorIds[i]); if (h) { // calling process is still alive liveCaller[i] = TRUE; + DWORD exitCode = -5; + BOOL exitCall = ::GetExitCodeProcess(h, &exitCode); + DWORD id = ::GetCurrentProcessId(); ::CloseHandle(h); - TCDEBUGLOGA1("CClientManager::TerminateServerThroughLockFile %d alive\n", callingId[i]); + TCDEBUGLOGA3("CClientManager::TerminateServerThroughLockFile %d alive exitCall=%d currentId=%d\n", creatorIds[i], exitCall, id); + if (exitCall == TRUE && exitCode != STILL_ACTIVE) + { + liveCaller[i] = FALSE; + numDeadCallers++; + } + { + TCDEBUGLOGA2("CClientManager::TerminateServerThroughLockFile exitCode=%d still_active=%d\n", exitCode, STILL_ACTIVE); + } } else { liveCaller[i] = FALSE; numDeadCallers++; DWORD err = ::GetLastError(); - TCDEBUGLOGA3("CClientManager::TerminateServerThroughLockFile %d dead err=%d:%s\n", callingId[i], err, GetErrorText(err)); + TCDEBUGLOGA3("CClientManager::TerminateServerThroughLockFile %d dead err=%d:%s\n", creatorIds[i], err, GetErrorText(err)); } } if (numDeadCallers == numIds) @@ -772,7 +783,7 @@ // terminate the TCFServer, and delete lock file pData->numRefs = 0; ::remove(m_ServerLockFile); - HANDLE h = ::OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, serverId[0]); + HANDLE h = ::OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, serverIds[0]); if (h) { BOOL ret = ::TerminateProcess(h, -1); @@ -795,7 +806,7 @@ { if (liveCaller[i]) { - fprintf(f, "%ld %ld\n", callingId[i], serverId[i]); + fprintf(f, "%ld %ld\n", creatorIds[i], serverIds[i]); } } fclose(f); diff -r 4fcf839f8ca1 -r f815991516d2 connectivity/com.nokia.tcf/native/TCFNative/TCFCommTCP/TcpComm.cpp --- a/connectivity/com.nokia.tcf/native/TCFNative/TCFCommTCP/TcpComm.cpp Mon Sep 21 10:37:58 2009 -0500 +++ b/connectivity/com.nokia.tcf/native/TCFNative/TCFCommTCP/TcpComm.cpp Mon Sep 21 17:18:44 2009 -0500 @@ -521,7 +521,8 @@ } #ifdef _DEBUG int reallen = fullMessageLength; - if (reallen > 80) reallen = 80; + if (reallen > 100) reallen = 100; + bool wasAlnum = false; char msg[6]; msg[0] = '\0'; @@ -531,13 +532,25 @@ sTcpLogMsg[0] = '\0'; for (int i = 0; i < reallen; i++) { - if (isalnum(ptr[i])) + if (isgraph/*isalnum*/(ptr[i]) && i > protocolHeaderLength) { + // string printables next to each other sprintf(msg, "%c", ptr[i]); + wasAlnum = true; } else { - sprintf(msg, "%02.2x ", ptr[i]); + if (wasAlnum) + { + // break from last alnum char + sprintf(msg, " %02.2x ", ptr[i]); + } + else + { + // no break + sprintf(msg, "%02.2x ", ptr[i]); + } + wasAlnum = false; } strcat(sTcpLogMsg, msg); } @@ -679,16 +692,53 @@ } // end while COMMLOGS("CTcpComm::SendDataToPort send done\n"); #ifdef _DEBUG + DWORD protocolHeaderLength = m_Protocol->GetHeaderLength(); BYTE* ptr = (BYTE*)inData; - long numBytes = (inSize > 20) ? 20 : inSize; - char msg[200]; - sprintf(msg, "CTcpComm::SendDataToPort data = "); - for (int i = 0; i < numBytes; i++) + int reallen = inSize; + if (reallen > 100) reallen = 100; + bool wasAlnum = false; + char msg[6]; + msg[0] = '\0'; + + sTcpLogMsgSend[0] = '\0'; + if (reallen > 0) { - sprintf(msg, "%s %02.2x", msg, ptr[i]); + sTcpLogMsgSend[0] = '\0'; + for (int i = 0; i < reallen; i++) + { + if (isgraph/*isalnum*/(ptr[i]) && i > protocolHeaderLength) + { + // string printables next to each other + sprintf(msg, "%c", ptr[i]); + wasAlnum = true; + } + else + { + if (wasAlnum) + { + // break from last alnum char + sprintf(msg, " %02.2x ", ptr[i]); + } + else + { + // no break + sprintf(msg, "%02.2x ", ptr[i]); + } + wasAlnum = false; + } + strcat(sTcpLogMsgSend, msg); + } } - sprintf(msg, "%s\n", msg); - COMMLOGS(msg); +// BYTE* ptr = (BYTE*)inData; +// long numBytes = (inSize > 20) ? 20 : inSize; +// char msg[200]; +// sprintf(msg, "CTcpComm::SendDataToPort data = "); +// for (int i = 0; i < numBytes; i++) +// { +// sprintf(msg, "%s %02.2x", msg, ptr[i]); +// } +// sprintf(msg, "%s\n", msg); + COMMLOGA2("CTcpComm::SendDataToPort len=%d msg=%s\n", inSize, sTcpLogMsgSend); #endif } diff -r 4fcf839f8ca1 -r f815991516d2 connectivity/com.nokia.tcf/native/TCFNative/TCFCommTCP/TcpComm.h --- a/connectivity/com.nokia.tcf/native/TCFNative/TCFCommTCP/TcpComm.h Mon Sep 21 10:37:58 2009 -0500 +++ b/connectivity/com.nokia.tcf/native/TCFNative/TCFCommTCP/TcpComm.h Mon Sep 21 17:18:44 2009 -0500 @@ -67,6 +67,7 @@ WSAEVENT m_hSocketEvent; DWORD m_pPeekBuffer; char sTcpLogMsg[3000]; + char sTcpLogMsgSend[3000]; }; #endif // !defined(AFX_TCPCOMM_H__69657421_6D37_497A_A377_12E71365EDAB__INCLUDED_)