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
f066226b
Commit
f066226b
authored
Sep 19, 2016
by
alexstocks
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add empty
parent
fce00ab9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
11 deletions
+17
-11
client.go
client.go
+2
-4
dev.md
dev.md
+5
-0
server.go
server.go
+2
-2
session.go
session.go
+7
-4
version.go
version.go
+1
-1
No files found.
client.go
View file @
f066226b
...
@@ -25,8 +25,6 @@ const (
...
@@ -25,8 +25,6 @@ const (
maxTimes
=
10
maxTimes
=
10
)
)
type
empty
struct
{}
type
Client
struct
{
type
Client
struct
{
// net
// net
sync
.
Mutex
sync
.
Mutex
...
@@ -37,7 +35,7 @@ type Client struct {
...
@@ -37,7 +35,7 @@ type Client struct {
sessionMap
map
[
*
Session
]
empty
sessionMap
map
[
*
Session
]
empty
sync
.
Once
sync
.
Once
done
chan
struct
{}
done
chan
empty
wg
sync
.
WaitGroup
wg
sync
.
WaitGroup
}
}
...
@@ -58,7 +56,7 @@ func NewClient(connNum int, connInterval time.Duration, serverAddr string) *Clie
...
@@ -58,7 +56,7 @@ func NewClient(connNum int, connInterval time.Duration, serverAddr string) *Clie
interval
:
connInterval
,
interval
:
connInterval
,
addr
:
serverAddr
,
addr
:
serverAddr
,
sessionMap
:
make
(
map
[
*
Session
]
empty
,
connNum
),
sessionMap
:
make
(
map
[
*
Session
]
empty
,
connNum
),
done
:
make
(
chan
struct
{}
),
done
:
make
(
chan
empty
),
}
}
}
}
...
...
dev.md
View file @
f066226b
...
@@ -11,6 +11,11 @@
...
@@ -11,6 +11,11 @@
## develop history ##
## develop history ##
---
---
-
2016/09/19
> 1 move empty to empty from client.go to session.go
>
> 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
>
>
...
...
server.go
View file @
f066226b
...
@@ -30,12 +30,12 @@ type Server struct {
...
@@ -30,12 +30,12 @@ type Server struct {
listener
net
.
Listener
listener
net
.
Listener
sync
.
Once
sync
.
Once
done
chan
struct
{}
done
chan
empty
wg
sync
.
WaitGroup
wg
sync
.
WaitGroup
}
}
func
NewServer
()
*
Server
{
func
NewServer
()
*
Server
{
return
&
Server
{
done
:
make
(
chan
struct
{}
)}
return
&
Server
{
done
:
make
(
chan
empty
)}
}
}
func
(
this
*
Server
)
stop
()
{
func
(
this
*
Server
)
stop
()
{
...
...
session.go
View file @
f066226b
...
@@ -20,8 +20,9 @@ import (
...
@@ -20,8 +20,9 @@ import (
)
)
import
(
import
(
log
"github.com/AlexStocks/log4go"
"runtime"
"runtime"
log
"github.com/AlexStocks/log4go"
)
)
const
(
const
(
...
@@ -105,6 +106,8 @@ var (
...
@@ -105,6 +106,8 @@ var (
ErrSessionBlocked
=
errors
.
New
(
"Session full blocked"
)
ErrSessionBlocked
=
errors
.
New
(
"Session full blocked"
)
)
)
type
empty
struct
{}
// getty base session
// getty base session
type
Session
struct
{
type
Session
struct
{
name
string
name
string
...
@@ -113,7 +116,7 @@ type Session struct {
...
@@ -113,7 +116,7 @@ type Session struct {
pkgHandler
ReadWriter
pkgHandler
ReadWriter
listener
EventListener
listener
EventListener
once
sync
.
Once
once
sync
.
Once
done
chan
struct
{}
done
chan
empty
// readerDone chan struct{} // end reader
// readerDone chan struct{} // end reader
peroid
time
.
Duration
peroid
time
.
Duration
...
@@ -134,7 +137,7 @@ func NewSession(conn net.Conn) *Session {
...
@@ -134,7 +137,7 @@ func NewSession(conn net.Conn) *Session {
return
&
Session
{
return
&
Session
{
name
:
defaultSessionName
,
name
:
defaultSessionName
,
gettyConn
:
newGettyConn
(
conn
),
gettyConn
:
newGettyConn
(
conn
),
done
:
make
(
chan
struct
{}
),
done
:
make
(
chan
empty
),
// readerDone: make(chan struct{}),
// readerDone: make(chan struct{}),
peroid
:
peroid
,
peroid
:
peroid
,
rDeadline
:
netIOTimeout
,
rDeadline
:
netIOTimeout
,
...
@@ -146,7 +149,7 @@ func NewSession(conn net.Conn) *Session {
...
@@ -146,7 +149,7 @@ func NewSession(conn net.Conn) *Session {
func
(
this
*
Session
)
Reset
()
{
func
(
this
*
Session
)
Reset
()
{
this
.
name
=
defaultSessionName
this
.
name
=
defaultSessionName
this
.
done
=
make
(
chan
struct
{}
)
this
.
done
=
make
(
chan
empty
)
// this.readerDone = make(chan struct{})
// this.readerDone = make(chan struct{})
this
.
peroid
=
peroid
this
.
peroid
=
peroid
this
.
rDeadline
=
netIOTimeout
this
.
rDeadline
=
netIOTimeout
...
...
version.go
View file @
f066226b
...
@@ -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