mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-12-28 09:58:30 +01:00
fix crash in dict iteration: add to thread map the env that creates globals
This commit is contained in:
parent
c3e7b12103
commit
7a1cd06486
1 changed files with 18 additions and 17 deletions
|
@ -63,21 +63,7 @@ typedef struct _JNIGlobalState {
|
|||
} JNIGlobalState;
|
||||
|
||||
static void
|
||||
map_init( EnvThreadInfo* ti )
|
||||
{
|
||||
pthread_mutex_init( &ti->mtxThreads, NULL );
|
||||
}
|
||||
|
||||
static void
|
||||
map_destroy( EnvThreadInfo* ti )
|
||||
{
|
||||
// XP_ASSERT( 0 == ti->nMaps );
|
||||
XP_LOGF( "%s: had %d threads max", __func__, ti->nMaps );
|
||||
pthread_mutex_destroy( &ti->mtxThreads );
|
||||
}
|
||||
|
||||
static void
|
||||
map_thread( EnvThreadInfo* ti, JNIEnv* env, const char* proc )
|
||||
map_thread( EnvThreadInfo* ti, JNIEnv* env )
|
||||
{
|
||||
pthread_t self = pthread_self();
|
||||
|
||||
|
@ -108,6 +94,21 @@ map_thread( EnvThreadInfo* ti, JNIEnv* env, const char* proc )
|
|||
pthread_mutex_unlock( &ti->mtxThreads );
|
||||
}
|
||||
|
||||
static void
|
||||
map_init( EnvThreadInfo* ti, JNIEnv* env )
|
||||
{
|
||||
pthread_mutex_init( &ti->mtxThreads, NULL );
|
||||
map_thread( ti, env );
|
||||
}
|
||||
|
||||
static void
|
||||
map_destroy( EnvThreadInfo* ti )
|
||||
{
|
||||
// XP_ASSERT( 0 == ti->nMaps );
|
||||
XP_LOGF( "%s: had %d threads max", __func__, ti->nMaps );
|
||||
pthread_mutex_destroy( &ti->mtxThreads );
|
||||
}
|
||||
|
||||
JNIEnv*
|
||||
envForMe( EnvThreadInfo* ti, const char* caller )
|
||||
{
|
||||
|
@ -137,7 +138,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_initGlobals
|
|||
MemPoolCtx* mpool = mpool_make();
|
||||
#endif
|
||||
JNIGlobalState* state = (JNIGlobalState*)XP_CALLOC( mpool, sizeof(*state) );
|
||||
map_init( &state->ti );
|
||||
map_init( &state->ti, env );
|
||||
state->dictMgr = dmgr_make( MPPARM_NOCOMMA( mpool ) );
|
||||
MPASSIGN( state->mpool, mpool );
|
||||
LOG_RETURNF( "%p", state );
|
||||
|
@ -537,7 +538,7 @@ struct _JNIState {
|
|||
MPSLOT; \
|
||||
MPASSIGN( mpool, state->mpool); \
|
||||
XP_ASSERT( !!state->globalJNI ); \
|
||||
map_thread( &state->globalJNI->ti, env, __func__ ); \
|
||||
map_thread( &state->globalJNI->ti, env ); \
|
||||
|
||||
#define XWJNI_START_GLOBALS() \
|
||||
XWJNI_START() \
|
||||
|
|
Loading…
Reference in a new issue