mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
fix race condition when logging requests
This commit is contained in:
parent
ac82ca5ee9
commit
d631204dee
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user