summaryrefslogtreecommitdiff
path: root/ace
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1997-02-28 20:13:32 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1997-02-28 20:13:32 +0000
commitbfa1e90ba0c3711a2a74edfae03b3aa9bdd4ec36 (patch)
tree2a3da2a69b30260cb8cbb027c38afe60a7262240 /ace
parent915bcc45e3d686524f7bd3f806fdc79ae3c2ae18 (diff)
downloadATCD-bfa1e90ba0c3711a2a74edfae03b3aa9bdd4ec36.tar.gz
foo
Diffstat (limited to 'ace')
-rw-r--r--ace/OS.h1
-rw-r--r--ace/OS.i16
-rw-r--r--ace/SOCK.cpp22
-rw-r--r--ace/SOCK.h10
-rw-r--r--ace/SOCK_Acceptor.cpp9
-rw-r--r--ace/SOCK_Connector.cpp17
-rw-r--r--ace/SOCK_Dgram.cpp10
-rw-r--r--ace/SOCK_Dgram.h6
-rw-r--r--ace/SOCK_Dgram_Bcast.cpp10
-rw-r--r--ace/SOCK_Dgram_Bcast.h6
10 files changed, 68 insertions, 39 deletions
diff --git a/ace/OS.h b/ace/OS.h
index 6332a456314..f7db793f290 100644
--- a/ace/OS.h
+++ b/ace/OS.h
@@ -2380,6 +2380,7 @@ public:
static void _exit (int status = 0);
static void exit (int status = 0);
static pid_t fork (void);
+ static pid_t fork (const char *program_name);
static pid_t fork_exec (char *argv[]);
// Forks and exec's a process in a manner that works on Solaris and
// NT. argv[0] must be the full path name to the executable.
diff --git a/ace/OS.i b/ace/OS.i
index 823cde9d919..f598137b3c5 100644
--- a/ace/OS.i
+++ b/ace/OS.i
@@ -6371,4 +6371,20 @@ ACE_OS::thr_suspend (const ACE_Thread_ID &thr_id)
return ACE_OS::thr_suspend (thr_id.handle ());
}
+ACE_INLINE pid_t
+ACE_OS::fork (const char *program_name)
+{
+ // ACE_TRACE ("ACE_OS::fork");
+#if defined (ACE_WIN32) || defined (VXWORKS)
+ ACE_NOTSUP_RETURN (pid_t (-1));
+#else
+ pid_t pid = ::fork ();
+
+ if (pid == 0)
+ ACE_LOG_MSG->sync (program_name);
+
+ return pid;
+#endif /* ACE_WIN32 */
+}
+
#endif /* 0 */
diff --git a/ace/SOCK.cpp b/ace/SOCK.cpp
index 27886121f90..1e7e2a0ece3 100644
--- a/ace/SOCK.cpp
+++ b/ace/SOCK.cpp
@@ -60,11 +60,23 @@ ACE_SOCK::get_local_addr (ACE_Addr &sa) const
int
ACE_SOCK::open (int type,
int protocol_family,
- int protocol)
+ int protocol,
+ int reuse_addr)
{
ACE_TRACE ("ACE_SOCK::open");
+ int one = 1;
+
this->set_handle (ACE_OS::socket (protocol_family, type, protocol));
- return this->get_handle () == ACE_INVALID_HANDLE ? -1 : 0;
+
+ if (this->get_handle () == ACE_INVALID_HANDLE)
+ return -1;
+ else if (reuse_addr && this->set_option (SOL_SOCKET, SO_REUSEADDR,
+ &one, sizeof one))
+ {
+ this->close ();
+ return -1;
+ }
+ return 0;
}
// Close down a ACE_SOCK.
@@ -88,9 +100,11 @@ ACE_SOCK::close (void)
ACE_SOCK::ACE_SOCK (int type,
int protocol_family,
- int protocol)
+ int protocol,
+ int reuse_addr)
{
ACE_TRACE ("ACE_SOCK::ACE_SOCK");
- if (this->open (type, protocol_family, protocol) == -1)
+ if (this->open (type, protocol_family,
+ protocol, reuse_addr) == -1)
ACE_ERROR ((LM_ERROR, "%p\n", "ACE_SOCK::ACE_SOCK"));
}
diff --git a/ace/SOCK.h b/ace/SOCK.h
index d2d2ac19647..64ecc5b5225 100644
--- a/ace/SOCK.h
+++ b/ace/SOCK.h
@@ -71,11 +71,13 @@ protected:
int open (int type,
int protocol_family,
- int protocol);
- // Wrapper around the socket() system call.
+ int protocol,
+ int reuse_addr);
+ // Wrapper around the <socket> system call.
- ACE_SOCK (int type, int protocol_family, int protocol = 0);
- // Constructor with arguments to also call the socket() system call.
+ ACE_SOCK (int type, int protocol_family,
+ int protocol = 0, int reuse_addr = 0);
+ // Constructor with arguments to call the <socket> system call.
#if defined (ACE_WIN32)
static ACE_SOCK dummy_;
diff --git a/ace/SOCK_Acceptor.cpp b/ace/SOCK_Acceptor.cpp
index bd2a03177af..84d23733d9c 100644
--- a/ace/SOCK_Acceptor.cpp
+++ b/ace/SOCK_Acceptor.cpp
@@ -59,15 +59,10 @@ ACE_SOCK_Acceptor::open (const ACE_Addr &local_sap,
int protocol)
{
ACE_TRACE ("ACE_SOCK_Acceptor::open");
- int one = 1;
int error = 0;
- if (ACE_SOCK::open (SOCK_STREAM, protocol_family, protocol)
- == -1)
- error = 1;
- else if (reuse_addr &&
- this->set_option (SOL_SOCKET, SO_REUSEADDR,
- &one, sizeof one) == -1)
+ if (ACE_SOCK::open (SOCK_STREAM, protocol_family,
+ protocol, reuse_addr) == -1)
error = 1;
else if (&local_sap == &ACE_Addr::sap_any
&& protocol_family == PF_INET)
diff --git a/ace/SOCK_Connector.cpp b/ace/SOCK_Connector.cpp
index 6b2d437f32e..e7224370b1f 100644
--- a/ace/SOCK_Connector.cpp
+++ b/ace/SOCK_Connector.cpp
@@ -34,7 +34,8 @@ ACE_SOCK_Connector::connect (ACE_SOCK_Stream &new_stream,
// Only open a new socket if we don't already have a valid handle.
if (new_stream.get_handle () == ACE_INVALID_HANDLE)
{
- if (ACE_SOCK::open (SOCK_STREAM, protocol_family, protocol) == -1)
+ if (ACE_SOCK::open (SOCK_STREAM, protocol_family,
+ protocol, reuse_addr) == -1)
return -1;
}
else // Borrow the handle from the NEW_STREAM.
@@ -45,18 +46,10 @@ ACE_SOCK_Connector::connect (ACE_SOCK_Stream &new_stream,
if (&local_sap != &ACE_Addr::sap_any)
{
- // Bind the local endpoint to a specific addr.
+ sockaddr *laddr = (sockaddr *) local_sap.get_addr ();
+ size_t size = local_sap.get_size ();
+ result = ACE_OS::bind (this->get_handle (), laddr, size);
- int one = 1;
- if (reuse_addr && this->set_option (SOL_SOCKET, SO_REUSEADDR,
- &one, sizeof one) == -1)
- result = -1;
- else
- {
- sockaddr *laddr = (sockaddr *) local_sap.get_addr ();
- size_t size = local_sap.get_size ();
- result = ACE_OS::bind (this->get_handle (), laddr, size);
- }
if (result == -1)
{
this->close ();
diff --git a/ace/SOCK_Dgram.cpp b/ace/SOCK_Dgram.cpp
index 94238b50ca5..f8b1e07d813 100644
--- a/ace/SOCK_Dgram.cpp
+++ b/ace/SOCK_Dgram.cpp
@@ -84,8 +84,9 @@ ACE_SOCK_Dgram::shared_open (const ACE_Addr &local, int protocol_family)
ACE_SOCK_Dgram::ACE_SOCK_Dgram (const ACE_Addr &local,
int protocol_family,
- int protocol)
- : ACE_SOCK (SOCK_DGRAM, protocol_family, protocol)
+ int protocol,
+ int reuse_addr)
+ : ACE_SOCK (SOCK_DGRAM, protocol_family, protocol, reuse_addr)
{
ACE_TRACE ("ACE_SOCK_Dgram::ACE_SOCK_Dgram");
if (this->shared_open (local, protocol_family) == -1)
@@ -97,11 +98,12 @@ ACE_SOCK_Dgram::ACE_SOCK_Dgram (const ACE_Addr &local,
int
ACE_SOCK_Dgram::open (const ACE_Addr &local,
int protocol_family,
- int protocol)
+ int protocol,
+ int reuse_addr)
{
ACE_TRACE ("ACE_SOCK_Dgram::open");
if (ACE_SOCK::open (SOCK_DGRAM, protocol_family,
- protocol) == -1)
+ protocol, reuse_addr) == -1)
return -1;
else
return this->shared_open (local, protocol_family);
diff --git a/ace/SOCK_Dgram.h b/ace/SOCK_Dgram.h
index 402a38c9bce..9a2f8aefce0 100644
--- a/ace/SOCK_Dgram.h
+++ b/ace/SOCK_Dgram.h
@@ -32,12 +32,14 @@ public:
ACE_SOCK_Dgram (const ACE_Addr &local,
int protocol_family = PF_INET,
- int protocol = 0);
+ int protocol = 0,
+ int reuse_addr = 0);
// Initiate a socket dgram.
int open (const ACE_Addr &local,
int protocol_family = PF_INET,
- int protocol = 0);
+ int protocol = 0,
+ int reuse_addr = 0);
// Initiate a socket dgram.
// = Data transfer routines.
diff --git a/ace/SOCK_Dgram_Bcast.cpp b/ace/SOCK_Dgram_Bcast.cpp
index 641bb3788c7..f9355d7119d 100644
--- a/ace/SOCK_Dgram_Bcast.cpp
+++ b/ace/SOCK_Dgram_Bcast.cpp
@@ -55,8 +55,9 @@ ACE_SOCK_Dgram_Bcast::ACE_SOCK_Dgram_Bcast (void)
ACE_SOCK_Dgram_Bcast::ACE_SOCK_Dgram_Bcast (const ACE_Addr &local,
int protocol_family,
- int protocol)
- : ACE_SOCK_Dgram (local, protocol_family, protocol),
+ int protocol,
+ int reuse_addr)
+ : ACE_SOCK_Dgram (local, protocol_family, protocol, reuse_addr),
if_list_ (0)
{
ACE_TRACE ("ACE_SOCK_Dgram_Bcast::ACE_SOCK_Dgram_Bcast");
@@ -70,11 +71,12 @@ ACE_SOCK_Dgram_Bcast::ACE_SOCK_Dgram_Bcast (const ACE_Addr &local,
int
ACE_SOCK_Dgram_Bcast::open (const ACE_Addr &local,
int protocol_family,
- int protocol)
+ int protocol,
+ int reuse_addr)
{
ACE_TRACE ("ACE_SOCK_Dgram_Bcast::open");
if (this->ACE_SOCK_Dgram::open (local, protocol_family,
- protocol) == -1)
+ protocol, reuse_addr) == -1)
return -1;
return this->mk_broadcast ();
diff --git a/ace/SOCK_Dgram_Bcast.h b/ace/SOCK_Dgram_Bcast.h
index f44270a37a9..bba7cebe842 100644
--- a/ace/SOCK_Dgram_Bcast.h
+++ b/ace/SOCK_Dgram_Bcast.h
@@ -44,12 +44,14 @@ public:
ACE_SOCK_Dgram_Bcast (const ACE_Addr &local,
int protocol_family = PF_INET,
- int protocol = 0);
+ int protocol = 0,
+ int reuse_addr = 0);
// Initiate a connectionless datagram broadcast endpoint.
int open (const ACE_Addr &local,
int protocol_family = PF_INET,
- int protocol = 0);
+ int protocol = 0,
+ int reuse_addr = 0);
// Initiate a connectionless datagram broadcast endpoint.
int close (void);