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
36ec376d
Commit
36ec376d
authored
Aug 29, 2016
by
alexstocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename reconnect to errFlag
parent
7b7480dc
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
22 deletions
+29
-22
README.md
README.md
+5
-1
session.go
session.go
+23
-20
version.go
version.go
+1
-1
No files found.
README.md
View file @
36ec376d
...
@@ -9,6 +9,10 @@
...
@@ -9,6 +9,10 @@
## develop history ##
## develop history ##
---
---
-
2016/08/29
> 1 rename reconnect to errFlag in function session.go:(Session)handlePackage
>
> 2 version: 0.2.07
-
2016/08/25
-
2016/08/25
> 1 move close done to once clause in server.go:(Server)stop
> 1 move close done to once clause in server.go:(Server)stop
...
...
session.go
View file @
36ec376d
...
@@ -33,7 +33,7 @@ const (
...
@@ -33,7 +33,7 @@ const (
)
)
var
(
var
(
connID
uint32
=
0
connID
uint32
ErrSessionClosed
=
errors
.
New
(
"Session Already Closed"
)
ErrSessionClosed
=
errors
.
New
(
"Session Already Closed"
)
ErrSessionBlocked
=
errors
.
New
(
"Session full blocked"
)
ErrSessionBlocked
=
errors
.
New
(
"Session full blocked"
)
)
)
...
@@ -56,12 +56,14 @@ func newGettyConn(conn net.Conn) *gettyConn {
...
@@ -56,12 +56,14 @@ func newGettyConn(conn net.Conn) *gettyConn {
}
}
func
(
this
*
gettyConn
)
read
(
p
[]
byte
)
(
int
,
error
)
{
func
(
this
*
gettyConn
)
read
(
p
[]
byte
)
(
int
,
error
)
{
atomic
.
AddUint32
(
&
this
.
readCount
,
1
)
// atomic.AddUint32(&this.readCount, 1)
atomic
.
AddUint32
(
&
this
.
readCount
,
(
uint32
)(
len
(
p
)))
return
this
.
conn
.
Read
(
p
)
return
this
.
conn
.
Read
(
p
)
}
}
func
(
this
*
gettyConn
)
write
(
p
[]
byte
)
(
int
,
error
)
{
func
(
this
*
gettyConn
)
write
(
p
[]
byte
)
(
int
,
error
)
{
atomic
.
AddUint32
(
&
this
.
writeCount
,
1
)
// atomic.AddUint32(&this.writeCount, 1)
atomic
.
AddUint32
(
&
this
.
writeCount
,
(
uint32
)(
len
(
p
)))
return
this
.
conn
.
Write
(
p
)
return
this
.
conn
.
Write
(
p
)
}
}
...
@@ -254,8 +256,9 @@ func (this *Session) Close() {
...
@@ -254,8 +256,9 @@ func (this *Session) Close() {
func
(
this
*
Session
)
sessionToken
()
string
{
func
(
this
*
Session
)
sessionToken
()
string
{
return
fmt
.
Sprintf
(
return
fmt
.
Sprintf
(
"%s:%d:%s:%s"
,
"{%s, %d, %s <-> %s}"
,
this
.
name
,
this
.
ID
,
this
.
name
,
this
.
ID
,
this
.
conn
.
LocalAddr
()
.
String
(),
this
.
conn
.
LocalAddr
()
.
String
(),
this
.
conn
.
RemoteAddr
()
.
String
(),
this
.
conn
.
RemoteAddr
()
.
String
(),
)
)
...
@@ -406,7 +409,7 @@ func (this *Session) handlePackage() {
...
@@ -406,7 +409,7 @@ func (this *Session) handlePackage() {
nerr
net
.
Error
nerr
net
.
Error
ok
bool
ok
bool
exit
bool
exit
bool
reconnect
bool
errFlag
bool
len
int
len
int
buf
[]
byte
buf
[]
byte
pktBuf
*
bytes
.
Buffer
pktBuf
*
bytes
.
Buffer
...
@@ -422,8 +425,8 @@ func (this *Session) handlePackage() {
...
@@ -422,8 +425,8 @@ func (this *Session) handlePackage() {
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
reconnect
&&
this
.
listener
!=
nil
{
if
errFlag
&&
this
.
listener
!=
nil
{
log
.
Info
(
"%s, [session.handlePackage]
reconnect
"
,
this
.
sessionToken
())
log
.
Info
(
"%s, [session.handlePackage]
errFlag
"
,
this
.
sessionToken
())
this
.
listener
.
OnError
(
this
,
nerr
)
this
.
listener
.
OnError
(
this
,
nerr
)
}
}
}()
}()
...
@@ -449,7 +452,7 @@ func (this *Session) handlePackage() {
...
@@ -449,7 +452,7 @@ func (this *Session) handlePackage() {
// 遇到网络错误的时候,handlePackage能够及时退出,但是handleLoop的第一个for-select因为要处理(Codec)OnMessage
// 遇到网络错误的时候,handlePackage能够及时退出,但是handleLoop的第一个for-select因为要处理(Codec)OnMessage
// 导致程序不能及时退出,此处添加(Codec)OnError调用以及时通知getty调用者
// 导致程序不能及时退出,此处添加(Codec)OnError调用以及时通知getty调用者
// AS, 2016/08/21
// AS, 2016/08/21
reconnect
=
true
errFlag
=
true
exit
=
true
exit
=
true
}
}
break
break
...
...
version.go
View file @
36ec376d
...
@@ -10,5 +10,5 @@
...
@@ -10,5 +10,5 @@
package
getty
package
getty
var
(
var
(
Version
=
"0.2.0
6
"
Version
=
"0.2.0
7
"
)
)
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