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 @@
...
@@ -11,6 +11,11 @@
## develop history ##
## develop history ##
---
---
-
2016/09/18
> 1 close Session{rQ} in session.go:(Session)handlePackage
>
> 2 version: 0.3.09
-
2016/09/12
-
2016/09/12
> 1 add defeat self connection logic in client.go & server.go
> 1 add defeat self connection logic in client.go & server.go
>
>
...
...
session.go
View file @
c097d154
...
@@ -356,6 +356,7 @@ func (this *Session) handleLoop() {
...
@@ -356,6 +356,7 @@ func (this *Session) handleLoop() {
var
(
var
(
err
error
err
error
flag
bool
flag
bool
rQFlag
bool
// start time.Time
// start time.Time
counter
CountWatch
counter
CountWatch
ticker
*
time
.
Ticker
ticker
*
time
.
Ticker
...
@@ -401,14 +402,16 @@ LOOP:
...
@@ -401,14 +402,16 @@ LOOP:
}
}
}
}
case
inPkg
=
<-
this
.
rQ
:
case
inPkg
,
rQFlag
=
<-
this
.
rQ
:
// 这个条件分支通过(Session)rQ排空确保(Session)handlePackage gr不会阻塞在(Session)rQ上
// 这个条件分支通过(Session)rQ排空确保(Session)handlePackage gr不会阻塞在(Session)rQ上
if
rQFlag
{
if
flag
{
if
flag
{
this
.
listener
.
OnMessage
(
this
,
inPkg
)
this
.
listener
.
OnMessage
(
this
,
inPkg
)
this
.
incReadPkgCount
()
this
.
incReadPkgCount
()
}
else
{
}
else
{
log
.
Info
(
"[session.handleLoop] drop readin package{%#v}"
,
inPkg
)
log
.
Info
(
"[session.handleLoop] drop readin package{%#v}"
,
inPkg
)
}
}
}
case
outPkg
=
<-
this
.
wQ
:
case
outPkg
=
<-
this
.
wQ
:
if
flag
{
if
flag
{
...
@@ -459,11 +462,12 @@ func (this *Session) handlePackage() {
...
@@ -459,11 +462,12 @@ func (this *Session) handlePackage() {
}
}
this
.
stop
()
this
.
stop
()
close
(
this
.
rQ
)
// close(this.readerDone)
// close(this.readerDone)
grNum
=
atomic
.
AddInt32
(
&
(
this
.
grNum
),
-
1
)
grNum
=
atomic
.
AddInt32
(
&
(
this
.
grNum
),
-
1
)
log
.
Info
(
"%s, [session.handlePackage] gr will exit now, left gr num %d"
,
this
.
sessionToken
(),
grNum
)
log
.
Info
(
"%s, [session.handlePackage] gr will exit now, left gr num %d"
,
this
.
sessionToken
(),
grNum
)
if
errFlag
{
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
)
this
.
listener
.
OnError
(
this
,
err
)
}
}
}()
}()
...
@@ -524,7 +528,7 @@ func (this *Session) handlePackage() {
...
@@ -524,7 +528,7 @@ func (this *Session) handlePackage() {
func
(
this
*
Session
)
stop
()
{
func
(
this
*
Session
)
stop
()
{
select
{
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
return
default
:
default
:
...
@@ -543,7 +547,7 @@ func (this *Session) gc() {
...
@@ -543,7 +547,7 @@ func (this *Session) gc() {
// }
// }
close
(
this
.
wQ
)
close
(
this
.
wQ
)
this
.
wQ
=
nil
this
.
wQ
=
nil
close
(
this
.
rQ
)
//
close(this.rQ)
this
.
rQ
=
nil
this
.
rQ
=
nil
this
.
gettyConn
.
close
((
int
)((
int64
)(
this
.
wait
)))
this
.
gettyConn
.
close
((
int
)((
int64
)(
this
.
wait
)))
}
}
...
@@ -554,6 +558,5 @@ func (this *Session) gc() {
...
@@ -554,6 +558,5 @@ func (this *Session) gc() {
// It is goroutine-safe to be invoked many times.
// It is goroutine-safe to be invoked many times.
func
(
this
*
Session
)
Close
()
{
func
(
this
*
Session
)
Close
()
{
this
.
stop
()
this
.
stop
()
log
.
Info
(
"%s closed now, its current gr num %d"
,
log
.
Info
(
"%s closed now, its current gr num %d"
,
this
.
sessionToken
(),
atomic
.
LoadInt32
(
&
(
this
.
grNum
)))
this
.
sessionToken
(),
atomic
.
LoadInt32
(
&
(
this
.
grNum
)))
}
}
version.go
View file @
c097d154
...
@@ -10,5 +10,5 @@
...
@@ -10,5 +10,5 @@
package
getty
package
getty
var
(
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