Browse Source

Add source debugging to close failure

master
Con Kolivas 10 years ago
parent
commit
d1e08ac9c2
  1. 5
      src/libckpool.c
  2. 5
      src/libckpool.h

5
src/libckpool.c

@ -440,13 +440,14 @@ void block_socket(int fd)
fcntl(fd, F_SETFL, flags & ~O_NONBLOCK);
}
void _Close(int *fd)
void _close(int *fd, const char *file, const char *func, const int line)
{
if (*fd < 0)
return;
LOGDEBUG("Closing file handle %d", *fd);
if (unlikely(close(*fd)))
LOGWARNING("Close of fd %d failed with errno %d:%s", *fd, errno, strerror(errno));
LOGWARNING("Close of fd %d failed with errno %d:%s from %s %s:%d",
*fd, errno, strerror(errno), file, func, line);
*fd = -1;
}

5
src/libckpool.h

@ -426,8 +426,9 @@ void keep_sockalive(int fd);
void nolinger_socket(int fd);
void noblock_socket(int fd);
void block_socket(int fd);
void _Close(int *fd);
#define Close(FD) _Close(&FD)
void _close(int *fd, const char *file, const char *func, const int line);
#define _Close(FD) _close(FD, __FILE__, __func__, __LINE__)
#define Close(FD) _close(&FD, __FILE__, __func__, __LINE__)
int bind_socket(char *url, char *port);
int connect_socket(char *url, char *port);
int write_socket(int fd, const void *buf, size_t nbyte);

Loading…
Cancel
Save