forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitbfc9497
committed
libpq: Use modern socket flags, if available.
Since commit7627b91, libpq has used FD_CLOEXEC so that socketswouldn't be leaked to subprograms. With enough bad luck, amulti-threaded program might fork in between the socket() and fcntl()calls. We can close that tiny gap by using SOCK_CLOEXEC instead of aseparate call. While here, we might as well do the same forSOCK_NONBLOCK, to save another syscall.These flags are expected to appear in the next revision of the POSIXstandard, specifically to address this problem. Our Unixoid targetsexcept macOS and AIX have had them for a long time, and macOS wouldhopefully use guarded availability to roll them out, so it seems enoughto use a simple ifdef test for availability until we hear otherwise.Windows doesn't have them, but has non-inheritable sockets by default.Discussion:https://postgr.es/m/CA%2BhUKGKb6FsAdQWcRL35KJsftv%2B9zXqQbzwkfRf1i0J2e57%2BhQ%40mail.gmail.com1 parent95a8283 commitbfc9497
1 file changed
+25
-1
lines changedLines changed: 25 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2629 | 2629 |
| |
2630 | 2630 |
| |
2631 | 2631 |
| |
| 2632 | + | |
2632 | 2633 |
| |
2633 | 2634 |
| |
2634 | 2635 |
| |
| |||
2659 | 2660 |
| |
2660 | 2661 |
| |
2661 | 2662 |
| |
2662 |
| - | |
| 2663 | + | |
| 2664 | + | |
| 2665 | + | |
| 2666 | + | |
| 2667 | + | |
| 2668 | + | |
| 2669 | + | |
| 2670 | + | |
| 2671 | + | |
| 2672 | + | |
| 2673 | + | |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
| 2681 | + | |
| 2682 | + | |
2663 | 2683 |
| |
2664 | 2684 |
| |
2665 | 2685 |
| |
| |||
2705 | 2725 |
| |
2706 | 2726 |
| |
2707 | 2727 |
| |
| 2728 | + | |
2708 | 2729 |
| |
2709 | 2730 |
| |
2710 | 2731 |
| |
2711 | 2732 |
| |
2712 | 2733 |
| |
2713 | 2734 |
| |
2714 | 2735 |
| |
| 2736 | + | |
2715 | 2737 |
| |
| 2738 | + | |
2716 | 2739 |
| |
2717 | 2740 |
| |
2718 | 2741 |
| |
| |||
2722 | 2745 |
| |
2723 | 2746 |
| |
2724 | 2747 |
| |
| 2748 | + | |
2725 | 2749 |
| |
2726 | 2750 |
| |
2727 | 2751 |
| |
|
0 commit comments
Comments
(0)