Fix bug in Engine that leaked Peer Connecting Status
This commit is contained in:
parent
75eb49d6ee
commit
b84de2aa61
|
@ -220,6 +220,7 @@ const (
|
||||||
|
|
||||||
// Conversation Search
|
// Conversation Search
|
||||||
SearchResult = Type("SearchResult")
|
SearchResult = Type("SearchResult")
|
||||||
|
SearchCancelled = Type("SearchCancelled")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Field defines common event attributes
|
// Field defines common event attributes
|
||||||
|
|
|
@ -805,6 +805,11 @@ func (cp *cwtchPeer) GetChannelMessage(conversation int, channel int, id int) (s
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cp *cwtchPeer) doSearch(ctx context.Context, searchID string, pattern string) {
|
func (cp *cwtchPeer) doSearch(ctx context.Context, searchID string, pattern string) {
|
||||||
|
|
||||||
|
// do not allow trivial searches that would match a wide variety of messages...
|
||||||
|
if len(pattern) <=5 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
conversations, _ := cp.FetchConversations()
|
conversations, _ := cp.FetchConversations()
|
||||||
maxCount := 0
|
maxCount := 0
|
||||||
|
@ -824,8 +829,9 @@ func (cp *cwtchPeer) doSearch(ctx context.Context, searchID string, pattern stri
|
||||||
for offset := 0; offset < (maxCount + 10); offset += 10 {
|
for offset := 0; offset < (maxCount + 10); offset += 10 {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
cp.PublishEvent(event.NewEvent(event.SearchCancelled, map[event.Field]string{event.SearchID: searchID}))
|
||||||
return
|
return
|
||||||
case <-time.After(time.Millisecond):
|
case <-time.After(time.Millisecond*100):
|
||||||
for _, conversation := range conversations {
|
for _, conversation := range conversations {
|
||||||
ccount := conversationCount[conversation.ID]
|
ccount := conversationCount[conversation.ID]
|
||||||
if offset > ccount {
|
if offset > ccount {
|
||||||
|
|
|
@ -344,10 +344,11 @@ func (e *engine) Shutdown() {
|
||||||
log.Infof("shutting down ephemeral service")
|
log.Infof("shutting down ephemeral service")
|
||||||
// work around: service.shutdown() can block for a long time if it is Open()ing a new connection, putting it in a
|
// work around: service.shutdown() can block for a long time if it is Open()ing a new connection, putting it in a
|
||||||
// goroutine means we can perform this operation and let the per service shutdown in their own time or until the app exits
|
// goroutine means we can perform this operation and let the per service shutdown in their own time or until the app exits
|
||||||
|
conn := connection; // don't capture loop variable
|
||||||
go func() {
|
go func() {
|
||||||
connection.connectingLock.Lock()
|
conn.connectingLock.Lock()
|
||||||
connection.service.Shutdown()
|
conn.service.Shutdown()
|
||||||
connection.connectingLock.Unlock()
|
conn.connectingLock.Unlock()
|
||||||
|
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
@ -380,6 +381,7 @@ func (e *engine) peerWithOnion(onion string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
e.ignoreOnShutdown(e.peerDisconnected)(onion)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *engine) makeAntispamPayment(onion string) {
|
func (e *engine) makeAntispamPayment(onion string) {
|
||||||
|
|
Loading…
Reference in New Issue