-const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.114 2012/03/09 17:56:41 fabiankeil Exp $";
+const char jbsockets_rcs[] = "$Id: jbsockets.c,v 1.118 2012/10/21 12:44:58 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jbsockets.c,v $
#endif
-#ifdef FEATURE_CONNECTION_KEEP_ALIVE
#ifdef HAVE_POLL
#ifdef __GLIBC__
#include <sys/poll.h>
#include <poll.h>
#endif /* def __GLIBC__ */
#endif /* HAVE_POLL */
-#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
#include "project.h"
int bytes_drained;
#ifdef HAVE_SHUTDOWN
-/* Apparently Windows has shutdown() but now SHUT_WR */
+/* Apparently Windows has shutdown() but not SHUT_WR. */
#ifndef SHUT_WR
#define SHUT_WR 1
#endif
if (0 != shutdown(fd, SHUT_WR))
{
- log_error(LOG_LEVEL_ERROR, "Failed to shutdown socket %d %E", fd);
+ log_error(LOG_LEVEL_CONNECT, "Failed to shutdown socket %d: %E", fd);
}
#endif
#define ARBITRARY_DRAIN_LIMIT 10000
bytes_drained = read_socket(fd, drainage, sizeof(drainage));
if (bytes_drained < 0)
{
- log_error(LOG_LEVEL_ERROR, "Failed to drain socket %d %E", fd);
+ log_error(LOG_LEVEL_CONNECT, "Failed to drain socket %d: %E", fd);
}
else if (bytes_drained > 0)
{
}
#endif
+#ifdef SO_LINGER
+ {
+ struct linger linger_options;
+ linger_options.l_onoff = 1;
+ linger_options.l_linger = 5;
+ if (0 != setsockopt(fd, SOL_SOCKET, SO_LINGER, &linger_options, sizeof(linger_options)))
+ {
+ log_error(LOG_LEVEL_ERROR, "Setting SO_LINGER on socket %d failed.", afd);
+ }
+ }
+#endif
+
csp->cfd = afd;
#ifdef HAVE_RFC2553
csp->ip_addr_str = malloc(NI_MAXHOST);
}
-#ifdef FEATURE_CONNECTION_KEEP_ALIVE
/*********************************************************************
*
* Function : socket_is_still_alive
return (no_data_waiting || (1 == recv(sfd, buf, 1, MSG_PEEK)));
}
-#endif /* def FEATURE_CONNECTION_KEEP_ALIVE */
/*