postgresql/src/interfaces/ecpg/include
Tom Lane 0028b55bc8 Clean up Windows-specific mutex code in libpq and ecpglib.
Fix pthread-win32.h and pthread-win32.c to provide a more complete
emulation of POSIX pthread mutexes: define PTHREAD_MUTEX_INITIALIZER
and make sure that pthread_mutex_lock() can operate on a mutex
object that's been initialized that way.  Then we don't need the
duplicative platform-specific logic in default_threadlock() and
pgtls_init(), which we'd otherwise need yet a third copy of for
an upcoming bug fix.

Also, since default_threadlock() supposes that pthread_mutex_lock()
cannot fail, try to ensure that that's actually true, by getting
rid of the malloc call that was formerly involved in initializing
an emulated mutex.  We can define an extra state for the spinlock
field instead.

Also, replace the similar code in ecpglib/misc.c with this version.
While ecpglib's version at least had a POSIX-compliant API, it
also had the potential of failing during mutex init (but here,
because of CreateMutex failure rather than malloc failure).  Since
all of misc.c's callers ignore failures, it seems like a wise idea
to avoid failures here too.

A further improvement in this area could be to unify libpq's and
ecpglib's implementations into a src/port/pthread-win32.c file.
But that doesn't seem like a bug fix, so I'll desist for now.

In preparation for the aforementioned bug fix, back-patch to all
supported branches.

Discussion: https://postgr.es/m/264860.1707163416@sss.pgh.pa.us
2024-02-09 11:11:39 -05:00
..
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
Makefile Remove distprep 2023-11-06 15:18:04 +01:00
datetime.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
decimal.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
ecpg-pthread-win32.h Clean up Windows-specific mutex code in libpq and ecpglib. 2024-02-09 11:11:39 -05:00
ecpg_config.h.in Remove --disable-thread-safety and related code. 2023-07-12 08:20:43 +12:00
ecpg_informix.h Harmonize parameter names in ecpg code. 2022-09-22 12:53:20 -07:00
ecpgerrno.h Revert "Add DECLARE STATEMENT support to ECPG." 2019-09-20 12:47:37 -04:00
ecpglib.h Remove --disable-thread-safety and related code. 2023-07-12 08:20:43 +12:00
ecpgtype.h Revert "Add DECLARE STATEMENT support to ECPG." 2019-09-20 12:47:37 -04:00
meson.build Update copyright for 2024 2024-01-03 20:49:05 -05:00
pgtypes.h Add PGTYPESchar_free() to avoid cross-module problems on Windows. 2018-06-18 18:33:53 +12:00
pgtypes_date.h Harmonize parameter names in ecpg code. 2022-09-22 12:53:20 -07:00
pgtypes_error.h Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
pgtypes_interval.h Pre-beta mechanical code beautification. 2023-05-19 17:24:48 -04:00
pgtypes_numeric.h Harmonize parameter names in ecpg code. 2022-09-22 12:53:20 -07:00
pgtypes_timestamp.h Harmonize parameter names in ecpg code. 2022-09-22 12:53:20 -07:00
sql3types.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
sqlca.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
sqlda-compat.h Fix more wrong paths in header comments 2018-07-11 17:57:04 +03:00
sqlda-native.h Fix some typos, grammar and style in docs and comments 2021-02-24 16:13:17 +09:00
sqlda.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
sqltypes.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00