mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-13 08:01:33 +01:00
Close down relay connection when comms going away. Fixes crashes when
new game is standalone and prev used relay. Add logging code in comms.
This commit is contained in:
parent
c2d00ee2ae
commit
8e31a3c5cb
3 changed files with 34 additions and 3 deletions
|
@ -1006,6 +1006,22 @@ relayCmdToStr( XWRELAY_Cmd cmd )
|
|||
default: return "<unknown>";
|
||||
}
|
||||
}
|
||||
|
||||
const char*
|
||||
ConnType2Str( CommsConnType typ )
|
||||
{
|
||||
switch( typ ) {
|
||||
CASESTR(COMMS_CONN_NONE);
|
||||
CASESTR( COMMS_CONN_IR );
|
||||
CASESTR( COMMS_CONN_IP_DIRECT );
|
||||
CASESTR( COMMS_CONN_RELAY );
|
||||
CASESTR( COMMS_CONN_BT );
|
||||
CASESTR( COMMS_CONN_SMS );
|
||||
default:
|
||||
XP_ASSERT(0);
|
||||
}
|
||||
return "<unknown>";
|
||||
}
|
||||
# else
|
||||
# define relayCmdToStr( cmd )
|
||||
# endif
|
||||
|
|
|
@ -143,6 +143,7 @@ XP_Bool comms_checkIncomingStream( CommsCtxt* comms, XWStreamCtxt* stream,
|
|||
|
||||
# ifdef DEBUG
|
||||
void comms_getStats( CommsCtxt* comms, XWStreamCtxt* stream );
|
||||
const char* ConnType2Str( CommsConnType typ );
|
||||
# endif
|
||||
|
||||
EXTERN_C_END
|
||||
|
|
|
@ -3375,10 +3375,24 @@ ce_util_remSelected( XW_UtilCtxt* uc )
|
|||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
static void
|
||||
ce_util_addrChange( XW_UtilCtxt* XP_UNUSED(uc),
|
||||
const CommsAddrRec* XP_UNUSED(oldAddr),
|
||||
const CommsAddrRec* XP_UNUSED(newAddr) )
|
||||
ce_util_addrChange( XW_UtilCtxt* uc,
|
||||
const CommsAddrRec* oldAddr,
|
||||
const CommsAddrRec* newAddr )
|
||||
{
|
||||
CEAppGlobals* globals = (CEAppGlobals*)uc->closure;
|
||||
|
||||
XP_LOGF( "%s: old: %s -> new: %s", __func__,
|
||||
ConnType2Str( oldAddr->conType ),
|
||||
ConnType2Str( newAddr->conType ) );
|
||||
|
||||
/* A lot more needs to be tested for and done here... */
|
||||
if ( COMMS_CONN_NONE == newAddr->conType ) {
|
||||
if ( !!globals->socketWrap ) {
|
||||
ce_sockwrap_delete( globals->socketWrap );
|
||||
globals->socketWrap = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
XP_LOGF( "ce_util_addrChange called; DO SOMETHING." );
|
||||
} /* ce_util_addrChange */
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue