From 8181153da09bd0c99120887f56b741809263300d Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Sun, 18 Feb 2018 21:12:55 -0700 Subject: [PATCH] net: move more common code out of posix routines Signed-off-by: Jim Harris Change-Id: I9a94bf22e36ae58ea98888e4a8ab295169d01dc5 Reviewed-on: https://review.gerrithub.io/400435 Tested-by: SPDK Automated Test System Reviewed-by: Shuhei Matsumoto Reviewed-by: Daniel Verkamp Reviewed-by: Tomasz Zawadzki --- lib/net/sock.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/net/sock.c b/lib/net/sock.c index 1a21e24fc..73df147d8 100644 --- a/lib/net/sock.c +++ b/lib/net/sock.c @@ -343,11 +343,6 @@ spdk_posix_sock_recv(struct spdk_sock *_sock, void *buf, size_t len) { struct spdk_posix_sock *sock = __posix_sock(_sock); - if (sock == NULL) { - errno = EBADF; - return -1; - } - return recv(sock->fd, buf, len, MSG_DONTWAIT); } @@ -356,11 +351,6 @@ spdk_posix_sock_writev(struct spdk_sock *_sock, struct iovec *iov, int iovcnt) { struct spdk_posix_sock *sock = __posix_sock(_sock); - if (sock == NULL) { - errno = EBADF; - return -1; - } - return writev(sock->fd, iov, iovcnt); } @@ -616,12 +606,22 @@ spdk_sock_close(struct spdk_sock **sock) ssize_t spdk_sock_recv(struct spdk_sock *sock, void *buf, size_t len) { + if (sock == NULL) { + errno = EBADF; + return -1; + } + return spdk_posix_sock_recv(sock, buf, len); } ssize_t spdk_sock_writev(struct spdk_sock *sock, struct iovec *iov, int iovcnt) { + if (sock == NULL) { + errno = EBADF; + return -1; + } + return spdk_posix_sock_writev(sock, iov, iovcnt); }