mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-03 23:04:08 +01:00
Use a timer to avoid trying to get an ACL connection too frequetly.
This seems to trigger crash Treo650s far less often than constantly retrying.
This commit is contained in:
parent
a2f60cb1f8
commit
d58789c493
3 changed files with 37 additions and 8 deletions
|
@ -31,6 +31,7 @@
|
||||||
#define SOCK_INVAL ((BtLibSocketRef)-1)
|
#define SOCK_INVAL ((BtLibSocketRef)-1)
|
||||||
|
|
||||||
// #define DO_SERVICE_RECORD 1
|
// #define DO_SERVICE_RECORD 1
|
||||||
|
#define ACL_WAIT_INTERVAL 8
|
||||||
|
|
||||||
typedef enum { PBT_UNINIT = 0, PBT_MASTER, PBT_SLAVE } PBT_PicoRole;
|
typedef enum { PBT_UNINIT = 0, PBT_MASTER, PBT_SLAVE } PBT_PicoRole;
|
||||||
|
|
||||||
|
@ -137,6 +138,7 @@ static void pbt_postpone( PalmBTStuff* btStuff, PBT_ACTION act );
|
||||||
static XP_S16 pbt_enque( PBT_queue* queue, const XP_U8* data, XP_S16 len );
|
static XP_S16 pbt_enque( PBT_queue* queue, const XP_U8* data, XP_S16 len );
|
||||||
static void pbt_processIncoming( PalmBTStuff* btStuff );
|
static void pbt_processIncoming( PalmBTStuff* btStuff );
|
||||||
|
|
||||||
|
static void waitACL( PalmBTStuff* btStuff );
|
||||||
static void pbt_reset( PalmBTStuff* btStuff );
|
static void pbt_reset( PalmBTStuff* btStuff );
|
||||||
static void pbt_killL2C( PalmBTStuff* btStuff, BtLibSocketRef sock );
|
static void pbt_killL2C( PalmBTStuff* btStuff, BtLibSocketRef sock );
|
||||||
static void pbt_checkAddress( PalmBTStuff* btStuff, const CommsAddrRec* addr );
|
static void pbt_checkAddress( PalmBTStuff* btStuff, const CommsAddrRec* addr );
|
||||||
|
@ -654,7 +656,7 @@ pbt_do_work( PalmBTStuff* btStuff )
|
||||||
SET_STATE( btStuff, PBTST_L2C_CONNECTING );
|
SET_STATE( btStuff, PBTST_L2C_CONNECTING );
|
||||||
} else {
|
} else {
|
||||||
SET_STATE( btStuff, PBTST_NONE );
|
SET_STATE( btStuff, PBTST_NONE );
|
||||||
pbt_postpone( btStuff, PBT_ACT_CONNECT_ACL );
|
waitACL( btStuff );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
btStuff->dataSocket = SOCK_INVAL;
|
btStuff->dataSocket = SOCK_INVAL;
|
||||||
|
@ -756,6 +758,22 @@ pbt_reset( PalmBTStuff* btStuff )
|
||||||
LOG_RETURN_VOID();
|
LOG_RETURN_VOID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
btTimerProc( void* closure, XWTimerReason why )
|
||||||
|
{
|
||||||
|
PalmBTStuff* btStuff;
|
||||||
|
btStuff = (PalmBTStuff*)closure;
|
||||||
|
XP_ASSERT( why == TIMER_ACL_BACKOFF );
|
||||||
|
pbt_postpone( btStuff, PBT_ACT_CONNECT_ACL );
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
waitACL( PalmBTStuff* btStuff )
|
||||||
|
{
|
||||||
|
util_setTimer( &btStuff->globals->util, TIMER_ACL_BACKOFF,
|
||||||
|
ACL_WAIT_INTERVAL, btTimerProc, btStuff );
|
||||||
|
}
|
||||||
|
|
||||||
static Err
|
static Err
|
||||||
bpd_discover( PalmBTStuff* btStuff, BtLibDeviceAddressType* addr )
|
bpd_discover( PalmBTStuff* btStuff, BtLibDeviceAddressType* addr )
|
||||||
{
|
{
|
||||||
|
@ -959,7 +977,7 @@ l2SocketCallback( BtLibSocketEventType* sEvent, UInt32 refCon )
|
||||||
*/
|
*/
|
||||||
if ( PBT_SLAVE == btStuff->picoRole ) {
|
if ( PBT_SLAVE == btStuff->picoRole ) {
|
||||||
pbt_killL2C( btStuff, sEvent->socket );
|
pbt_killL2C( btStuff, sEvent->socket );
|
||||||
pbt_postpone( btStuff, PBT_ACT_CONNECT_ACL );
|
waitACL( btStuff );
|
||||||
} else if ( PBT_MASTER == btStuff->picoRole ) {
|
} else if ( PBT_MASTER == btStuff->picoRole ) {
|
||||||
pbt_close_datasocket( btStuff );
|
pbt_close_datasocket( btStuff );
|
||||||
SET_STATE( btStuff, PBTST_LISTENING );
|
SET_STATE( btStuff, PBTST_LISTENING );
|
||||||
|
@ -1009,7 +1027,7 @@ libMgmtCallback( BtLibManagementEventType* mEvent, UInt32 refCon )
|
||||||
pbt_postpone( btStuff, PBT_ACT_CONNECT_L2C );
|
pbt_postpone( btStuff, PBT_ACT_CONNECT_L2C );
|
||||||
} else {
|
} else {
|
||||||
SET_STATE( btStuff, PBTST_NONE );
|
SET_STATE( btStuff, PBTST_NONE );
|
||||||
pbt_postpone( btStuff, PBT_ACT_CONNECT_ACL );
|
waitACL( btStuff );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1039,7 +1057,7 @@ libMgmtCallback( BtLibManagementEventType* mEvent, UInt32 refCon )
|
||||||
SET_STATE( btStuff, PBTST_NONE );
|
SET_STATE( btStuff, PBTST_NONE );
|
||||||
/* See comment at btLibSocketEventDisconnected */
|
/* See comment at btLibSocketEventDisconnected */
|
||||||
if ( PBT_SLAVE == btStuff->picoRole ) {
|
if ( PBT_SLAVE == btStuff->picoRole ) {
|
||||||
pbt_postpone( btStuff, PBT_ACT_CONNECT_ACL );
|
waitACL( btStuff );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1558,7 +1558,7 @@ timeForTimer( PalmAppGlobals* globals, XWTimerReason* why, XP_U32* when )
|
||||||
XP_U32 nextWhen = 0xFFFFFFFF;
|
XP_U32 nextWhen = 0xFFFFFFFF;
|
||||||
XP_Bool found;
|
XP_Bool found;
|
||||||
|
|
||||||
for ( i = 1; i < NUM_TIMERS_PLUS_ONE; ++i ) {
|
for ( i = 1; i < NUM_PALM_TIMERS; ++i ) {
|
||||||
if ( (globals->timerProcs[i] != NULL) &&
|
if ( (globals->timerProcs[i] != NULL) &&
|
||||||
(globals->timerFireAt[i] < nextWhen) ) {
|
(globals->timerFireAt[i] < nextWhen) ) {
|
||||||
nextWhy = i;
|
nextWhy = i;
|
||||||
|
@ -3782,6 +3782,10 @@ palm_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why,
|
||||||
#ifdef XWFEATURE_RELAY
|
#ifdef XWFEATURE_RELAY
|
||||||
} else if ( why == TIMER_HEARTBEAT ) {
|
} else if ( why == TIMER_HEARTBEAT ) {
|
||||||
now += (secsFromNow * SysTicksPerSecond());
|
now += (secsFromNow * SysTicksPerSecond());
|
||||||
|
#endif
|
||||||
|
#ifdef XWFEATURE_BLUETOOTH
|
||||||
|
} else if ( why == TIMER_ACL_BACKOFF ) {
|
||||||
|
now += (secsFromNow * SysTicksPerSecond());
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
XP_ASSERT( 0 );
|
XP_ASSERT( 0 );
|
||||||
|
|
|
@ -231,6 +231,13 @@ typedef enum {
|
||||||
} BtUIState;
|
} BtUIState;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef XWFEATURE_BLUETOOTH
|
||||||
|
# define TIMER_ACL_BACKOFF NUM_TIMERS_PLUS_ONE
|
||||||
|
# define NUM_PALM_TIMERS (NUM_TIMERS_PLUS_ONE + 1)
|
||||||
|
#else
|
||||||
|
# define NUM_PALM_TIMERS NUM_TIMERS_PLUS_ONE
|
||||||
|
#endif
|
||||||
|
|
||||||
struct PalmAppGlobals {
|
struct PalmAppGlobals {
|
||||||
FormPtr mainForm;
|
FormPtr mainForm;
|
||||||
PrefsDlgState* prefsDlgState;
|
PrefsDlgState* prefsDlgState;
|
||||||
|
@ -324,9 +331,9 @@ struct PalmAppGlobals {
|
||||||
|
|
||||||
struct ConnsDlgState* connState;
|
struct ConnsDlgState* connState;
|
||||||
|
|
||||||
XWTimerProc timerProcs[NUM_TIMERS_PLUS_ONE];
|
XWTimerProc timerProcs[NUM_PALM_TIMERS];
|
||||||
void* timerClosures[NUM_TIMERS_PLUS_ONE];
|
void* timerClosures[NUM_PALM_TIMERS];
|
||||||
XP_U32 timerFireAt[NUM_TIMERS_PLUS_ONE];
|
XP_U32 timerFireAt[NUM_PALM_TIMERS];
|
||||||
|
|
||||||
#ifdef XWFEATURE_RELAY
|
#ifdef XWFEATURE_RELAY
|
||||||
NetLibStuff nlStuff;
|
NetLibStuff nlStuff;
|
||||||
|
|
Loading…
Reference in a new issue