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: Sudheer Mogilappagari <sudheer.mogilappagari@intel.com>
Change-Id: I1cb101848d51f7778cdf3d4c015d2d03201bdb37
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7014
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Sudheer Mogilappagari 2021-03-23 10:28:28 -07:00 committed by Jim Harris
parent 5cf9b5c52d
commit 2974f8d676

View File

@ -1275,15 +1275,17 @@ posix_sock_group_impl_poll(struct spdk_sock_group_impl *_group, int max_events,
if (num_events == -1) { if (num_events == -1) {
return -1; return -1;
} else if (num_events == 0 && !TAILQ_EMPTY(&_group->socks)) { } else if (num_events == 0 && !TAILQ_EMPTY(&_group->socks)) {
uint8_t byte;
sock = TAILQ_FIRST(&_group->socks); sock = TAILQ_FIRST(&_group->socks);
psock = __posix_sock(sock); 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. * first socket in list and potentially reap incoming data.
*/ */
if (sock->opts.priority) { 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);
} }
} }