Skip to content

Commit df4bc86

Browse files
committed
order: fix concurrent map access
Because spew.Sdump will iterate through the whole struct, it will also access maps, such as the underlying sync.Map. Which can then lead to concurrent map access, because that access isn't protected by the mutex.
1 parent 1ee066e commit df4bc86

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

Diff for: rfq/order.go

+15-3
Original file line numberDiff line numberDiff line change
@@ -912,9 +912,21 @@ func (h *OrderHandler) fetchPolicy(htlc lndclient.InterceptedHtlc) (Policy,
912912
inPolicy, haveInPolicy := h.policies.Load(inScid)
913913

914914
log.Tracef("Have inbound policy: %v: %v", haveInPolicy,
915-
spew.Sdump(inPolicy))
916-
log.Tracef("Have outbound policy: %v: %v", haveOutPolicy,
917-
spew.Sdump(outPolicy))
915+
lnutils.LogClosure(func() string {
916+
if inPolicy == nil {
917+
return "<nil>"
918+
}
919+
920+
return fmt.Sprintf("%d", inPolicy.Scid())
921+
}))
922+
log.Tracef("Have outbound policy: %v: scid %v", haveOutPolicy,
923+
lnutils.LogClosure(func() string {
924+
if outPolicy == nil {
925+
return "<nil>"
926+
}
927+
928+
return fmt.Sprintf("%d", outPolicy.Scid())
929+
}))
918930

919931
var (
920932
foundPolicy *Policy

0 commit comments

Comments
 (0)