Re: BUG #1044: snprintf() shipped with PostgreSQL is not
От | Denis N. Stepanov |
---|---|
Тема | Re: BUG #1044: snprintf() shipped with PostgreSQL is not |
Дата | |
Msg-id | Pine.LNX.4.33.0401091111040.14170-100000@Linda.inp.nsk.su обсуждение исходный текст |
Ответ на | Re: BUG #1044: snprintf() shipped with PostgreSQL is not thread safe (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: BUG #1044: snprintf() shipped with PostgreSQL is not
|
Список | pgsql-bugs |
On Thu, 8 Jan 2004, Tom Lane wrote: TL> "PostgreSQL Bugs List" <pgsql-bugs@postgresql.org> writes: TL> > Some OSes lack proper snprintf()/vsnprintf() fuctions so PostgreSQL includes TL> > its own version (src/port/snprintf.c) during building. Unfortunately, this TL> > version of snprintf() is not reentrant (it uses global vars to keep internal TL> > state), so for example running libpq-based concurrent applications (threads) TL> > causes libpq fuctions to fail sometimes. TL> TL> What platforms have workable thread support but not snprintf? I think TL> this change is not likely to accomplish much except clutter the snprintf TL> code ... I discovered this problem while porting libpq (client interface) on RTEMS OS (rtems.org). This is an embedded OS and as many other embedded OSes it lacks non-ANSI C functions (at least RTEMS image from my vendor does not have them). snprintf()/vsnprintf() functions are not ANSI-compliant so they should be used with care. This OS has POSIX thread support though I did not use it (i.e. I keep all PgSQL activity in one thread, so the code was compiled without --enable-thread-safety). The difficulty I observed is: if even I keep PgSQL calls serialized, calling bare snprintf() from some other thread would likely cause concurrent PgSQL call to fail. Quite a strange result for such an inoffensive action, don't you think so? Anyway, I have fixed this for my code but if you think that the change is inappropriate for the main stream then let it be. I guess you would hear some more complaints as there will be more ports on embedded platforms. TL> TL> regards, tom lane TL> -- Thanks, Denis.
В списке pgsql-bugs по дате отправления: