Check that a mirror write returning an error will cause a reconnect and retry

This commit is contained in:
Alex Young
2012-07-02 15:04:45 +01:00
parent 99f8c24b01
commit ea4642a878
10 changed files with 192 additions and 88 deletions

View File

@@ -68,16 +68,17 @@ void fill_request(struct nbd_request *request, int type, int from, int len)
void read_reply(int fd, struct nbd_request *request, struct nbd_reply *reply)
{
FATAL_IF_NEGATIVE(readloop(fd, reply, sizeof(*reply)),
ERROR_IF_NEGATIVE(readloop(fd, reply, sizeof(*reply)),
"Couldn't read reply");
if (be32toh(reply->magic) != REPLY_MAGIC) {
fatal("Reply magic incorrect (%p)", be32toh(reply->magic));
error("Reply magic incorrect (%p)", be32toh(reply->magic));
}
if (be32toh(reply->error) != 0) {
fatal("Server replied with error %d", be32toh(reply->error));
error("Server replied with error %d", be32toh(reply->error));
}
if (strncmp(request->handle, reply->handle, 8) != 0) {
fatal("Did not reply with correct handle");
error("Did not reply with correct handle");
}
}