sock: fix socket memory free

Memory for socket structure is allocated in the selected net
framework but freed in the libsocket on the higher level.

This patch moves memory free to the net framework implementation.

Change-Id: Ia3d4e1553a858a38beb390986e9af105778c12c7
Signed-off-by: Tomasz Kulasek <tomaszx.kulasek@intel.com>
Reviewed-on: https://review.gerrithub.io/421587
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Tomasz Kulasek 2018-08-08 09:25:29 +02:00 committed by Jim Harris
parent 8680bea106
commit 349f43c2fc
4 changed files with 9 additions and 2 deletions

View File

@ -329,8 +329,14 @@ static int
spdk_posix_sock_close(struct spdk_sock *_sock)
{
struct spdk_posix_sock *sock = __posix_sock(_sock);
int rc;
return close(sock->fd);
rc = close(sock->fd);
if (rc == 0) {
free(sock);
}
return rc;
}
static ssize_t

View File

@ -111,7 +111,6 @@ spdk_sock_close(struct spdk_sock **sock)
rc = (*sock)->net_impl->close(*sock);
if (rc == 0) {
free(*sock);
*sock = NULL;
}

View File

@ -346,6 +346,7 @@ spdk_vpp_sock_close(struct spdk_sock *_sock)
errno = -rc;
return -1;
}
free(sock);
return 0;
}

View File

@ -144,6 +144,7 @@ spdk_ut_sock_close(struct spdk_sock *_sock)
if (sock == g_ut_client_sock) {
g_ut_client_sock = NULL;
}
free(_sock);
return 0;
}