fix race condition when logging requests

This commit is contained in:
Marten Seemann 2021-02-27 18:33:13 +08:00
parent ac82ca5ee9
commit d631204dee
2 changed files with 1 additions and 1 deletions

View File

@ -117,7 +117,6 @@ func (c *Context) LogRequest(req *cmds.Request) func() {
Command: strings.Join(req.Path, "/"),
Options: req.Options,
Args: req.Arguments,
ID: c.ReqLog.nextID,
log: c.ReqLog,
}
c.ReqLog.AddEntry(rle)

View File

@ -38,6 +38,7 @@ func (rl *ReqLog) AddEntry(rle *ReqLogEntry) {
rl.lock.Lock()
defer rl.lock.Unlock()
rle.ID = rl.nextID
rl.nextID++
rl.Requests = append(rl.Requests, rle)