Commit e6cee71f authored by Alex Elder's avatar Alex Elder Committed by Alex Elder

ceph: messenger: update "to" in read_partial() caller

read_partial() always increases whatever "to" value is supplied by
adding the requested size to it, and that's the only thing it does
with that pointed-to value.

Do that pointer advance in the caller (and then only when the
updated value will be subsequently used), and change the "to"
parameter to be an in-only and non-pointer value.
Signed-off-by: default avatarAlex Elder <elder@inktank.com>
Reviewed-by: default avatarSage Weil <sage@inktank.com>
parent 57dac9d1
...@@ -992,11 +992,12 @@ static int prepare_read_message(struct ceph_connection *con) ...@@ -992,11 +992,12 @@ static int prepare_read_message(struct ceph_connection *con)
static int read_partial(struct ceph_connection *con, static int read_partial(struct ceph_connection *con,
int *to, int size, void *object) int to, int size, void *object)
{ {
*to += size; int end = to + size;
while (con->in_base_pos < *to) {
int left = *to - con->in_base_pos; while (con->in_base_pos < end) {
int left = end - con->in_base_pos;
int have = size - left; int have = size - left;
int ret = ceph_tcp_recvmsg(con->sock, object + have, left); int ret = ceph_tcp_recvmsg(con->sock, object + have, left);
if (ret <= 0) if (ret <= 0)
...@@ -1017,14 +1018,16 @@ static int read_partial_banner(struct ceph_connection *con) ...@@ -1017,14 +1018,16 @@ static int read_partial_banner(struct ceph_connection *con)
dout("read_partial_banner %p at %d\n", con, con->in_base_pos); dout("read_partial_banner %p at %d\n", con, con->in_base_pos);
/* peer's banner */ /* peer's banner */
ret = read_partial(con, &to, strlen(CEPH_BANNER), con->in_banner); ret = read_partial(con, to, strlen(CEPH_BANNER), con->in_banner);
if (ret <= 0) if (ret <= 0)
goto out; goto out;
ret = read_partial(con, &to, sizeof(con->actual_peer_addr), to += strlen(CEPH_BANNER);
ret = read_partial(con, to, sizeof(con->actual_peer_addr),
&con->actual_peer_addr); &con->actual_peer_addr);
if (ret <= 0) if (ret <= 0)
goto out; goto out;
ret = read_partial(con, &to, sizeof(con->peer_addr_for_me), to += sizeof(con->actual_peer_addr);
ret = read_partial(con, to, sizeof(con->peer_addr_for_me),
&con->peer_addr_for_me); &con->peer_addr_for_me);
if (ret <= 0) if (ret <= 0)
goto out; goto out;
...@@ -1038,10 +1041,11 @@ static int read_partial_connect(struct ceph_connection *con) ...@@ -1038,10 +1041,11 @@ static int read_partial_connect(struct ceph_connection *con)
dout("read_partial_connect %p at %d\n", con, con->in_base_pos); dout("read_partial_connect %p at %d\n", con, con->in_base_pos);
ret = read_partial(con, &to, sizeof(con->in_reply), &con->in_reply); ret = read_partial(con, to, sizeof(con->in_reply), &con->in_reply);
if (ret <= 0) if (ret <= 0)
goto out; goto out;
ret = read_partial(con, &to, le32_to_cpu(con->in_reply.authorizer_len), to += sizeof(con->in_reply);
ret = read_partial(con, to, le32_to_cpu(con->in_reply.authorizer_len),
con->auth_reply_buf); con->auth_reply_buf);
if (ret <= 0) if (ret <= 0)
goto out; goto out;
...@@ -1491,9 +1495,7 @@ static int process_connect(struct ceph_connection *con) ...@@ -1491,9 +1495,7 @@ static int process_connect(struct ceph_connection *con)
*/ */
static int read_partial_ack(struct ceph_connection *con) static int read_partial_ack(struct ceph_connection *con)
{ {
int to = 0; return read_partial(con, 0, sizeof(con->in_temp_ack),
return read_partial(con, &to, sizeof(con->in_temp_ack),
&con->in_temp_ack); &con->in_temp_ack);
} }
...@@ -1638,8 +1640,7 @@ static int read_partial_message(struct ceph_connection *con) ...@@ -1638,8 +1640,7 @@ 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 */
to = 0; ret = read_partial(con, 0, sizeof (con->in_hdr), &con->in_hdr);
ret = read_partial(con, &to, sizeof (con->in_hdr), &con->in_hdr);
if (ret <= 0) if (ret <= 0)
return ret; return ret;
...@@ -1755,7 +1756,7 @@ static int read_partial_message(struct ceph_connection *con) ...@@ -1755,7 +1756,7 @@ static int read_partial_message(struct ceph_connection *con)
/* footer */ /* footer */
to = sizeof (m->hdr); to = sizeof (m->hdr);
ret = read_partial(con, &to, sizeof (m->footer), &m->footer); ret = read_partial(con, to, sizeof (m->footer), &m->footer);
if (ret <= 0) if (ret <= 0)
return ret; return ret;
......
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