File tree 2 files changed +9
-5
lines changed
websites/code2/studygolang/src
2 files changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ func (SearchController) Search(ctx echo.Context) error {
30
30
"f" : field ,
31
31
}
32
32
if err == nil {
33
- uri := "/search?q=" + q + "&f=" + field
33
+ uri := "/search?q=" + q + "&f=" + field + "&"
34
34
paginator := logic .NewPaginatorWithPerPage (p , rows )
35
35
data ["pageHtml" ] = paginator .SetTotal (int64 (respBody .NumFound )).GetPageHtml (uri )
36
36
}
Original file line number Diff line number Diff line change @@ -92,8 +92,9 @@ func (this *book) AddUser(user, serverId int) *UserData {
92
92
var userData * UserData
93
93
var ok bool
94
94
this .rwMutex .Lock ()
95
- defer this .rwMutex .Unlock ()
96
95
if userData , ok = this .users [user ]; ok {
96
+ this .rwMutex .Unlock ()
97
+
97
98
userData .InitMessageQueue (serverId )
98
99
userData .onlineDuartion += time .Now ().Sub (userData .lastAccessTime )
99
100
userData .lastAccessTime = time .Now ()
@@ -103,12 +104,15 @@ func (this *book) AddUser(user, serverId int) *UserData {
103
104
lastAccessTime : time .Now (),
104
105
}
105
106
this .users [user ] = userData
107
+ length := len (this .users )
108
+
109
+ this .rwMutex .Unlock ()
106
110
107
- onlineInfo := map [string ]int {"online" : len ( this . users ) }
111
+ onlineInfo := map [string ]int {"online" : length }
108
112
// 在线人数超过历史最高
109
- if len ( this . users ) > MaxOnlineNum () {
113
+ if length > MaxOnlineNum () {
110
114
maxRwMu .Lock ()
111
- maxOnlineNum = len ( this . users )
115
+ maxOnlineNum = length
112
116
onlineInfo ["maxonline" ] = maxOnlineNum
113
117
maxRwMu .Unlock ()
114
118
saveMaxOnlineNum ()
You can’t perform that action at this time.
0 commit comments