Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
7e36a880
Commit
7e36a880
authored
Apr 11, 2015
by
Xiang Li
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pkg/proxy: a more reliable way to detect a closed proxy
parent
aa804ffb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
proxier.go
pkg/proxy/proxier.go
+16
-6
No files found.
pkg/proxy/proxier.go
View file @
7e36a880
...
...
@@ -94,19 +94,22 @@ func (tcp *tcpProxySocket) ProxyLoop(service ServicePortName, myInfo *serviceInf
for
{
if
info
,
exists
:=
proxier
.
getServiceInfo
(
service
);
!
exists
||
info
!=
myInfo
{
// The service port was closed or replaced.
break
return
}
// Block until a connection is made.
inConn
,
err
:=
tcp
.
Accept
()
if
err
!=
nil
{
if
info
,
exists
:=
proxier
.
getServiceInfo
(
service
);
!
exists
||
info
!=
myInfo
{
// Then the service port was just closed so the accept failure is to be expected.
break
}
if
isTooManyFDsError
(
err
)
{
panic
(
"Accept failed: "
+
err
.
Error
())
}
if
isClosedError
(
err
)
{
return
}
if
info
,
exists
:=
proxier
.
getServiceInfo
(
service
);
!
exists
||
info
!=
myInfo
{
// Then the service port was just closed so the accept failure is to be expected.
return
}
glog
.
Errorf
(
"Accept failed: %v"
,
err
)
continue
}
...
...
@@ -801,3 +804,10 @@ func (proxier *Proxier) iptablesHostPortalArgs(destIP net.IP, destPort int, prot
func
isTooManyFDsError
(
err
error
)
bool
{
return
strings
.
Contains
(
err
.
Error
(),
"too many open files"
)
}
func
isClosedError
(
err
error
)
bool
{
// A brief discussion about handling closed error here:
// https://code.google.com/p/go/issues/detail?id=4373#c14
// TODO: maybe create a stoppable TCP listener that returns a StoppedError
return
strings
.
HasSuffix
(
err
.
Error
(),
"use of closed network connection"
)
}
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