Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
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
brpc
Commits
05227912
Unverified
Commit
05227912
authored
Aug 27, 2018
by
Ge Jun
Committed by
GitHub
Aug 27, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #466 from gydong/master
change the backlog of listen() from INT_MAX to 65535
parents
0b4117d8
fbeffa45
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
endpoint.cpp
src/butil/endpoint.cpp
+10
-9
No files found.
src/butil/endpoint.cpp
View file @
05227912
// Copyright (c) 2011 Baidu, Inc.
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
...
@@ -134,7 +134,7 @@ int hostname2ip(const char* hostname, ip_t* ip) {
struct
hostent
*
result
=
NULL
;
if
(
gethostbyname_r
(
hostname
,
&
ent
,
aux_buf
,
sizeof
(
aux_buf
),
&
result
,
&
error
)
!=
0
||
result
==
NULL
)
{
return
-
1
;
return
-
1
;
}
#endif // defined(OS_MACOSX)
// Only fetch the first address here
...
...
@@ -146,7 +146,7 @@ struct MyAddressInfo {
char
my_hostname
[
256
];
ip_t
my_ip
;
IPStr
my_ip_str
;
MyAddressInfo
()
{
my_ip
=
IP_ANY
;
if
(
gethostname
(
my_hostname
,
sizeof
(
my_hostname
))
<
0
)
{
...
...
@@ -222,7 +222,7 @@ int hostname2endpoint(const char* str, EndPoint* point) {
if
(
i
==
sizeof
(
buf
)
-
1
)
{
return
-
1
;
}
buf
[
i
]
=
'\0'
;
if
(
hostname2ip
(
buf
,
&
point
->
ip
)
!=
0
)
{
return
-
1
;
...
...
@@ -333,13 +333,14 @@ int tcp_listen(EndPoint point, bool reuse_addr) {
bzero
((
char
*
)
&
serv_addr
,
sizeof
(
serv_addr
));
serv_addr
.
sin_family
=
AF_INET
;
serv_addr
.
sin_addr
=
point
.
ip
;
serv_addr
.
sin_port
=
htons
(
point
.
port
);
serv_addr
.
sin_port
=
htons
(
point
.
port
);
if
(
bind
(
sockfd
,
(
struct
sockaddr
*
)
&
serv_addr
,
sizeof
(
serv_addr
))
!=
0
)
{
return
-
1
;
}
if
(
listen
(
sockfd
,
INT_MAX
)
!=
0
)
{
if
(
listen
(
sockfd
,
65535
)
!=
0
)
{
// ^^^ kernel would silently truncate backlog to the value
// defined in /proc/sys/net/core/somaxconn
// defined in /proc/sys/net/core/somaxconn if it is less
// than 65535
return
-
1
;
}
return
sockfd
.
release
();
...
...
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