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
2a319e56
Commit
2a319e56
authored
Oct 10, 2016
by
alexstocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bugs
parent
9525bb8a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
1 deletion
+5
-1
conn.go
conn.go
+3
-1
session.go
session.go
+2
-0
No files found.
conn.go
View file @
2a319e56
...
...
@@ -17,6 +17,7 @@ import (
import
(
"github.com/gorilla/websocket"
// log "github.com/AlexStocks/log4go"
)
var
(
...
...
@@ -100,6 +101,7 @@ func (this *gettyTCPConn) read(p []byte) (int, error) {
// if this.conn == nil {
// return 0, ErrInvalidConnection
// }
// atomic.AddUint32(&this.readCount, 1)
atomic
.
AddUint32
(
&
this
.
readCount
,
(
uint32
)(
len
(
p
)))
return
this
.
conn
.
Read
(
p
)
...
...
@@ -122,6 +124,7 @@ func (this *gettyTCPConn) close(waitSec int) {
// if tcpConn, ok := this.conn.(*net.TCPConn); ok {
// tcpConn.SetLinger(0)
// }
if
this
.
conn
!=
nil
{
this
.
conn
.
(
*
net
.
TCPConn
)
.
SetLinger
(
waitSec
)
this
.
conn
.
Close
()
...
...
@@ -164,7 +167,6 @@ func newGettyWSConn(conn *websocket.Conn) *gettyWSConn {
// websocket connection read
func
(
this
*
gettyWSConn
)
read
()
([]
byte
,
error
)
{
// l, b, e := this.conn.ReadMessage()
_
,
b
,
e
:=
this
.
conn
.
ReadMessage
()
if
e
==
nil
{
// atomic.AddUint32(&this.readCount, (uint32)(l))
...
...
session.go
View file @
2a319e56
...
...
@@ -535,6 +535,7 @@ func (this *Session) handleTCPPackage() error {
buf
=
make
([]
byte
,
maxReadBufLen
)
pktBuf
=
new
(
bytes
.
Buffer
)
conn
=
this
.
iConn
.
(
*
gettyTCPConn
)
for
{
if
this
.
IsClosed
()
{
err
=
nil
...
...
@@ -603,6 +604,7 @@ func (this *Session) handleWSPackage() error {
unmarshalPkg
interface
{}
)
conn
=
this
.
iConn
.
(
*
gettyWSConn
)
for
{
if
this
.
IsClosed
()
{
break
// 退出前不再读取任何packet,buf中剩余的stream bytes也不可能凑够一个package, 所以直接退出
...
...
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