arashpayan/chirp

Serialize message processing in *Listener.listen

Closed this issue · 0 comments

This block of code from *Listener.listen occasionally causes a 'concurrent map writes' panic inside of l.handlePublish, and probably l.handleRemoval too.

    received := make(chan *message)
    for msg := range received {
        if msg.SenderID == l.id {
            continue
        }
        switch msg.Type {
        case messageTypePublishService:
            l.handlePublish(msg)
        case messageTypeRemoveService:
            l.handleRemoval(msg)
        }
    }