MCPcopy Index your code
hub / github.com/RsyncProject/rsync / close_all

Function close_all

cleanup.c:51–68  ·  view source on GitHub ↗

* Close all open sockets and files, allowing a (somewhat) graceful * shutdown() of socket connections. This eliminates the abortive * TCP RST sent by a Winsock-based system when the close() occurs. **/

Source from the content-addressed store, hash-verified

49 * TCP RST sent by a Winsock-based system when the close() occurs.
50 **/
51void close_all(void)
52{
53#ifdef SHUTDOWN_ALL_SOCKETS
54 int max_fd;
55 int fd;
56 int ret;
57 STRUCT_STAT st;
58
59 max_fd = sysconf(_SC_OPEN_MAX) - 1;
60 for (fd = max_fd; fd >= 0; fd--) {
61 if ((ret = do_fstat(fd, &st)) == 0) {
62 if (is_a_socket(fd))
63 ret = shutdown(fd, 2);
64 ret = close(fd);
65 }
66 }
67#endif
68}
69
70/**
71 * @file cleanup.c

Callers 3

_exit_cleanupFunction · 0.85
start_accept_loopFunction · 0.85
sigusr2_handlerFunction · 0.85

Calls 2

do_fstatFunction · 0.85
is_a_socketFunction · 0.85

Tested by

no test coverage detected