1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
--- src/common/utils/unixsocket.C.orig Fri Feb 21 21:41:25 1997
+++ src/common/utils/unixsocket.C Wed Oct 20 19:35:42 1999
@@ -67,6 +67,9 @@
#if defined(BSDI)
# define DONT_HAVE_SENDFD
#endif
+#if defined(FreeBSD)
+# define DONT_HAVE_SENDFD
+#endif
#if ! (defined HAVE_SENDFD || defined DONT_HAVE_SENDFD)
#error SEND_FD
@@ -110,19 +113,29 @@
sock = ::socket (AF_UNIX, SOCK_STREAM, 0) ;
if (sock < 0) {
DEBUGNL ("UNIXSocket::connect(): could not create socket") ;
+#ifndef __FreeBSD__
set_errno_(::errno) ;
+#endif
perror_("UNIXSocket::connect(): ::socket()") ;
return false ;
}
if (::connect (sock, (struct sockaddr*)&addr, addrlen) < 0) {
+#ifdef __FreeBSD__
+ if (errno == ECONNREFUSED && retries > 0) {
+#else
if (::errno == ECONNREFUSED && retries > 0) {
+#endif
// try again since peer's backlog may just be full
::close (sock) ;
::sleep (1) ; // ++++
continue ;
} else {
DEBUGNL ("UNIXSocket::connect(): cannot connect") ;
+#ifdef __FreeBSD__
+ set_errno_(errno) ;
+#else
set_errno_(::errno) ;
+#endif
perror_("UNIXSocket::connect(): ::connect()") ;
::close (sock) ;
return false ;
@@ -143,7 +156,11 @@
int sock = ::socket (AF_UNIX, SOCK_STREAM, 0) ;
if (sock < 0) {
DEBUGNL ("UNIXSocket::listen(): could not create socket") ;
+#ifdef __FreeBSD__
+ set_errno_(errno) ;
+#else
set_errno_(::errno) ;
+#endif
perror_("UNIXSocket::listen(): ::socket()") ;
return false ;
}
@@ -160,14 +177,22 @@
// systems have 2 chars (len and family) instead.
if (::bind (sock, (struct sockaddr*)&addr, 2 + pathlen) < 0) {
DEBUGNL ("UNIXSocket::listen(): ::bind() error") ;
+#ifdef __FreeBSD__
+ set_errno_(errno) ;
+#else
set_errno_(::errno) ;
+#endif
perror_("UNIXSocket::listen(): ::bind()") ;
::close (sock) ;
return false ;
}
if (::listen (sock, SOMAXCONN) < 0) {
DEBUGNL ("UNIXSocket::listen(): ::listen() error") ;
+#ifdef __FreeBSD__
+ set_errno_(errno) ;
+#else
set_errno_(::errno) ;
+#endif
perror_("UNIXSocket::listen(): ::listen()") ;
::close (sock);
return false ;
|