req_iov[1].iov_len = size;
err = proxy_link_req_recv(client->sd, req_iov, 2);
- if (err > 0) {
- if (req.header.op >= LIBCEPHFSD_OP_TOTAL_OPS) {
- err = send_error(client, -ENOSYS);
- } else if (libcephfsd_handlers[req.header.op] == NULL) {
- err = send_error(client, -EOPNOTSUPP);
- } else {
- err = libcephfsd_handlers[req.header.op](
- client, &req, req_iov[1].iov_base,
- req.header.data_len);
- }
+ if (err <= 0) {
+ break;
}
- if (req_iov[1].iov_base != buffer) {
- /* Free the buffer if it was temporarily allocated. */
- proxy_free(req_iov[1].iov_base);
+ if (req.header.op >= LIBCEPHFSD_OP_TOTAL_OPS) {
+ err = send_error(client, -ENOSYS);
+ } else if (libcephfsd_handlers[req.header.op] == NULL) {
+ err = send_error(client, -EOPNOTSUPP);
+ } else {
+ err = libcephfsd_handlers[req.header.op](
+ client, &req, req_iov[1].iov_base,
+ req.header.data_len);
}
-
if (err < 0) {
break;
}
+
+ if (req_iov[1].iov_base != buffer) {
+ /* Free the buffer if it was temporarily allocated. */
+ proxy_free(req_iov[1].iov_base);
+ }
}
+ if (req_iov[1].iov_base != buffer) {
+ proxy_free(req_iov[1].iov_base);
+ }
proxy_free(buffer);
}
"Failed to receive data");
}
if (len == 0) {
- return proxy_log(LOG_ERR, ENODATA, "Partial read");
+ if (total > 0) {
+ return proxy_log(LOG_ERR, EPIPE,
+ "Partial read");
+ }
+ return 0;
}
total += len;
len = iov->iov_len;
iov->iov_len = sizeof(proxy_link_req_t);
err = proxy_link_recv(sd, iov, 1);
- if (err < 0) {
+ if (err <= 0) {
return err;
}
total = err;
}
err = proxy_link_recv(sd, iov, count);
- if (err < 0) {
+ if (err <= 0) {
+ if (err == 0) {
+ return proxy_log(LOG_ERR, EPIPE, "Partial read");
+ }
return err;
}
len = iov->iov_len;
iov->iov_len = sizeof(proxy_link_ans_t);
err = proxy_link_recv(sd, iov, 1);
- if (err < 0) {
+ if (err <= 0) {
+ if (err == 0) {
+ return proxy_log(LOG_ERR, EPIPE,
+ "Connection closed while waiting for "
+ "an answer");
+ }
return err;
}
total = err;
}
err = proxy_link_recv(sd, iov, count);
- if (err < 0) {
+ if (err <= 0) {
+ if (err == 0) {
+ return proxy_log(LOG_ERR, EPIPE, "Partial read");
+ }
return err;
}