Sock: The created pipe for sock should have a minimal value.
Thus, we can make sure that when read data is larger than the pipe size, it will not read the data into the pipe. Change-Id: I87f3b03fd9b81eb693e9eae0fea9eef7d1b9eaa8 Signed-off-by: Ziye Yang <ziye.yang@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2450 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
parent
a354903737
commit
d8cafc28bb
@ -48,6 +48,7 @@ extern "C" {
|
||||
|
||||
#define MAX_EVENTS_PER_POLL 32
|
||||
#define DEFAULT_SOCK_PRIORITY 0
|
||||
#define MIN_SOCK_PIPE_SIZE 1024
|
||||
|
||||
struct spdk_sock {
|
||||
struct spdk_net_impl *net_impl;
|
||||
|
@ -212,6 +212,9 @@ posix_sock_alloc_pipe(struct spdk_posix_sock *sock, int sz)
|
||||
sock->recv_pipe = NULL;
|
||||
sock->recv_buf = NULL;
|
||||
return 0;
|
||||
} else if (sz < MIN_SOCK_PIPE_SIZE) {
|
||||
SPDK_ERRLOG("The size of the pipe must be larger than %d\n", MIN_SOCK_PIPE_SIZE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Round up to next 64 byte multiple */
|
||||
@ -924,7 +927,7 @@ posix_sock_readv(struct spdk_sock *_sock, struct iovec *iov, int iovcnt)
|
||||
if (spdk_pipe_reader_bytes_available(sock->recv_pipe) == 0) {
|
||||
/* If the user is receiving a sufficiently large amount of data,
|
||||
* receive directly to their buffers. */
|
||||
if (len >= 1024) {
|
||||
if (len >= MIN_SOCK_PIPE_SIZE) {
|
||||
return readv(sock->fd, iov, iovcnt);
|
||||
}
|
||||
|
||||
|
@ -232,6 +232,9 @@ uring_sock_alloc_pipe(struct spdk_uring_sock *sock, int sz)
|
||||
sock->recv_pipe = NULL;
|
||||
sock->recv_buf = NULL;
|
||||
return 0;
|
||||
} else if (sz < MIN_SOCK_PIPE_SIZE) {
|
||||
SPDK_ERRLOG("The size of the pipe must be larger than %d\n", MIN_SOCK_PIPE_SIZE);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Round up to next 64 byte multiple */
|
||||
@ -660,7 +663,7 @@ uring_sock_readv(struct spdk_sock *_sock, struct iovec *iov, int iovcnt)
|
||||
if (spdk_pipe_reader_bytes_available(sock->recv_pipe) == 0) {
|
||||
/* If the user is receiving a sufficiently large amount of data,
|
||||
* receive directly to their buffers. */
|
||||
if (len >= 1024) {
|
||||
if (len >= MIN_SOCK_PIPE_SIZE) {
|
||||
return readv(sock->fd, iov, iovcnt);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user