From 1ab1806a247e9fc53606ac3c18ed82037e2d5116 Mon Sep 17 00:00:00 2001 From: ehouse Date: Thu, 28 Jan 2010 04:29:24 +0000 Subject: [PATCH] improve logging --- xwords4/common/comms.c | 11 +++++++---- xwords4/wince/cemain.c | 14 ++++++++------ xwords4/wince/cesockwr.c | 8 ++++++-- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index 84f3c3eff..560542bb1 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -992,8 +992,10 @@ sendMsg( CommsCtxt* comms, MsgQueueElem* elem ) } else if ( conType == COMMS_CONN_RELAY ) { if ( comms->r.relayState >= COMMS_RELAYSTATE_CONNECTED ) { XWHostID destID = getDestID( comms, channelNo ); - result = send_via_relay( comms, XWRELAY_MSG_TORELAY, destID, - elem->msg, elem->len ); + if ( send_via_relay( comms, XWRELAY_MSG_TORELAY, destID, + elem->msg, elem->len ) ) { + result = elem->len; + } } else { XP_LOGF( "%s: skipping message: not connected", __func__ ); } @@ -1036,12 +1038,12 @@ comms_resendAll( CommsCtxt* comms ) if ( result == 0 && oneResult != 0 ) { result = oneResult; } - XP_STATUSF( "resend: msgID=" XP_LD "; rslt=%d", + XP_STATUSF( "%s: msgID=" XP_LD "; rslt=%d", __func__, msg->msgID, oneResult ); } return result; -} /* comms_resend */ +} /* comms_resendAll */ #ifdef XWFEATURE_RELAY # ifdef DEBUG @@ -1057,6 +1059,7 @@ relayCmdToStr( XWRELAY_Cmd cmd ) CASESTR( XWRELAY_CONNECT_RESP ); CASESTR( XWRELAY_RECONNECT_RESP ); CASESTR( XWRELAY_ALLHERE ); + CASESTR( XWRELAY_ALLBACK ); CASESTR( XWRELAY_DISCONNECT_YOU ); CASESTR( XWRELAY_DISCONNECT_OTHER ); CASESTR( XWRELAY_CONNECTDENIED ); diff --git a/xwords4/wince/cemain.c b/xwords4/wince/cemain.c index d3ea47dd7..58acd8975 100755 --- a/xwords4/wince/cemain.c +++ b/xwords4/wince/cemain.c @@ -2483,7 +2483,7 @@ connEvtAndError( CEAppGlobals* globals, WPARAM wParam ) #endif LRESULT CALLBACK -WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) +WndProc( HWND hWnd, UINT message, const WPARAM wParam, const LPARAM lParam ) { LRESULT result = 0; int wmId; @@ -2774,17 +2774,19 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) message==WM_KEYDOWN, &handled ); break; #endif - case WM_CHAR: + case WM_CHAR: { + WPARAM tmpWParam = wParam; if ( wParam == 0x08 ) { - wParam = XP_CURSOR_KEY_DEL; + tmpWParam = XP_CURSOR_KEY_DEL; #ifdef KEYBOARD_NAV } else if ( wParam == ' ' ) { - wParam = XP_RAISEFOCUS_KEY; + tmpWParam = XP_RAISEFOCUS_KEY; #endif } - draw = board_handleKey( globals->game.board, wParam, &handled ) - || board_handleKey( globals->game.board, wParam - ('a'-'A'), + draw = board_handleKey( globals->game.board, tmpWParam, &handled ) + || board_handleKey( globals->game.board, tmpWParam - ('a'-'A'), &handled ); + } break; case WM_TIMER: diff --git a/xwords4/wince/cesockwr.c b/xwords4/wince/cesockwr.c index c0fd91b24..55e0aa7cc 100755 --- a/xwords4/wince/cesockwr.c +++ b/xwords4/wince/cesockwr.c @@ -442,13 +442,13 @@ dispatch_msgs( CeSocketWrapper* self ) XP_U16 msgLen; XP_U16 lenUsed, lenLeft; - XP_LOGF( "%s: have %d bytes", __func__, lenInBuffer ); - /* Do we even have the length header? */ if ( lenInBuffer < sizeof(msgLen) ) { break; } + XP_LOGF( "%s: have %d bytes", __func__, lenInBuffer ); + XP_MEMCPY( &msgLen, self->in_buf, sizeof(msgLen) ); msgLen = XP_NTOHS( msgLen ); @@ -519,6 +519,8 @@ ce_sockwrap_event( CeSocketWrapper* self, WPARAM wParam, LPARAM lParam ) long event = (long)LOWORD(lParam); XP_Bool draw = XP_FALSE; + XP_LOGF( "%s(event=%lx)", __func__, event ); + if ( 0 != (FD_WRITE & event) ) { send_packet_if( self ); event &= ~FD_WRITE; @@ -547,6 +549,8 @@ ce_sockwrap_event( CeSocketWrapper* self, WPARAM wParam, LPARAM lParam ) } if ( 0 != (FD_CLOSE & event) ) { + int err = WSAGETSELECTERROR(lParam); + XP_LOGF( "%s: got FD_CLOSE; err=%d", __func__, err ); event &= ~FD_CLOSE; closeConnection( self ); }