Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit30829e5

Browse files
committed
Add WL_SOCKET_ACCEPT event to WaitEventSet API.
To be able to handle incoming connections on a server socket withthe WaitEventSet API, we'll need a new kind of event to indicate thatthe the socket is ready to accept a connection.On Unix, it's just the same as WL_SOCKET_READABLE, but on Windows thereis a different underlying kernel event that we need to map ourabstraction to.No user yet, but a proposed patch would use this.Reviewed-by: Andres Freund <andres@anarazel.de>Discussion:https://postgr.es/m/CA%2BhUKG%2BZ-HpOj1JsO9eWUP%2Bar7npSVinsC_npxSy%2BjdOMsx%3DGg%40mail.gmail.com
1 parentf4f2f2b commit30829e5

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

‎src/backend/storage/ipc/latch.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,9 @@ FreeWaitEventSet(WaitEventSet *set)
864864
* - WL_SOCKET_CONNECTED: Wait for socket connection to be established,
865865
* can be combined with other WL_SOCKET_* events (on non-Windows
866866
* platforms, this is the same as WL_SOCKET_WRITEABLE)
867+
* - WL_SOCKET_ACCEPT: Wait for new connection to a server socket,
868+
* can be combined with other WL_SOCKET_* events (on non-Windows
869+
* platforms, this is the same as WL_SOCKET_READABLE)
867870
* - WL_SOCKET_CLOSED: Wait for socket to be closed by remote peer.
868871
* - WL_EXIT_ON_PM_DEATH: Exit immediately if the postmaster dies
869872
*
@@ -874,7 +877,7 @@ FreeWaitEventSet(WaitEventSet *set)
874877
* i.e. it must be a process-local latch initialized with InitLatch, or a
875878
* shared latch associated with the current process by calling OwnLatch.
876879
*
877-
* In the WL_SOCKET_READABLE/WRITEABLE/CONNECTED cases, EOF and error
880+
* In the WL_SOCKET_READABLE/WRITEABLE/CONNECTED/ACCEPT cases, EOF and error
878881
* conditions cause the socket to be reported as readable/writable/connected,
879882
* so that the caller can deal with the condition.
880883
*
@@ -1312,6 +1315,8 @@ WaitEventAdjustWin32(WaitEventSet *set, WaitEvent *event)
13121315
flags |=FD_WRITE;
13131316
if (event->events&WL_SOCKET_CONNECTED)
13141317
flags |=FD_CONNECT;
1318+
if (event->events&WL_SOCKET_ACCEPT)
1319+
flags |=FD_ACCEPT;
13151320

13161321
if (*handle==WSA_INVALID_EVENT)
13171322
{
@@ -2067,6 +2072,12 @@ WaitEventSetWaitBlock(WaitEventSet *set, int cur_timeout,
20672072
/* connected */
20682073
occurred_events->events |=WL_SOCKET_CONNECTED;
20692074
}
2075+
if ((cur_event->events&WL_SOCKET_ACCEPT)&&
2076+
(resEvents.lNetworkEvents&FD_ACCEPT))
2077+
{
2078+
/* incoming connection could be accepted */
2079+
occurred_events->events |=WL_SOCKET_ACCEPT;
2080+
}
20702081
if (resEvents.lNetworkEvents&FD_CLOSE)
20712082
{
20722083
/* EOF/error, so signal all caller-requested socket flags */

‎src/include/storage/latch.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,16 @@ typedef struct Latch
135135
#defineWL_SOCKET_CONNECTED WL_SOCKET_WRITEABLE
136136
#endif
137137
#defineWL_SOCKET_CLOSED (1 << 7)
138+
#ifdefWIN32
139+
#defineWL_SOCKET_ACCEPT (1 << 8)
140+
#else
141+
/* avoid having to deal with case on platforms not requiring it */
142+
#defineWL_SOCKET_ACCEPTWL_SOCKET_READABLE
143+
#endif
138144
#defineWL_SOCKET_MASK(WL_SOCKET_READABLE | \
139145
WL_SOCKET_WRITEABLE | \
140146
WL_SOCKET_CONNECTED | \
147+
WL_SOCKET_ACCEPT | \
141148
WL_SOCKET_CLOSED)
142149

143150
typedefstructWaitEvent

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp