Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
getty
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wei.xuan
getty
Commits
e1bbe623
Commit
e1bbe623
authored
Feb 09, 2017
by
AlexStocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete shutdown
parent
97fc48e6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
12 deletions
+15
-12
client.go
client.go
+1
-1
server.go
server.go
+14
-11
No files found.
client.go
View file @
e1bbe623
...
...
@@ -183,7 +183,7 @@ func (c *Client) dialWSS() Session {
dialer
.
EnableCompression
=
true
config
=
&
tls
.
Config
{
//
InsecureSkipVerify: true,
InsecureSkipVerify
:
true
,
}
gxlog
.
CInfo
(
"client cert:%s, key:%s, caCert:%s"
,
c
.
cert
,
c
.
privateKey
,
c
.
caCert
)
...
...
server.go
View file @
e1bbe623
...
...
@@ -10,7 +10,7 @@
package
getty
import
(
"context"
//
"context"
"crypto/tls"
"crypto/x509"
"errors"
...
...
@@ -54,8 +54,8 @@ func NewServer() *Server {
func
(
s
*
Server
)
stop
()
{
var
(
err
error
ctx
context
.
Context
//
err error
//
ctx context.Context
)
select
{
case
<-
s
.
done
:
...
...
@@ -65,12 +65,12 @@ func (s *Server) stop() {
close
(
s
.
done
)
s
.
lock
.
Lock
()
if
s
.
server
!=
nil
{
ctx
,
_
=
context
.
WithTimeout
(
context
.
Background
(),
serverFastFailTimeout
)
if
err
=
s
.
server
.
Shutdown
(
ctx
);
err
!=
nil
{
// 如果下面内容输出为:server shutdown ctx: context deadline exceeded,
// 则说明有未处理完的active connections。
log
.
Error
(
"server shutdown ctx:%#v"
,
err
)
}
//
ctx, _ = context.WithTimeout(context.Background(), serverFastFailTimeout)
//
if err = s.server.Shutdown(ctx); err != nil {
//
// 如果下面内容输出为:server shutdown ctx: context deadline exceeded,
//
// 则说明有未处理完的active connections。
//
log.Error("server shutdown ctx:%#v", err)
//
}
}
s
.
lock
.
Unlock
()
// 把listener.Close放在这里,既能防止多次关闭调用,
...
...
@@ -266,11 +266,14 @@ func (s *Server) RunWSSEventLoop(
server
*
http
.
Server
)
config
=
&
tls
.
Config
{
InsecureSkipVerify
:
true
}
config
=
&
tls
.
Config
{
InsecureSkipVerify
:
true
,
ClientAuth
:
tls
.
NoClientCert
,
}
config
.
Certificates
=
make
([]
tls
.
Certificate
,
1
)
gxlog
.
CInfo
(
"server cert:%s, key:%s, caCert:%s"
,
cert
,
privateKey
,
caCert
)
if
config
.
Certificates
[
0
],
err
=
tls
.
LoadX509KeyPair
(
cert
,
privateKey
);
err
!=
nil
{
log
.
Error
(
"tls.LoadX509KeyPair(cert{%s}, privateKey{%s}) = err{%#v}"
,
cert
,
privateKey
,
err
)
panic
(
fmt
.
Sprintf
(
"tls.LoadX509KeyPair(cert{%s}, privateKey{%s}) = err{%#v}"
,
cert
,
privateKey
,
err
)
)
return
}
...
...
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