From 2e8c7695f3a8953df25950e7da756daad8de1e7c Mon Sep 17 00:00:00 2001 From: Eric House Date: Thu, 11 Jun 2015 07:29:47 -0700 Subject: [PATCH] fix failure to connect using means (e.g. BT) that becomes available partway through a game. Problem was that once a channel was working with one means we wouldn't fall back to default addressing for the means for which we didn't have a return address yet. (NOTE: Not yet fully tested...) --- xwords4/common/comms.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/xwords4/common/comms.c b/xwords4/common/comms.c index 210678c7f..3151305ab 100644 --- a/xwords4/common/comms.c +++ b/xwords4/common/comms.c @@ -1392,23 +1392,20 @@ sendMsg( CommsCtxt* comms, MsgQueueElem* elem ) const CommsAddrRec* addrP; (void)channelToAddress( comms, channelNo, &addrP ); - if ( NULL == addrP ) { - XP_LOGF( TAGFMT() "no addr for channel so using comms'", TAGPRMS ); + if ( NULL == addrP || !addr_hasType( addrP, typ ) ) { + XP_LOGF( TAGFMT() "no addr for channel or addr type %s" + " so using comms'", ConnType2Str(typ), TAGPRMS ); comms_getAddr( comms, &addr ); } else { addr = *addrP; } + XP_ASSERT( addr_hasType( &addr, typ ) ); XP_ASSERT( !!comms->procs.send ); - if ( addr_hasType( &addr, typ ) ) { - XP_U32 gameid = gameID( comms ); - logAddr( comms, &addr, __func__ ); - nSent = (*comms->procs.send)( elem->msg, elem->len, &addr, typ, - gameid, comms->procs.closure ); - } else { - XP_LOGF( TAGFMT() "not sending b/c type %s missing from addr", - TAGPRMS, ConnType2Str(typ) ); - } + XP_U32 gameid = gameID( comms ); + logAddr( comms, &addr, __func__ ); + nSent = (*comms->procs.send)( elem->msg, elem->len, &addr, typ, + gameid, comms->procs.closure ); break; } } /* switch */