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
c097d154
Commit
c097d154
authored
Sep 18, 2016
by
alexstocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add remark
parent
567fa0c4
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
14 deletions
+22
-14
README.md
README.md
+5
-0
session.go
session.go
+16
-13
version.go
version.go
+1
-1
No files found.
README.md
View file @
c097d154
...
...
@@ -11,6 +11,11 @@
## develop history ##
---
-
2016/09/18
> 1 close Session{rQ} in session.go:(Session)handlePackage
>
> 2 version: 0.3.09
-
2016/09/12
> 1 add defeat self connection logic in client.go & server.go
>
...
...
session.go
View file @
c097d154
...
...
@@ -356,6 +356,7 @@ func (this *Session) handleLoop() {
var
(
err
error
flag
bool
rQFlag
bool
// start time.Time
counter
CountWatch
ticker
*
time
.
Ticker
...
...
@@ -401,14 +402,16 @@ LOOP:
}
}
case
inPkg
=
<-
this
.
rQ
:
case
inPkg
,
rQFlag
=
<-
this
.
rQ
:
// 这个条件分支通过(Session)rQ排空确保(Session)handlePackage gr不会阻塞在(Session)rQ上
if
rQFlag
{
if
flag
{
this
.
listener
.
OnMessage
(
this
,
inPkg
)
this
.
incReadPkgCount
()
}
else
{
log
.
Info
(
"[session.handleLoop] drop readin package{%#v}"
,
inPkg
)
}
}
case
outPkg
=
<-
this
.
wQ
:
if
flag
{
...
...
@@ -459,11 +462,12 @@ func (this *Session) handlePackage() {
}
this
.
stop
()
close
(
this
.
rQ
)
// close(this.readerDone)
grNum
=
atomic
.
AddInt32
(
&
(
this
.
grNum
),
-
1
)
log
.
Info
(
"%s, [session.handlePackage] gr will exit now, left gr num %d"
,
this
.
sessionToken
(),
grNum
)
if
errFlag
{
log
.
Info
(
"%s, [session.handlePackage] errFlag"
,
this
.
sessionToken
()
)
log
.
Error
(
"%s, [session.handlePackage] error{%#v}"
,
this
.
sessionToken
(),
err
)
this
.
listener
.
OnError
(
this
,
err
)
}
}()
...
...
@@ -524,7 +528,7 @@ func (this *Session) handlePackage() {
func
(
this
*
Session
)
stop
()
{
select
{
case
<-
this
.
done
:
case
<-
this
.
done
:
// this.done is a blocked channel. if it has not been closed, the default branch will be invoked.
return
default
:
...
...
@@ -543,7 +547,7 @@ func (this *Session) gc() {
// }
close
(
this
.
wQ
)
this
.
wQ
=
nil
close
(
this
.
rQ
)
//
close(this.rQ)
this
.
rQ
=
nil
this
.
gettyConn
.
close
((
int
)((
int64
)(
this
.
wait
)))
}
...
...
@@ -554,6 +558,5 @@ func (this *Session) gc() {
// It is goroutine-safe to be invoked many times.
func
(
this
*
Session
)
Close
()
{
this
.
stop
()
log
.
Info
(
"%s closed now, its current gr num %d"
,
this
.
sessionToken
(),
atomic
.
LoadInt32
(
&
(
this
.
grNum
)))
log
.
Info
(
"%s closed now, its current gr num %d"
,
this
.
sessionToken
(),
atomic
.
LoadInt32
(
&
(
this
.
grNum
)))
}
version.go
View file @
c097d154
...
...
@@ -10,5 +10,5 @@
package
getty
var
(
Version
=
"0.3.0
8
"
Version
=
"0.3.0
9
"
)
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