=== modified file 'ChangeLog' --- ChangeLog 2013-07-30 13:40:01 +0000 +++ ChangeLog 2013-08-01 05:25:34 +0000 @@ -22,6 +22,8 @@ (Bug# 16176981/67793) * Conversion of Time field data to Timestamp type may produce incorrect result (Bug# 17016839/69545) + * Need to add a lock to access connections member in ENV structure + (Bug# 17240611/69864) ---- === modified file 'driver/driver.h' --- driver/driver.h 2013-03-20 10:13:21 +0000 +++ driver/driver.h 2013-08-01 06:27:15 +0000 @@ -330,7 +330,9 @@ SQLINTEGER odbc_ver; LIST *connections; MYERROR error; - +#ifdef THREAD + pthread_mutex_t lock; +#endif } ENV; === modified file 'driver/handle.c' --- driver/handle.c 2012-12-13 23:31:25 +0000 +++ driver/handle.c 2013-08-01 07:49:19 +0000 @@ -62,6 +62,7 @@ SQLRETURN SQL_API my_SQLAllocEnv(SQLHENV FAR *phenv) { + ENV FAR **env= (ENV FAR**) phenv; #ifdef _UNIX_ /* Init thread key just once for all threads */ pthread_once(&myodbc_thread_key_inited, myodbc_thread_key_create); @@ -85,7 +86,7 @@ return SQL_ERROR; } #endif /* _UNIX_ */ - + pthread_mutex_init(&(*env)->lock,NULL); return SQL_SUCCESS; } @@ -121,6 +122,7 @@ SQLRETURN SQL_API my_SQLFreeEnv(SQLHENV henv) { + ENV FAR *env= (ENV FAR*) henv; #ifndef _UNIX_ GlobalUnlock(GlobalHandle((HGLOBAL) henv)); GlobalFree(GlobalHandle((HGLOBAL) henv)); @@ -128,6 +130,7 @@ x_free(henv); myodbc_end(); #endif /* _UNIX_ */ + pthread_mutex_destroy(&env->lock); return(SQL_SUCCESS); } @@ -245,7 +248,9 @@ dbc->last_query_time= (time_t) time((time_t*) 0); dbc->txn_isolation= DEFAULT_TXN_ISOLATION; dbc->env= penv; + pthread_mutex_lock(&penv->lock); penv->connections= list_add(penv->connections,&dbc->list); + pthread_mutex_unlock(&penv->lock); dbc->list.data= dbc; dbc->unicode= 0; dbc->ansi_charset_info= dbc->cxn_charset_info= NULL; @@ -283,7 +288,9 @@ LIST *ldesc; LIST *next; + pthread_mutex_lock(&dbc->env->lock); dbc->env->connections= list_delete(dbc->env->connections,&dbc->list); + pthread_mutex_unlock(&dbc->env->lock); x_free(dbc->database); if (dbc->ds) ds_delete(dbc->ds); @@ -682,7 +689,9 @@ /* add to this connection's list of explicit descriptors */ e= (LIST *) my_malloc(sizeof(LIST), MYF(0)); e->data= desc; + pthread_mutex_lock(&dbc->lock); dbc->exp_desc= list_add(dbc->exp_desc, e); + pthread_mutex_unlock(&dbc->lock); *pdesc= desc; return SQL_SUCCESS; @@ -712,7 +721,9 @@ { if (ldesc->data == desc) { + pthread_mutex_lock(&dbc->lock); dbc->exp_desc= list_delete(dbc->exp_desc, ldesc); + pthread_mutex_unlock(&dbc->lock); x_free(ldesc); break; } === modified file 'driver/options.c' --- driver/options.c 2013-06-28 16:53:41 +0000 +++ driver/options.c 2013-08-01 07:37:10 +0000 @@ -608,6 +608,7 @@ /* otherwise, associate this statement with the desc */ LIST *e= (LIST *) my_malloc(sizeof(LIST), MYF(0)); e->data= stmt; + /* No need to lock */ desc->exp.stmts= list_add(desc->exp.stmts, e); }