Commit 256d6dac authored by Kirill Smelkov's avatar Kirill Smelkov

wcfs: Fix potential stuck in WatchLink.serve exit codepath

When serve is completing and going to exit, it sends an error message to
the client without any timeout. So if the client is not reading from the
channel, wcfs will get stuck waiting for the message to be consumed.

-> Fix that by trying to send that last error only during 1 second and
   ignoring errors if any

Test is, hopefully, TODO.
parent 37fd9820
......@@ -1899,9 +1899,11 @@ func (wlink *WatchLink) _serve() (err error) {
delete(head.wlinkTab, wlink)
head.wlinkMu.Unlock()
// write to peer if it was logical error on client side
// give client a chance to be notified if it was due to some logical error
if err != nil {
_ = wlink.send(ctx0, 0, fmt.Sprintf("error: %s", err))
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
_ = wlink.send(ctx, 0, fmt.Sprintf("error: %s", err))
}
// close .sk
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment