mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-13 10:15:00 +00:00
Use socketpair syscall when available
This commit is contained in:
@@ -356,6 +356,13 @@ static void accept_conn(struct mg_mgr *mgr, struct mg_connection *lsn) {
|
||||
|
||||
#if MG_ENABLE_SOCKETPAIR
|
||||
bool mg_socketpair(int *s1, int *s2) {
|
||||
#if MG_ARCH == MG_ARCH_UNIX
|
||||
int sp[2], ret = 0;
|
||||
if (socketpair(AF_INET, SOCK_DGRAM, 0) == 0) {
|
||||
*s1 = sp[0], *s2 = sp[1], ret = 1;
|
||||
}
|
||||
return ret;
|
||||
#else
|
||||
union usa sa, sa2;
|
||||
SOCKET sp[2] = {INVALID_SOCKET, INVALID_SOCKET};
|
||||
socklen_t len = sizeof(sa.sin);
|
||||
@@ -382,6 +389,7 @@ bool mg_socketpair(int *s1, int *s2) {
|
||||
}
|
||||
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user