call srand with current time (attempting to fix what may be duplicate

seeds on relay, possible if rand() always starts with same sequence on
different devices in new process); add commented-out logging util_rand
implementation.
This commit is contained in:
Andy2 2010-07-29 06:53:06 -07:00
parent 6be5105eff
commit 51d759569a
2 changed files with 14 additions and 0 deletions

View file

@ -444,3 +444,13 @@ and_empty_stream( MPFORMAL AndGlobals* globals )
return stream;
}
/* #ifdef DEBUG */
/* XP_U32 */
/* andy_rand( const char* caller ) */
/* { */
/* XP_U32 result = rand(); */
/* XP_LOGF( "%s: returning 0x%lx to %s", __func__, result, caller ); */
/* LOG_RETURNF( "%lx", result ); */
/* return result; */
/* } */
/* #endif */

View file

@ -337,6 +337,10 @@ Java_org_eehouse_android_xw4_jni_XwJNI_initJNI
MPASSIGN( state->mpool, mpool );
globals->vtMgr = make_vtablemgr(MPPARM_NOCOMMA(mpool));
XP_U32 secs = and_util_getCurSeconds( NULL );
XP_LOGF( "initing srand with %ld", secs );
srandom( secs );
return (jint) state;
}