dsi->socket = -1;
}
-static void dsi_tcp_timeout(DSI *dsi)
-{
- struct timeval tv;
- /* 2 seconds delay, most of the time it translates to 4 seconds:
- * send/write returns first with whatever it has written and the
- * second time it returns EAGAIN
- */
- tv.tv_sec = 2;
- tv.tv_usec = 0;
-
- /* Note: write isn't a restartable syscall if there's a timeout on the socket
- * we have to test for EINTR
- */
- if (setsockopt(dsi->socket, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv)) < 0) {
- LOG(log_error, logtype_dsi, "dsi_tcp_open: unable to set timeout %s", strerror(errno));
- exit(EXITERR_CLNT);
- }
-}
-
/* alarm handler for tcp_open */
static void timeout_handler(int sig _U_)
{
sigaction(SIGALRM, &oldact, NULL);
#endif
- dsi_tcp_timeout(dsi);
-
LOG(log_info, logtype_dsi, "AFP/TCP session from %s:%u",
getip_string((struct sockaddr *)&dsi->client),
getip_port((struct sockaddr *)&dsi->client));
/* Prepare hint for getaddrinfo */
memset(&hints, 0, sizeof hints);
+#if !defined(FREEBSD)
hints.ai_family = AF_UNSPEC;
+#endif
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_NUMERICSERV;
- if ( ! address)
+
+ if ( ! address) {
hints.ai_flags |= AI_PASSIVE;
- else
+#if defined(FREEBSD)
+ hints.ai_family = AF_INET6;
+#endif
+ } else {
hints.ai_flags |= AI_NUMERICHOST;
-
+#if defined(FREEBSD)
+ hints.ai_family = AF_UNSPEC;
+#endif
+ }
if ((ret = getaddrinfo(address ? address : NULL, port ? port : "548", &hints, &servinfo)) != 0) {
LOG(log_error, logtype_dsi, "dsi_tcp_init: getaddrinfo: %s\n", gai_strerror(ret));
return 0;
flag = 1;
setsockopt(dsi->serversock, SOL_SOCKET, SO_REUSEADDR, &flag, sizeof(flag));
#endif
+#if defined(FREEBSD) && defined(IPV6_BINDV6ONLY)
+ int on = 0;
+ setsockopt(dsi->serversock, IPPROTO_IPV6, IPV6_BINDV6ONLY, (char *)&on, sizeof (on));
+#endif
#ifdef USE_TCP_NODELAY
#ifndef SOL_TCP