MCPcopy Create free account
hub / github.com/acl-dev/acl / close

Function close

lib_acl/samples/hook_close/hook_close.cpp:128–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128int close(int fd)
129{
130 char peer[64], *at, buf[256];
131
132 if (fd < 0) {
133 acl_msg_error("%s(%d), %s: invalid fd: %d",
134 __FILE__, __LINE__, __FUNCTION__, fd);
135 trace_info("invalid fd");
136 return -1;
137 }
138
139 if (__monitor_ports_cur == 0
140 || acl_getpeername(fd, peer, sizeof(peer)) == -1)
141 {
142 peer[0] = 0;
143 } else if ((at = strchr(peer, ':')) && *++at && should_check(atoi(at))) {
144 snprintf(buf, sizeof(buf), "closing %s", peer);
145 trace_info(buf);
146 }
147
148 if (__sys_close(fd) == 0)
149 return 0;
150
151 snprintf(buf, sizeof(buf), "close error %s, fd=%d, peer=%s",
152 acl_last_serror(), fd, peer);
153 trace_info(buf);
154
155 return -1;
156}

Callers 15

acl_vstream_popenFunction · 0.50
main_epoll_endFunction · 0.50
thread_epoll_endFunction · 0.50
thread_epoll_reopenFunction · 0.50
acl_closefromFunction · 0.50
acl_file_closeFunction · 0.50
acl_trace_saveFunction · 0.50
acl_get_ifaddrsFunction · 0.50
acl_stream_connectFunction · 0.50
acl_fifo_listen.cFile · 0.50
server_sigtermFunction · 0.50
netlink_openFunction · 0.50

Calls 5

acl_msg_errorFunction · 0.85
trace_infoFunction · 0.85
acl_getpeernameFunction · 0.85
should_checkFunction · 0.85
acl_last_serrorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…