Merge pull request 'Move chunk respones into goroutine to not block the listen() thread' (#390) from filesharing-bugs into master
continuous-integration/drone/tag Build is passing Details
continuous-integration/drone/push Build is failing Details

Reviewed-on: #390
Reviewed-by: erinn <erinn@openprivacy.ca>
This commit is contained in:
erinn 2021-09-30 20:06:22 +00:00
commit eefc39272a
1 changed files with 7 additions and 4 deletions

View File

@ -561,11 +561,14 @@ func (e *engine) handlePeerMessage(hostname string, eventID string, context stri
e.eventManager.Publish(event.NewEvent(event.ManifestReceived, map[event.Field]string{event.Handle: hostname, event.FileKey: fileKey, event.SerializedManifest: manifest}))
}
} else if context == event.ContextRequestFile {
for _, message := range e.filesharingSubSystem.ProcessChunkRequest(eventID, message) {
if err := e.sendPeerMessage(hostname, message); err != nil {
e.eventManager.Publish(event.NewEvent(event.SendMessageToPeerError, map[event.Field]string{event.RemotePeer: hostname, event.EventID: eventID, event.Error: err.Error()}))
chunks := e.filesharingSubSystem.ProcessChunkRequest(eventID, message)
go func() {
for _, message := range chunks {
if err := e.sendPeerMessage(hostname, message); err != nil {
e.eventManager.Publish(event.NewEvent(event.SendMessageToPeerError, map[event.Field]string{event.RemotePeer: hostname, event.EventID: eventID, event.Error: err.Error()}))
}
}
}
}()
} else if context == event.ContextSendFile {
fileKey, progress, totalChunks, _, title := e.filesharingSubSystem.ProcessChunk(eventID, message)
if len(fileKey) != 0 {