Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 379c43b

Browse filesBrowse files
committed
Fix ancient bug in ecpg's pthread_once() emulation for Windows.
We must not set the "done" flag until after we've executed the initialization function. Otherwise, other threads can fall through the initial unlocked test before initialization is really complete. This has been seen to cause rare failures of ecpg's thread/descriptor test, and it could presumably cause other sorts of misbehavior in threaded ECPG-using applications, since ecpglib relies on pthread_once() in several places. Diagnosis and patch by me, based on investigation by Alexander Lakhin. Back-patch to all supported branches (the bug dates to 2007). Discussion: https://postgr.es/m/16685-d6cd241872c101d3@postgresql.org
1 parent 05a3632 commit 379c43b
Copy full SHA for 379c43b

File tree

Expand file treeCollapse file tree

1 file changed

+1
-1
lines changed
Filter options
  • src/interfaces/ecpg/ecpglib
Expand file treeCollapse file tree

1 file changed

+1
-1
lines changed

‎src/interfaces/ecpg/ecpglib/misc.c

Copy file name to clipboardExpand all lines: src/interfaces/ecpg/ecpglib/misc.c
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@ win32_pthread_once(volatile pthread_once_t *once, void (*fn) (void))
475475
pthread_mutex_lock(&win32_pthread_once_lock);
476476
if (!*once)
477477
{
478-
*once = true;
479478
fn();
479+
*once = true;
480480
}
481481
pthread_mutex_unlock(&win32_pthread_once_lock);
482482
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.