Re: Thread Safety of ODBC Driver - Mailing list pgsql-odbc
From | Hiroshi Inoue |
---|---|
Subject | Re: Thread Safety of ODBC Driver |
Date | |
Msg-id | 3D7C009F.385D115@tpf.co.jp Whole thread Raw |
In response to | Thread Safety of ODBC Driver ("Jason Koeninger" <jkoenin@jjcc.com>) |
Responses |
Re: Thread Safety of ODBC Driver
|
List | pgsql-odbc |
Sorry for the delay. I have little time to spare for psqlodbc now. I've developped psqlodbc mainly from Windows side. I've planned a trial thread-safe implementation under Windows. As for unix I knew about a few xxx_r functions but I don't know details about it and unfortunately there's no developper from unix side. I'm very happy if someone would take care of the driver from unix side. Jason Koeninger wrote: > > Here's a list of the issues I found. Since you've dealt with the statics, > I won't worry about those. > > connection.c: Uses strtok. Could convert to strtok_r. On FreeBSD, > I used strsep. > > convert.c: localtime used in copy_and_convert_field and > copy_statement_with_parameters. Use localtime_r and create > another struct tm to use as the extra argument. > > environ.c: The "conns" global at the start of the file could be a > problem. Looks like the only reason it's used is to commit all > connections on a single HENV at once if SQLTransact receives > a NULL HDBC. If it's necessary that the array exist, you'll have > to serialize access somehow. > > execute.c: Uses the conns global in PGAPI_Transact. My plan under Windows is to use CriticalSection to serialize the access to conns global. > gpps.c: The Unix implementation of Windows INI files has a > couple functions I'm not as familiar with, but I think they may be > a problem. getpwuid and getuid. I believe they return pointers > to statics, don't they? gpps.c is used with neither iDOBC nor unixODBC. I have no interest for standalone driver. > misc.c: Also has some getpwuid and getuid calls. mylog and > qlog probably need to be serialized, but they shouldn't cause a > crash. I would also use another CriticalSection to serialize the access to mylog or qlog. > socket.c: Uses gethostbyname. Some platforms have a > gethostbyname_r, but the implementations vary. I know in my > class libraries, I have a different implementation across > Linux, Solaris, FreeBSD, Windows, and OS/2. On FreeBSD, > you can use mutexes to serialize gethostbyname or use the > function getipnodebyname. The others either have a gethostbyname > that returns thread local storage or a gethostbyname_r > variation. > > The problem with these fixes is that, at least in FreeBSD, you > have to compile with the -pthread option to get some of the > normal C library functions to work safely in a threaded environment. > Some of the functions are also only defined in libc_r so some of > these fixes may require precompiler directives and makefile changes > if you want a thread-safe driver. The development of psqlodbc was moved to GBorg (http://gborg.postgresql.org/project/psqlodbc/projdisplay.php) and psqlodbc could have its own release cycle. As for Windows there's no problem. However as for *nixes, the *make* may be broken. I'm happy if you can figure out how to manage it together with the thread-safe option. regards, Hiroshi Inoue http://w2422.nsk.ne.jp/~inoue/
pgsql-odbc by date: