static int parse_args(vector<const char*>& args, std::ostream *err_msg,
Config *cfg);
+static int netlink_disconnect(int index);
static int netlink_resize(int nbd_index, uint64_t size);
static int run_quiesce_hook(const std::string &quiesce_hook,
}
r = -errno;
derr << "failed to poll nbd: " << cpp_strerror(r) << dendl;
- goto signal;
+ goto error;
}
if ((poll_fds[1].revents & POLLIN) != 0) {
if (r < 0) {
derr << "failed to read nbd request header: " << cpp_strerror(r)
<< dendl;
- goto signal;
+ goto error;
}
if (ctx->request.magic != htonl(NBD_REQUEST_MAGIC)) {
if (r < 0) {
derr << *ctx << ": failed to read nbd request data: "
<< cpp_strerror(r) << dendl;
- goto signal;
+ goto error;
}
ctx->data.push_back(ptr);
break;
goto signal;
}
}
+error:
+ {
+ int r = netlink_disconnect(nbd_index);
+ if (r == 1) {
+ ioctl(nbd, NBD_DISCONNECT);
+ }
+ }
signal:
std::lock_guard l{lock};
terminated = true;