Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
nghttp2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
nghttp2
Commits
fcf0ceea
Commit
fcf0ceea
authored
Jan 05, 2015
by
Tatsuhiro Tsujikawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nghttpd: Make use of accept4
parent
e253d8f6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
17 deletions
+20
-17
configure.ac
configure.ac
+1
-0
src/HttpServer.cc
src/HttpServer.cc
+9
-17
src/util.cc
src/util.cc
+10
-0
No files found.
configure.ac
View file @
fcf0ceea
...
...
@@ -520,6 +520,7 @@ if test "x$cross_compiling" != "xyes"; then
fi
AC_CHECK_FUNCS([ \
_Exit \
accept4 \
getpwnam \
memmove \
memset \
...
...
src/HttpServer.cc
View file @
fcf0ceea
...
...
@@ -64,18 +64,6 @@ const std::string DEFAULT_HTML = "index.html";
const
std
::
string
NGHTTPD_SERVER
=
"nghttpd nghttp2/"
NGHTTP2_VERSION
;
}
// namespace
namespace
{
int
make_socket_nonblocking
(
int
fd
)
{
int
flags
;
int
rv
;
while
((
flags
=
fcntl
(
fd
,
F_GETFL
,
0
))
==
-
1
&&
errno
==
EINTR
)
;
while
((
rv
=
fcntl
(
fd
,
F_SETFL
,
flags
|
O_NONBLOCK
))
==
-
1
&&
errno
==
EINTR
)
;
return
rv
;
}
}
// namespace
namespace
{
void
delete_handler
(
Http2Handler
*
handler
)
{
handler
->
remove_self
();
...
...
@@ -235,9 +223,7 @@ public:
}
const
nghttp2_session_callbacks
*
get_callbacks
()
const
{
return
callbacks_
;
}
void
accept_connection
(
int
fd
)
{
int
val
=
1
;
(
void
)
setsockopt
(
fd
,
IPPROTO_TCP
,
TCP_NODELAY
,
reinterpret_cast
<
char
*>
(
&
val
),
sizeof
(
val
));
util
::
make_socket_nodelay
(
fd
);
SSL
*
ssl
=
nullptr
;
if
(
ssl_ctx_
)
{
ssl
=
ssl_session_new
(
fd
);
...
...
@@ -1397,14 +1383,20 @@ public:
}
void
accept_connection
()
{
for
(;;)
{
#ifdef HAVE_ACCEPT4
auto
fd
=
accept4
(
fd_
,
nullptr
,
nullptr
,
SOCK_NONBLOCK
);
#else // !HAVE_ACCEPT4
auto
fd
=
accept
(
fd_
,
nullptr
,
nullptr
);
#endif // !HAVE_ACCEPT4
if
(
fd
==
-
1
)
{
if
(
errno
==
EAGAIN
||
errno
==
EWOULDBLOCK
)
{
break
;
}
continue
;
}
make_socket_nonblocking
(
fd
);
#ifndef HAVE_ACCEPT4
util
::
make_socket_nonblocking
(
fd
);
#endif // !HAVE_ACCEPT4
acceptor_
->
accept_connection
(
fd
);
}
}
...
...
@@ -1478,7 +1470,7 @@ int start_listen(struct ev_loop *loop, Sessions *sessions,
close
(
fd
);
continue
;
}
make_socket_nonblocking
(
fd
);
util
::
make_socket_nonblocking
(
fd
);
#ifdef IPV6_V6ONLY
if
(
rp
->
ai_family
==
AF_INET6
)
{
if
(
setsockopt
(
fd
,
IPPROTO_IPV6
,
IPV6_V6ONLY
,
&
val
,
...
...
src/util.cc
View file @
fcf0ceea
...
...
@@ -839,6 +839,16 @@ int make_socket_closeonexec(int fd) {
return
rv
;
}
int
make_socket_nonblocking
(
int
fd
)
{
int
flags
;
int
rv
;
while
((
flags
=
fcntl
(
fd
,
F_GETFL
,
0
))
==
-
1
&&
errno
==
EINTR
)
;
while
((
rv
=
fcntl
(
fd
,
F_SETFL
,
flags
|
O_NONBLOCK
))
==
-
1
&&
errno
==
EINTR
)
;
return
rv
;
}
int
make_socket_nodelay
(
int
fd
)
{
int
val
=
1
;
if
(
setsockopt
(
fd
,
IPPROTO_TCP
,
TCP_NODELAY
,
reinterpret_cast
<
char
*>
(
&
val
),
...
...
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