Fix vitastor-nbd spinning forever after NBD_CMD_DISC #142

Merged
vitalif merged 1 commits from koolkhel/vitastor:nbd-disc-exit into master 2026-11-21 11:28:20 +03:00

1 Commits

Author SHA1 Message Date
d9497d38c9 Fix vitastor-nbd spinning forever after NBD_CMD_DISC
The NBD_CMD_DISC branch closed the socket and returned without
preparing the next read, so handle_read() looped forever on any bytes
that followed the disconnect request in the same recvmsg(), ignoring
`stop` and SIGTERM. The kernel sends such requests after the
NBD_DISCONNECT ioctl, for example when the device is opened and its
partition table is re-read.

The closed descriptor also stayed in use: a read or a reply submitted
after it failed with EBADF, and the process exited with code 1 in the
middle of the final sync. Forget the descriptor once it is closed and
stop parsing, reading and sending after that.
2026-11-21 10:52:47 +03:00