Commit 2974f8d6 authored by Sudheer Mogilappagari's avatar Sudheer Mogilappagari Committed by Jim Harris
Browse files

posix: replace usage of recv() with poll()



Busy pollng using recv() is dependent on kernel socket buffer being
empty. Instead poll() function busy polls hw queues with no such dependency.

Signed-off-by: default avatarSudheer Mogilappagari <sudheer.mogilappagari@intel.com>
Change-Id: I1cb101848d51f7778cdf3d4c015d2d03201bdb37
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7014


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
parent 5cf9b5c5
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -1275,15 +1275,17 @@ posix_sock_group_impl_poll(struct spdk_sock_group_impl *_group, int max_events,
	if (num_events == -1) {
		return -1;
	} else if (num_events == 0 && !TAILQ_EMPTY(&_group->socks)) {
		uint8_t byte;

		sock = TAILQ_FIRST(&_group->socks);
		psock = __posix_sock(sock);
		/* a recv is done here to busy poll the queue associated with
		/* poll() is called here to busy poll the queue associated with
		 * first socket in list and potentially reap incoming data.
		 */
		if (sock->opts.priority) {
			recv(psock->fd, &byte, 1, MSG_PEEK);
			struct pollfd pfd = {0, 0, 0};

			pfd.fd = psock->fd;
			pfd.events = POLLIN | POLLERR;
			poll(&pfd, 1, 0);
		}
	}