Commit 57dac9d1 authored by Alex Elder's avatar Alex Elder Committed by Alex Elder

ceph: messenger: use read_partial() in read_partial_message()

There are two blocks of code in read_partial_message()--those that
read the header and footer of the message--that can be replaced by a
call to read_partial().  Do that.
Signed-off-by: default avatarAlex Elder <elder@inktank.com>
Reviewed-by: default avatarSage Weil <sage@inktank.com>
parent b7f6519e
...@@ -1628,7 +1628,7 @@ static int read_partial_message(struct ceph_connection *con) ...@@ -1628,7 +1628,7 @@ static int read_partial_message(struct ceph_connection *con)
{ {
struct ceph_msg *m = con->in_msg; struct ceph_msg *m = con->in_msg;
int ret; int ret;
int to, left; int to;
unsigned front_len, middle_len, data_len; unsigned front_len, middle_len, data_len;
bool do_datacrc = !con->msgr->nocrc; bool do_datacrc = !con->msgr->nocrc;
int skip; int skip;
...@@ -1638,15 +1638,10 @@ static int read_partial_message(struct ceph_connection *con) ...@@ -1638,15 +1638,10 @@ static int read_partial_message(struct ceph_connection *con)
dout("read_partial_message con %p msg %p\n", con, m); dout("read_partial_message con %p msg %p\n", con, m);
/* header */ /* header */
while (con->in_base_pos < sizeof(con->in_hdr)) { to = 0;
left = sizeof(con->in_hdr) - con->in_base_pos; ret = read_partial(con, &to, sizeof (con->in_hdr), &con->in_hdr);
ret = ceph_tcp_recvmsg(con->sock, if (ret <= 0)
(char *)&con->in_hdr + con->in_base_pos, return ret;
left);
if (ret <= 0)
return ret;
con->in_base_pos += ret;
}
crc = crc32c(0, &con->in_hdr, offsetof(struct ceph_msg_header, crc)); crc = crc32c(0, &con->in_hdr, offsetof(struct ceph_msg_header, crc));
if (cpu_to_le32(crc) != con->in_hdr.crc) { if (cpu_to_le32(crc) != con->in_hdr.crc) {
...@@ -1759,16 +1754,11 @@ static int read_partial_message(struct ceph_connection *con) ...@@ -1759,16 +1754,11 @@ static int read_partial_message(struct ceph_connection *con)
} }
/* footer */ /* footer */
to = sizeof(m->hdr) + sizeof(m->footer); to = sizeof (m->hdr);
while (con->in_base_pos < to) { ret = read_partial(con, &to, sizeof (m->footer), &m->footer);
left = to - con->in_base_pos; if (ret <= 0)
ret = ceph_tcp_recvmsg(con->sock, (char *)&m->footer + return ret;
(con->in_base_pos - sizeof(m->hdr)),
left);
if (ret <= 0)
return ret;
con->in_base_pos += ret;
}
dout("read_partial_message got msg %p %d (%u) + %d (%u) + %d (%u)\n", dout("read_partial_message got msg %p %d (%u) + %d (%u) + %d (%u)\n",
m, front_len, m->footer.front_crc, middle_len, m, front_len, m->footer.front_crc, middle_len,
m->footer.middle_crc, data_len, m->footer.data_crc); m->footer.middle_crc, data_len, m->footer.data_crc);
......
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