htlcswitch: fix panic when receiving close req for unknown channel

This commit is contained in:
Olaoluwa Osuntokun 2017-02-16 20:45:01 +08:00
parent 12f69692aa
commit 00a4da3b8c
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -658,8 +658,13 @@ func (h *htlcSwitch) handleCloseLink(req *closeLinkReq) {
// channel's available bandwidth by the delta specified within the message. // channel's available bandwidth by the delta specified within the message.
func (h *htlcSwitch) handleLinkUpdate(req *linkInfoUpdateMsg) { func (h *htlcSwitch) handleLinkUpdate(req *linkInfoUpdateMsg) {
h.chanIndexMtx.RLock() h.chanIndexMtx.RLock()
link := h.chanIndex[*req.targetLink] link, ok := h.chanIndex[*req.targetLink]
h.chanIndexMtx.RUnlock() h.chanIndexMtx.RUnlock()
if !ok {
hswcLog.Errorf("received link update for non-existent link: %v",
req.targetLink)
return
}
atomic.AddInt64(&link.availableBandwidth, int64(req.bandwidthDelta)) atomic.AddInt64(&link.availableBandwidth, int64(req.bandwidthDelta))