--- libaitrpc/src/cli.c 2015/06/28 21:52:26 1.25.2.2 +++ libaitrpc/src/cli.c 2015/06/28 22:11:30 1.25.2.3 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: cli.c,v 1.25.2.2 2015/06/28 21:52:26 misho Exp $ +* $Id: cli.c,v 1.25.2.3 2015/06/28 22:11:30 misho Exp $ * ************************************************************************** The ELWIX and AITNET software is distributed under the following @@ -261,6 +261,16 @@ rpc_cli_reconnectClient(rpc_cli_t * __restrict cli) else netBuf = AIT_LEN(&cli->cli_buf); + if (cli->cli_id == SOCK_STREAM) + shutdown(cli->cli_sock, SHUT_RDWR); + if (cli->cli_id == SOCK_DGRAM && cli->cli_sa.sa.sa_family == AF_LOCAL) { + sockaddr_t sa2 = E_SOCKADDR_INIT; + socklen_t salen; + + sa2.sa.sa_len = salen = sizeof sa2; + if (!getsockname(cli->cli_sock, &sa2.sa, &salen)) + unlink(sa2.sun.sun_path); + } close(cli->cli_sock); srandom(time(NULL) ^ getpid()); @@ -307,6 +317,14 @@ rpc_cli_closeClient(rpc_cli_t ** __restrict cli) if ((*cli)->cli_id == SOCK_STREAM) shutdown((*cli)->cli_sock, SHUT_RDWR); + if ((*cli)->cli_id == SOCK_DGRAM && (*cli)->cli_sa.sa.sa_family == AF_LOCAL) { + sockaddr_t sa2 = E_SOCKADDR_INIT; + socklen_t salen; + + sa2.sa.sa_len = salen = sizeof sa2; + if (!getsockname((*cli)->cli_sock, &sa2.sa, &salen)) + unlink(sa2.sun.sun_path); + } close((*cli)->cli_sock); AIT_FREE_VAL(&(*cli)->cli_buf);