Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
capnproto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
capnproto
Commits
8f43164a
Commit
8f43164a
authored
Apr 21, 2019
by
Kenton Varda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup: Remove dead code in KJ async.
parent
ac70b2fe
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
65 deletions
+0
-65
async-io-unix.c++
c++/src/kj/async-io-unix.c++
+0
-65
No files found.
c++/src/kj/async-io-unix.c++
View file @
8f43164a
...
...
@@ -549,71 +549,6 @@ private:
}
}
}
template
<
typename
T
>
kj
::
Promise
<
kj
::
Maybe
<
T
>>
tryReceiveFdImpl
()
{
struct
msghdr
msg
;
memset
(
&
msg
,
0
,
sizeof
(
msg
));
struct
iovec
iov
;
memset
(
&
iov
,
0
,
sizeof
(
iov
));
char
c
;
iov
.
iov_base
=
&
c
;
iov
.
iov_len
=
1
;
msg
.
msg_iov
=
&
iov
;
msg
.
msg_iovlen
=
1
;
// Allocate space to receive a cmsg.
union
{
struct
cmsghdr
cmsg
;
char
cmsgSpace
[
CMSG_SPACE
(
sizeof
(
int
))];
};
msg
.
msg_control
=
&
cmsg
;
msg
.
msg_controllen
=
sizeof
(
cmsgSpace
);
#ifdef MSG_CMSG_CLOEXEC
int
recvmsgFlags
=
MSG_CMSG_CLOEXEC
;
#else
int
recvmsgFlags
=
0
;
#endif
ssize_t
n
;
KJ_NONBLOCKING_SYSCALL
(
n
=
recvmsg
(
fd
,
&
msg
,
recvmsgFlags
));
if
(
n
<
0
)
{
return
observer
.
whenBecomesReadable
().
then
([
this
]()
{
return
tryReceiveFdImpl
<
T
>
();
});
}
else
if
(
n
==
0
)
{
return
kj
::
Maybe
<
T
>
(
nullptr
);
}
else
{
KJ_REQUIRE
(
msg
.
msg_controllen
>=
sizeof
(
cmsg
),
"expected to receive FD over socket; received data instead"
);
// We expect an SCM_RIGHTS message with a single FD.
KJ_REQUIRE
(
cmsg
.
cmsg_level
==
SOL_SOCKET
);
KJ_REQUIRE
(
cmsg
.
cmsg_type
==
SCM_RIGHTS
);
KJ_REQUIRE
(
cmsg
.
cmsg_len
==
CMSG_LEN
(
sizeof
(
int
)));
int
receivedFd
;
memcpy
(
&
receivedFd
,
CMSG_DATA
(
&
cmsg
),
sizeof
(
receivedFd
));
return
kj
::
Maybe
<
T
>
(
wrapFd
(
receivedFd
,
(
T
*
)
nullptr
));
}
}
AutoCloseFd
wrapFd
(
int
newFd
,
AutoCloseFd
*
)
{
auto
result
=
AutoCloseFd
(
newFd
);
#ifndef MSG_CMSG_CLOEXEC
setCloseOnExec
(
result
);
#endif
return
result
;
}
Own
<
AsyncCapabilityStream
>
wrapFd
(
int
newFd
,
Own
<
AsyncCapabilityStream
>*
)
{
return
kj
::
heap
<
AsyncStreamFd
>
(
eventPort
,
newFd
,
#ifdef MSG_CMSG_CLOEXEC
LowLevelAsyncIoProvider
::
ALREADY_CLOEXEC
|
#endif
LowLevelAsyncIoProvider
::
TAKE_OWNERSHIP
);
}
};
// =======================================================================================
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment