sock/posix: Set sendbuf and recvbuf before connect call

For client side connections, SO_RCVBUF needs to set
before connect call() so this patch moves those calls
accordingly.

Signed-off-by: Sudheer Mogilappagari <sudheer.mogilappagari@intel.com>
Change-Id: Ifa8373145b3699e697e34e93132b5c006e7fbf83
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/757
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Ziye Yang <ziye.yang@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Sudheer Mogilappagari 2020-02-06 05:52:21 -08:00 committed by Tomasz Zawadzki
parent beaf69617a
commit 8ba2c0159f

View File

@ -219,9 +219,8 @@ static struct spdk_posix_sock *
_spdk_posix_sock_alloc(int fd)
{
struct spdk_posix_sock *sock;
int rc;
#ifdef SPDK_ZEROCOPY
int flag;
int flag, rc;
#endif
sock = calloc(1, sizeof(*sock));
@ -232,15 +231,6 @@ _spdk_posix_sock_alloc(int fd)
sock->fd = fd;
rc = spdk_posix_sock_set_recvbuf(&sock->base, SO_RCVBUF_SIZE);
if (rc) {
/* Not fatal */
}
rc = spdk_posix_sock_set_sendbuf(&sock->base, SO_SNDBUF_SIZE);
if (rc) {
/* Not fatal */
}
#ifdef SPDK_ZEROCOPY
/* Try to turn on zero copy sends */
@ -264,7 +254,7 @@ spdk_posix_sock_create(const char *ip, int port, enum spdk_posix_sock_create_typ
struct addrinfo hints, *res, *res0;
int fd, flag;
int val = 1;
int rc;
int rc, sz;
if (ip == NULL) {
return NULL;
@ -300,6 +290,19 @@ retry:
/* error */
continue;
}
sz = SO_RCVBUF_SIZE;
rc = setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &sz, sizeof(sz));
if (rc) {
/* Not fatal */
}
sz = SO_SNDBUF_SIZE;
rc = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &sz, sizeof(sz));
if (rc) {
/* Not fatal */
}
rc = setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof val);
if (rc != 0) {
close(fd);