Archived
1
0

try fixing deadlock

This commit is contained in:
Jeff Becker 2017-09-26 09:50:14 -04:00
parent 73cf6da65d
commit 3ee449062e
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05
4 changed files with 40 additions and 59 deletions

View File

@ -874,7 +874,7 @@ func (self *NNTPDaemon) poll(worker int) {
// send to frontend
if self.frontend != nil {
if self.frontend.AllowNewsgroup(group) {
self.frontend.PostsChan() <- frontendPost{msgid, ref, group}
self.frontend.HandleNewPost(frontendPost{msgid, ref, group})
}
}
}

View File

@ -25,8 +25,8 @@ func (p frontendPost) Newsgroup() string {
// frontend interface for any type of frontend
type Frontend interface {
// channel that is for the frontend to pool for new posts from the nntpd
PostsChan() chan frontendPost
// handle new post from nntpd
HandleNewPost(p frontendPost)
// run mainloop
Mainloop()
@ -36,6 +36,7 @@ type Frontend interface {
// trigger a manual regen of indexes for a root post
Regen(msg ArticleEntry)
// regenerate on mod event
RegenOnModEvent(newsgroup, msgid, root string, page int)
}

View File

@ -175,7 +175,6 @@ type httpFrontend struct {
httpmux *mux.Router
daemon *NNTPDaemon
cache CacheInterface
recvpostchan chan frontendPost
bindaddr string
name string
@ -222,10 +221,6 @@ func (self httpFrontend) AllowNewsgroup(group string) bool {
return newsgroupValidFormat(group) || group == "ctl" && !strings.HasSuffix(group, ".")
}
func (self httpFrontend) PostsChan() chan frontendPost {
return self.recvpostchan
}
func (self *httpFrontend) Regen(msg ArticleEntry) {
self.cache.Regen(msg)
}
@ -406,12 +401,14 @@ func (self *httpFrontend) poll() {
} else {
log.Println("failed to register mod message, file was not opened")
}
case nntp := <-self.recvpostchan:
// get root post and tell frontend to regen that thread
}
}
}
func (self *httpFrontend) HandleNewPost(nntp frontendPost) {
msgid := nntp.MessageID()
group := nntp.Newsgroup()
ref := nntp.Reference()
self.informLiveUI(msgid, ref, group)
go self.informLiveUI(msgid, ref, group)
if len(ref) > 0 {
msgid = ref
}
@ -430,8 +427,6 @@ func (self *httpFrontend) poll() {
}
self.regenGroupChan <- req
}
}
}
}
// create a new captcha, return as json object
@ -1569,7 +1564,7 @@ func NewHTTPFrontend(daemon *NNTPDaemon, cache CacheInterface, config map[string
Path: front.prefix,
MaxAge: 600,
}
front.recvpostchan = make(chan frontendPost)
front.regenThreadChan = front.cache.GetThreadChan()
front.regenGroupChan = front.cache.GetGroupChan()

View File

@ -7,7 +7,6 @@ package srnd
// muxed frontend for holding many frontends
type multiFrontend struct {
muxedpostchan chan frontendPost
frontends []Frontend
}
@ -25,25 +24,12 @@ func (self multiFrontend) Mainloop() {
for idx := range self.frontends {
go self.frontends[idx].Mainloop()
}
// poll for incoming
chnl := self.PostsChan()
for {
select {
case nntp := <-chnl:
for _, frontend := range self.frontends {
if frontend.AllowNewsgroup(nntp.Newsgroup()) {
ch := frontend.PostsChan()
ch <- nntp
}
}
break
}
}
}
func (self multiFrontend) PostsChan() chan frontendPost {
return self.muxedpostchan
func (self multiFrontend) HandleNewPost(nntp frontendPost) {
for idx := range self.frontends {
self.frontends[idx].HandleNewPost(nntp)
}
}
func (self multiFrontend) RegenOnModEvent(newsgroup, msgid, root string, page int) {
@ -54,7 +40,6 @@ func (self multiFrontend) RegenOnModEvent(newsgroup, msgid, root string, page in
func MuxFrontends(fronts ...Frontend) Frontend {
var front multiFrontend
front.muxedpostchan = make(chan frontendPost, 64)
front.frontends = fronts
return front
}