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
7f7fc050
Commit
7f7fc050
authored
Sep 03, 2019
by
pantianying
Committed by
watermelo
Jul 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add s.grNum for debug
parent
3c6cf46d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
4 deletions
+10
-4
session.go
session.go
+10
-4
No files found.
session.go
View file @
7f7fc050
...
@@ -86,6 +86,8 @@ type session struct {
...
@@ -86,6 +86,8 @@ type session struct {
// attribute
// attribute
attrs
*
ValuesContext
attrs
*
ValuesContext
// goroutines sync
grNum
int32
// read goroutines done signal
// read goroutines done signal
rDone
chan
struct
{}
rDone
chan
struct
{}
lock
sync
.
RWMutex
lock
sync
.
RWMutex
...
@@ -106,6 +108,7 @@ func newSession(endPoint EndPoint, conn Connection) *session {
...
@@ -106,6 +108,7 @@ func newSession(endPoint EndPoint, conn Connection) *session {
wait
:
pendingDuration
,
wait
:
pendingDuration
,
attrs
:
NewValuesContext
(
nil
),
attrs
:
NewValuesContext
(
nil
),
rDone
:
make
(
chan
struct
{}),
rDone
:
make
(
chan
struct
{}),
grNum
:
0
,
}
}
ss
.
Connection
.
setSession
(
ss
)
ss
.
Connection
.
setSession
(
ss
)
...
@@ -471,6 +474,7 @@ func (s *session) run() {
...
@@ -471,6 +474,7 @@ func (s *session) run() {
}
}
// start read/write gr
// start read/write gr
atomic
.
AddInt32
(
&
(
s
.
grNum
),
2
)
go
s
.
handleLoop
()
go
s
.
handleLoop
()
go
s
.
handlePackage
()
go
s
.
handlePackage
()
}
}
...
@@ -494,8 +498,9 @@ func (s *session) handleLoop() {
...
@@ -494,8 +498,9 @@ func (s *session) handleLoop() {
log
.
Errorf
(
"[session.handleLoop] panic session %s: err=%s
\n
%s"
,
s
.
sessionToken
(),
r
,
rBuf
)
log
.
Errorf
(
"[session.handleLoop] panic session %s: err=%s
\n
%s"
,
s
.
sessionToken
(),
r
,
rBuf
)
}
}
grNum
:=
atomic
.
AddInt32
(
&
(
s
.
grNum
),
-
1
)
s
.
listener
.
OnClose
(
s
)
s
.
listener
.
OnClose
(
s
)
log
.
Info
(
"%s, [session.handleLoop] goroutine exit now
"
,
s
.
Stat
()
)
log
.
Info
(
"%s, [session.handleLoop] goroutine exit now
, left gr num %d"
,
s
.
Stat
(),
grNum
)
s
.
gc
()
s
.
gc
()
}()
}()
...
@@ -571,7 +576,8 @@ func (s *session) handlePackage() {
...
@@ -571,7 +576,8 @@ func (s *session) handlePackage() {
}
}
close
(
s
.
rDone
)
close
(
s
.
rDone
)
log
.
Infof
(
"%s, [session.handlePackage] gr will exit now"
,
s
.
sessionToken
())
grNum
:=
atomic
.
AddInt32
(
&
(
s
.
grNum
),
-
1
)
log
.
Infof
(
"%s, [session.handlePackage] gr will exit now, left gr num %d"
,
s
.
sessionToken
(),
grNum
)
s
.
stop
()
s
.
stop
()
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Errorf
(
"%s, [session.handlePackage] error:%+v"
,
s
.
sessionToken
(),
err
)
log
.
Errorf
(
"%s, [session.handlePackage] error:%+v"
,
s
.
sessionToken
(),
err
)
...
@@ -848,6 +854,6 @@ func (s *session) gc() {
...
@@ -848,6 +854,6 @@ func (s *session) gc() {
// or (session)handleLoop automatically. It's thread safe.
// or (session)handleLoop automatically. It's thread safe.
func
(
s
*
session
)
Close
()
{
func
(
s
*
session
)
Close
()
{
s
.
stop
()
s
.
stop
()
log
.
Info
(
"%s closed now."
,
log
.
Info
(
"%s closed now.
its current gr num is %d
"
,
s
.
sessionToken
())
s
.
sessionToken
()
,
atomic
.
LoadInt32
(
&
(
s
.
grNum
))
)
}
}
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