Thread (1 message) 1 message, 1 author, 2012-08-16

RE: [PATCH] librdmacm/rsockets: Support MSG_WAITALL with rsockets recv()

From: Hefty, Sean <hidden>
Date: 2012-08-16 21:07:57

Support MSG_WAITALL flag with recv() when using rsockets.

Signed-off-by: Sridhar Samudrala <redacted>
The MSG_PEEK description that you pointed me to wasn't in the man page documentation that I was looking at.  That simplifies things.

I originally expected adding MSG_WAITALL support to be as trivial as your patch, and it didn't end up quite as simple as I expected.  It was mostly because I tried to handle MSG_PEEK differently, but I also have a note in my version.  Please see below.
quoted hunk
diff --git a/src/rsocket.c b/src/rsocket.c
index b9105a1..81f2654 100644
--- a/src/rsocket.c
+++ b/src/rsocket.c
@@ -1131,6 +1131,7 @@ ssize_t rrecv(int socket, void *buf, size_t len, int
flags)
 		}
 	}
 	fastlock_acquire(&rs->rlock);
+waitall:
 	if (!rs_have_rdata(rs)) {
 		ret = rs_get_comp(rs, rs_nonblocking(rs, flags),
rs_conn_have_rdata);
 		if (ret)
@@ -1167,6 +1168,10 @@ ssize_t rrecv(int socket, void *buf, size_t len, int
flags)
 		buf += rsize;
 	}
 	rs->rbuf_bytes_avail += len - left;
The above line doesn't work as written if placed inside a loop.  And we can't move it outside of the loop, or we may not give credits to the remote side.
quoted hunk
+
+	if ((flags & MSG_WAITALL) && left)
+		goto waitall;
One minor difference is that I used a do - while() loop in place of if - goto, but I also added a state check of (rs->state & rs_connect_rd).

Since we don't have to deal with MSG_PEEK, I'll fix-up how rbuf_bytes_avail is updated and send out an updated patch for review.

- Sean
N�����r��y���b�X��ǧv�^�)޺{.n�+����{��ٚ�{ay�
ʇڙ�,j��f���h�����/oSc��ڳ9�u�����&jw��(�階�ݢj"���m�����z�ޖ���f���h���~�m�
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help