fix null procptr crash in jni

I can't reproduce this, but while testing recovery from DatagramSocket
recreation in RelayService got enough to know that somehow a timer's
procptr's not set. So test before calling, and log instead of crashing.
This commit is contained in:
Eric House 2019-03-20 13:31:35 -07:00
parent 36cc181a5e
commit d25041e8a0

View file

@ -304,15 +304,19 @@ and_util_engineProgressCallback( XW_UtilCtxt* uc )
bool bool
utilTimerFired( XW_UtilCtxt* uc, XWTimerReason why, int handle ) utilTimerFired( XW_UtilCtxt* uc, XWTimerReason why, int handle )
{ {
bool handled; bool handled = false;
AndUtil* util = (AndUtil*)uc; AndUtil* util = (AndUtil*)uc;
TimerStorage* timerStorage = &util->timerStorage[why]; TimerStorage* timerStorage = &util->timerStorage[why];
if ( handle == (int)timerStorage ) { if ( handle == (int)timerStorage ) {
handled = (*timerStorage->proc)( timerStorage->closure, why ); XWTimerProc proc = timerStorage->proc;
if ( !!proc ) {
handled = (*proc)( timerStorage->closure, why );
} else {
XP_LOGF( "%s(why=%d): ERROR: no proc set", __func__, why );
}
} else { } else {
XP_LOGF( "%s: mismatch: handle=%d; timerStorage=%d", __func__, XP_LOGF( "%s: mismatch: handle=%d; timerStorage=%d", __func__,
handle, (int)timerStorage ); handle, (int)timerStorage );
handled = false;
} }
return handled; return handled;
} }