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
450e6da2
Commit
450e6da2
authored
Mar 10, 2018
by
AlexStocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add timeout for Session:WritePkg
parent
e7d1b729
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
9 deletions
+6
-9
change_log.md
change_log.md
+1
-0
session.go
session.go
+5
-9
No files found.
change_log.md
View file @
450e6da2
...
...
@@ -17,6 +17,7 @@
*
2 wDeadline -> wTimeout
*
3 disable readtimeout in gettyWSConn:read
*
4 add gettyWSConn:updateWriteDeadline
*
5 add timeout for Session:WritePkg
-
2018/03/08
> feature
...
...
session.go
View file @
450e6da2
...
...
@@ -77,7 +77,7 @@ type Session interface {
SetAttribute
(
interface
{},
interface
{})
RemoveAttribute
(
interface
{})
WritePkg
(
interface
{})
error
WritePkg
(
interface
{}
,
time
.
Duration
)
error
WriteBytes
([]
byte
)
error
WriteBytesArray
(
...
[]
byte
)
error
Close
()
...
...
@@ -340,7 +340,7 @@ func (s *session) sessionToken() string {
}
// Queued Write, for handler
func
(
s
*
session
)
WritePkg
(
pkg
interface
{})
error
{
func
(
s
*
session
)
WritePkg
(
pkg
interface
{}
,
timeout
time
.
Duration
)
error
{
if
s
.
IsClosed
()
{
return
ErrSessionClosed
}
...
...
@@ -354,18 +354,14 @@ func (s *session) WritePkg(pkg interface{}) error {
}
}()
var
d
=
s
.
writeTimeout
()
if
d
>
netIOTimeout
{
d
=
netIOTimeout
if
timeout
<=
0
{
timeout
=
netIOTimeout
}
select
{
case
s
.
wQ
<-
pkg
:
break
// for possible gen a new pkg
// default:
// case <-time.After(s.wTimeout):
// case <-time.After(netIOTimeout):
case
<-
wheel
.
After
(
d
)
:
case
<-
wheel
.
After
(
timeout
)
:
log
.
Warn
(
"%s, [session.WritePkg] wQ{len:%d, cap:%d}"
,
s
.
Stat
(),
len
(
s
.
wQ
),
cap
(
s
.
wQ
))
return
ErrSessionBlocked
}
...
...
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