|
@@ -871,8 +871,12 @@ func (client *Client) replayPrivmsgHistory(rb *ResponseBuffer, items []history.I
|
871
|
871
|
if allowTags {
|
872
|
872
|
tags = item.Tags
|
873
|
873
|
}
|
|
874
|
+ // XXX: Params[0] is the message target. if the source of this message is an in-memory
|
|
875
|
+ // buffer, then it's "" for an incoming message and the recipient's nick for an outgoing
|
|
876
|
+ // message. if the source of the message is mysql, then mysql only sees one copy of the
|
|
877
|
+ // message, and it's the version with the recipient's nick filled in. so this is an
|
|
878
|
+ // incoming message if Params[0] (the recipient's nick) equals the client's nick:
|
874
|
879
|
if item.Params[0] == "" || item.Params[0] == nick {
|
875
|
|
- // this message was sent *to* the client from another nick
|
876
|
880
|
rb.AddSplitMessageFromClient(item.Nick, item.AccountName, tags, command, nick, item.Message)
|
877
|
881
|
} else {
|
878
|
882
|
// this message was sent *from* the client to another nick; the target is item.Params[0]
|
|
@@ -1237,9 +1241,9 @@ func (client *Client) destroy(session *Session) {
|
1237
|
1241
|
Message: splitQuitMessage,
|
1238
|
1242
|
}
|
1239
|
1243
|
var channels []*Channel
|
|
1244
|
+ // use a defer here to avoid writing to mysql while holding the destroy semaphore:
|
1240
|
1245
|
defer func() {
|
1241
|
1246
|
for _, channel := range channels {
|
1242
|
|
- // TODO it's dangerous to write to mysql while holding the destroy semaphore
|
1243
|
1247
|
channel.AddHistoryItem(quitItem)
|
1244
|
1248
|
}
|
1245
|
1249
|
}()
|