}
#endif
-static void swrap_warn_stale(int fd)
-{
- struct socket_info *si;
- int si_index;
-
- swrap_mutex_lock(&socket_reset_mutex);
-
- si_index = find_socket_info_index(fd);
- if (si_index == -1) {
- swrap_mutex_unlock(&socket_reset_mutex);
- return;
- }
-
- si = swrap_get_socket_info(si_index);
- SWRAP_LOG(SWRAP_LOG_ERROR, "PID(%d):TID(%lld):PPID(%d): Stale fd=%d si_index=%d from sun_path[%s]",
- getpid(), (unsigned long long)gettid(), getppid(),
- fd, si_index, si->un_addr.sun_path);
-
- swrap_mutex_unlock(&socket_reset_mutex);
-}
-
static void swrap_remove_stale(int fd);
static int sockaddr_convert_to_un(struct socket_info *si,
file_hdr.frame_max_len = SWRAP_FRAME_LENGTH_MAX;
file_hdr.link_type = 0x0065; /* 101 RAW IP */
- swrap_warn_stale(fd);
- if (write(fd, &file_hdr, sizeof(file_hdr)) != sizeof(file_hdr)) {
+ if (libc_write(fd, &file_hdr, sizeof(file_hdr)) != sizeof(file_hdr)) {
libc_close(fd);
fd = -1;
}
}
fd = libc_open(fname, O_WRONLY|O_APPEND, 0644);
- if (fd != -1) {
- swrap_warn_stale(fd);
- }
return fd;
}
fd = swrap_pcap_get_fd(file_name);
if (fd != -1) {
- if (write(fd, packet, packet_len) != (ssize_t)packet_len) {
+ if (libc_write(fd, packet, packet_len) != (ssize_t)packet_len) {
free(packet);
goto done;
}
if (autobind_start_init != 1) {
autobind_start_init = 1;
- autobind_start = 12345;//getpid();
+ autobind_start = getpid();
autobind_start %= 50000;
autobind_start += 10000;
}
goto done;
}
- if (type == SOCKET_TYPE_CHAR_UDP) {
- SWRAP_LOG(SWRAP_LOG_ERROR, "PID(%d):TID(%lld):PPID(%d): Bound fd=%d port=%u to sun_path[%s]",
- getpid(), (unsigned long long)gettid(), getppid(),
- fd, (unsigned)port, un_addr.sa.un.sun_path);
-
- }
si->un_addr = un_addr.sa.un;
si->bound = 1;
return -1;
}
- sret = write(pipefd[1], &info, sizeof(info));
+ sret = libc_write(pipefd[1], &info, sizeof(info));
if (sret != sizeof(info)) {
int saved_errno = errno;
if (sret != -1) {
swrap_mutex_lock(&first_free_mutex);
SWRAP_LOCK_SI(si);
- swrap_log(SWRAP_LOG_ERROR, __func_name, "PID(%d):TID(%lld):PPID(%d): Close fd=%d si_index=%d from sun_path[%s]",
- getpid(), (unsigned long long)gettid(), getppid(),
- fd, si_index, si->un_addr.sun_path);
ret = __close_fd_fn(fd);
if (ret == -1) {
ret_errno = errno;