forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit0028b55
committed
Clean up Windows-specific mutex code in libpq and ecpglib.
Fix pthread-win32.h and pthread-win32.c to provide a more completeemulation of POSIX pthread mutexes: define PTHREAD_MUTEX_INITIALIZERand make sure that pthread_mutex_lock() can operate on a mutexobject that's been initialized that way. Then we don't need theduplicative platform-specific logic in default_threadlock() andpgtls_init(), which we'd otherwise need yet a third copy of foran upcoming bug fix.Also, since default_threadlock() supposes that pthread_mutex_lock()cannot fail, try to ensure that that's actually true, by gettingrid of the malloc call that was formerly involved in initializingan emulated mutex. We can define an extra state for the spinlockfield instead.Also, replace the similar code in ecpglib/misc.c with this version.While ecpglib's version at least had a POSIX-compliant API, italso had the potential of failing during mutex init (but here,because of CreateMutex failure rather than malloc failure). Sinceall of misc.c's callers ignore failures, it seems like a wise ideato avoid failures here too.A further improvement in this area could be to unify libpq's andecpglib'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 allsupported branches.Discussion:https://postgr.es/m/264860.1707163416@sss.pgh.pa.us1 parent5c7038d commit0028b55
File tree
6 files changed
+63
-69
lines changed- src
- interfaces
- ecpg
- ecpglib
- include
- libpq
- port
6 files changed
+63
-69
lines changedLines changed: 29 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
407 | 407 |
| |
408 | 408 |
| |
409 | 409 |
| |
410 |
| - | |
411 |
| - | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
412 | 419 |
| |
413 |
| - | |
| 420 | + | |
| 421 | + | |
414 | 422 |
| |
415 |
| - | |
416 |
| - | |
417 |
| - | |
418 |
| - | |
419 |
| - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
420 | 430 |
| |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
421 | 442 |
| |
422 | 443 |
| |
423 | 444 |
| |
|
Lines changed: 8 additions & 14 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
12 | 12 |
| |
13 | 13 |
| |
14 | 14 |
| |
15 |
| - | |
16 |
| - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
17 | 18 |
| |
18 | 19 |
| |
19 | 20 |
| |
20 | 21 |
| |
21 | 22 |
| |
22 |
| - | |
| 23 | + | |
23 | 24 |
| |
24 | 25 |
| |
25 |
| - | |
26 |
| - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
27 | 29 |
| |
28 |
| - | |
29 |
| - | |
30 |
| - | |
31 |
| - | |
32 |
| - | |
33 |
| - | |
34 |
| - | |
35 |
| - | |
36 |
| - | |
| 30 | + | |
37 | 31 |
| |
38 | 32 |
| |
39 | 33 |
| |
|
Lines changed: 0 additions & 16 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7426 | 7426 |
| |
7427 | 7427 |
| |
7428 | 7428 |
| |
7429 |
| - | |
7430 | 7429 |
| |
7431 |
| - | |
7432 |
| - | |
7433 |
| - | |
7434 | 7430 |
| |
7435 |
| - | |
7436 |
| - | |
7437 |
| - | |
7438 |
| - | |
7439 |
| - | |
7440 |
| - | |
7441 |
| - | |
7442 |
| - | |
7443 |
| - | |
7444 |
| - | |
7445 |
| - | |
7446 |
| - | |
7447 | 7431 |
| |
7448 | 7432 |
| |
7449 | 7433 |
| |
|
Lines changed: 0 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
91 | 91 |
| |
92 | 92 |
| |
93 | 93 |
| |
94 |
| - | |
95 | 94 |
| |
96 |
| - | |
97 |
| - | |
98 |
| - | |
99 |
| - | |
100 | 95 |
| |
101 | 96 |
| |
102 | 97 |
| |
| |||
773 | 768 |
| |
774 | 769 |
| |
775 | 770 |
| |
776 |
| - | |
777 |
| - | |
778 |
| - | |
779 |
| - | |
780 |
| - | |
781 |
| - | |
782 |
| - | |
783 |
| - | |
784 |
| - | |
785 |
| - | |
786 |
| - | |
787 |
| - | |
788 |
| - | |
789 |
| - | |
790 | 771 |
| |
791 | 772 |
| |
792 | 773 |
| |
| |||
874 | 855 |
| |
875 | 856 |
| |
876 | 857 |
| |
877 |
| - | |
878 | 858 |
| |
879 | 859 |
| |
880 | 860 |
| |
|
Lines changed: 16 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
34 | 34 |
| |
35 | 35 |
| |
36 | 36 |
| |
37 |
| - | |
38 |
| - | |
39 |
| - | |
40 |
| - | |
| 37 | + | |
41 | 38 |
| |
42 | 39 |
| |
43 | 40 |
| |
44 | 41 |
| |
45 | 42 |
| |
46 | 43 |
| |
47 |
| - | |
48 |
| - | |
49 |
| - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
50 | 56 |
| |
51 | 57 |
| |
52 | 58 |
| |
53 | 59 |
| |
54 | 60 |
| |
55 | 61 |
| |
56 |
| - | |
57 |
| - | |
58 |
| - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
59 | 65 |
| |
60 | 66 |
|
Lines changed: 10 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
5 | 5 |
| |
6 | 6 |
| |
7 | 7 |
| |
8 |
| - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
9 | 18 |
| |
10 | 19 |
| |
11 | 20 |
| |
|
0 commit comments
Comments
(0)