[PATCH] Fix for __SQLGetInfo
Richard Kettlewell <[email protected]>
| Newsgroups | gmane.comp.db.unixodbc.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi, __SQLGetInfo() exits via function_return(), but its callers all expect to call this function too. The effect is that it unlocks the mutex earlier than expected, and moreover then releases it a second time (possibly after another thread has acquired it). The effect is intermittent crashes, at least the extremely thread-heavy program I am working on. The attached patch fixes this problem, eliminating the crashes. I've been running my tests against a patched version all day, so I'm pretty confident that I've improved the situation l-) ttfn/rjk _______________________________________________ unixODBC-dev mailing list [email protected] http://mailman.unixodbc.org/mailman/listinfo/unixodbc-dev
17962.diff
(text/x-patch, 2.6 KB)
commit 0e975502419d0952a6f485fd373cd752fb97d8e0 Author: Richard Kettlewell <[email protected]> Date: Wed Mar 23 12:06:52 2011 +0000 Don't call function_return() from __SQLGetInfo(). Its callers all expect to call it. If it is called in both __SQLGetInfo() and its caller then the effect is that the mutex protecting the connection is released earlier than expected (leading to the connection being accsesed concurrently without appropriate synchronization), and twice (which was how the problem was isolated). diff --git a/DriverManager/SQLGetInfo.c b/DriverManager/SQLGetInfo.c index 3e3d458..f7ca4e2 100644 --- a/DriverManager/SQLGetInfo.c +++ b/DriverManager/SQLGetInfo.c @@ -256,7 +256,7 @@ SQLRETURN __SQLGetInfo( SQLHDBC connection_handle, ERROR_HY024, NULL, connection -> environment -> requested_version ); - return function_return( SQL_HANDLE_DBC, connection, SQL_ERROR ); + return SQL_ERROR; } } } @@ -291,7 +291,7 @@ SQLRETURN __SQLGetInfo( SQLHDBC connection_handle, ERROR_HY024, NULL, connection -> environment -> requested_version ); - return function_return( SQL_HANDLE_DBC, connection, SQL_ERROR ); + return SQL_ERROR; } } } @@ -328,7 +328,7 @@ SQLRETURN __SQLGetInfo( SQLHDBC connection_handle, ERROR_IM001, NULL, connection -> environment -> requested_version ); - return function_return( SQL_HANDLE_DBC, connection, SQL_ERROR ); + return SQL_ERROR; } switch( info_type ) @@ -455,7 +455,7 @@ SQLRETURN __SQLGetInfo( SQLHDBC connection_handle, ERROR_IM001, NULL, connection -> environment -> requested_version ); - return function_return( SQL_HANDLE_DBC, connection, SQL_ERROR ); + return SQL_ERROR; } ret = SQLGETINFO( connection, @@ -466,7 +466,7 @@ SQLRETURN __SQLGetInfo( SQLHDBC connection_handle, string_length ); } - return function_return( SQL_HANDLE_DBC, connection, ret ); + return ret; } if ( type == 1 ) @@ -505,7 +505,7 @@ SQLRETURN __SQLGetInfo( SQLHDBC connection_handle, *string_length = sizeof( SQLUSMALLINT ); } - return function_return( SQL_HANDLE_DBC, connection, ret ); + return ret; } SQLRETURN SQLGetInfo( SQLHDBC connection_handle,