release gorutines

This commit is contained in:
Liang Ding 2015-03-19 11:42:52 +08:00
parent 73cfcdce55
commit 4b9c72f440
2 changed files with 9 additions and 3 deletions

View File

@ -131,6 +131,8 @@ func (ueqs queues) Close(sid string) {
return return
} }
close(q.Queue)
delete(ueqs, sid) delete(ueqs, sid)
} }

View File

@ -365,15 +365,19 @@ func (sessions *wSessions) New(httpSession *sessions.Session, sid string) *WideS
defer util.Recover() defer util.Recover()
for { for {
ch := SessionWS[sid]
if nil == ch {
return // release this gorutine
}
select { select {
case event := <-watcher.Events: case event := <-watcher.Events:
path := event.Name path := event.Name
dir := filepath.Dir(path) dir := filepath.Dir(path)
ch := SessionWS[sid] ch = SessionWS[sid]
if nil == ch { if nil == ch {
break return // release this gorutine
} }
if event.Op&fsnotify.Create == fsnotify.Create { if event.Op&fsnotify.Create == fsnotify.Create {