Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
G
gost
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
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
nanahira
gost
Commits
085b0b30
Commit
085b0b30
authored
Jan 09, 2020
by
ginuerzh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix http2 failover
parent
7eea9b3a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
5 deletions
+19
-5
http2.go
http2.go
+19
-5
No files found.
http2.go
View file @
085b0b30
...
@@ -79,6 +79,7 @@ func (c *http2Connector) Connect(conn net.Conn, addr string, options ...ConnectO
...
@@ -79,6 +79,7 @@ func (c *http2Connector) Connect(conn net.Conn, addr string, options ...ConnectO
}
}
resp
,
err
:=
cc
.
client
.
Do
(
req
)
resp
,
err
:=
cc
.
client
.
Do
(
req
)
if
err
!=
nil
{
if
err
!=
nil
{
cc
.
Close
()
return
nil
,
err
return
nil
,
err
}
}
if
Debug
{
if
Debug
{
...
@@ -130,11 +131,11 @@ func (tr *http2Transporter) Dial(addr string, options ...DialOption) (net.Conn,
...
@@ -130,11 +131,11 @@ func (tr *http2Transporter) Dial(addr string, options ...DialOption) (net.Conn,
client
,
ok
:=
tr
.
clients
[
addr
]
client
,
ok
:=
tr
.
clients
[
addr
]
if
!
ok
{
if
!
ok
{
// NOTE: due to the dummy connection, HTTP2 node in a proxy chain can not be marked as dead.
// NOTE: There is no real connection to the HTTP2 server at this moment.
// There is no real connection to the HTTP2 server at this moment.
// So we try to connect to the server to check the server health.
// So we should try to connect the server.
conn
,
err
:=
opts
.
Chain
.
Dial
(
addr
)
conn
,
err
:=
opts
.
Chain
.
Dial
(
addr
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Log
(
"http2 dial:"
,
addr
,
err
)
return
nil
,
err
return
nil
,
err
}
}
conn
.
Close
()
conn
.
Close
()
...
@@ -163,6 +164,11 @@ func (tr *http2Transporter) Dial(addr string, options ...DialOption) (net.Conn,
...
@@ -163,6 +164,11 @@ func (tr *http2Transporter) Dial(addr string, options ...DialOption) (net.Conn,
return
&
http2ClientConn
{
return
&
http2ClientConn
{
addr
:
addr
,
addr
:
addr
,
client
:
client
,
client
:
client
,
onClose
:
func
()
{
tr
.
clientMutex
.
Lock
()
defer
tr
.
clientMutex
.
Unlock
()
delete
(
tr
.
clients
,
addr
)
},
},
nil
},
nil
}
}
...
@@ -891,6 +897,14 @@ type http2ClientConn struct {
...
@@ -891,6 +897,14 @@ type http2ClientConn struct {
nopConn
nopConn
addr
string
addr
string
client
*
http
.
Client
client
*
http
.
Client
onClose
func
()
}
func
(
c
*
http2ClientConn
)
Close
()
error
{
if
c
.
onClose
!=
nil
{
c
.
onClose
()
}
return
nil
}
}
type
flushWriter
struct
{
type
flushWriter
struct
{
...
...
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