summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralex <alex@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-10-06 07:14:52 +0000
committeralex <alex@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-10-06 07:14:52 +0000
commit4a53ac428f1f59e4d31dc656a773a087896cfa0d (patch)
tree4da7b81bb67adb14b01064a54ce1b60ed8d88ecc
parent7c9e853b77dbb5a820149dac5686641d2016ca25 (diff)
downloadATCD-4a53ac428f1f59e4d31dc656a773a087896cfa0d.tar.gz
Changed the behavior of the POSIX implementation of Asynch_Accept
further more to make it behave exactly like the NT implementation. The Message Block now will contain <Local Address, Remote Addess> in that order as it looks in NT. THANKS a lot to Irfan for this change, so things will be robust even if Asynch_Accpet is used directly not through Asynch_Acceptor.
-rw-r--r--ace/Asynch_Acceptor.cpp63
-rw-r--r--ace/Asynch_IO.cpp26
-rw-r--r--ace/Proactor.cpp3
3 files changed, 30 insertions, 62 deletions
diff --git a/ace/Asynch_Acceptor.cpp b/ace/Asynch_Acceptor.cpp
index 17a7fa78b99..61ed495a102 100644
--- a/ace/Asynch_Acceptor.cpp
+++ b/ace/Asynch_Acceptor.cpp
@@ -292,60 +292,49 @@ ACE_Asynch_Acceptor<HANDLER>::parse_address (const ACE_Asynch_Accept::Result &re
{
ACE_Message_Block &message_block = result.message_block ();
#if defined (ACE_HAS_AIO_CALLS)
- // <message_block> has <remote_address_length> and the
- // <remote_address> in our case. No data.
-
- // Getting the remote address.
-
- // Get the length.
- int remote_size = *(int *)message_block.rd_ptr ();
-
- // Update the <rd_ptr>.
- message_block.rd_ptr (sizeof (int));
-
- // @@ Just debugging.
- ACE_DEBUG ((LM_DEBUG,
- "ACE_Asynch_Acceptor<HANDLER>::parse_address : Remote address length = %d\n",
- remote_size));
-
- // Set the address.
- remote_address.set_addr (ACE_reinterpret_cast (sockaddr_in *,
- message_block.rd_ptr ()),
- remote_size);
-
- // Update the <rd_ptr>.
- message_block.rd_ptr (remote_size);
-
- // Getting the local address.
+ // Getting the addresses.
+ sockaddr_in local_addr;
+ sockaddr_in remote_addr;
// Get the length.
- int local_size = sizeof (sockaddr_in);
+ int local_size = sizeof (local_addr);
+ int remote_size = sizeof (remote_addr);
- // Get the address.
- sockaddr_in local_addr;
+ // Get the local address.
if (ACE_OS::getsockname (result.accept_handle (),
ACE_reinterpret_cast (sockaddr *,
&local_addr),
&local_size) < 0)
ACE_ERROR ((LM_ERROR,
"%p\n",
- "ACE_Asynch_Acceptor::<getsocketname> failed"));
+ "ACE_Asynch_Acceptor::<getsockname> failed"));
- // @@ Just debugging.
- ACE_DEBUG ((LM_DEBUG,
- "ACE_Asynch_Acceptor<HANDLER>::parse_address:Local address size : %d\n",
- local_size));
-
- // Set the address.
- local_address.set_addr (&local_addr, local_size);
+ // Get the remote address.
+ if (ACE_OS::getpeername (result.accept_handle (),
+ ACE_reinterpret_cast (sockaddr *,
+ &remote_addr),
+ &remote_size) < 0)
+ ACE_ERROR ((LM_ERROR,
+ "%p\n",
+ "ACE_Asynch_Acceptor::<getpeername> failed"));
+
+ // Set the addresses.
+ local_address.set_addr (&local_addr, local_size);
+ remote_address.set_addr (&remote_addr, remote_size);
// @@ Just debugging.
- char local_address_buf [BUFSIZ];
+ char local_address_buf [BUFSIZ];
+ char remote_address_buf [BUFSIZ];
if (local_address.addr_to_string (local_address_buf, sizeof local_address_buf) == -1)
ACE_ERROR ((LM_ERROR, "Error:%p:can't obtain local_address's address string"));
ACE_DEBUG ((LM_DEBUG,
"ACE_Asynch_Acceptor<HANDLER>::parse_address : Local address %s\n",
local_address_buf));
+ if (remote_address.addr_to_string (remote_address_buf, sizeof remote_address_buf) == -1)
+ ACE_ERROR ((LM_ERROR, "Error:%p:can't obtain remote_address's address string"));
+ ACE_DEBUG ((LM_DEBUG,
+ "ACE_Asynch_Acceptor<HANDLER>::parse_address : Remote address %s\n",
+ remote_address_buf));
#elif (defined (ACE_HAS_WINNT4) && (ACE_HAS_WINNT4 != 0)) || (defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0))
sockaddr *local_addr = 0;
sockaddr *remote_addr = 0;
diff --git a/ace/Asynch_IO.cpp b/ace/Asynch_IO.cpp
index 3491658089d..ac6ed91aa38 100644
--- a/ace/Asynch_IO.cpp
+++ b/ace/Asynch_IO.cpp
@@ -909,26 +909,10 @@ ACE_Asynch_Accept_Handler::handle_input (ACE_HANDLE fd)
fd,
result->listen_handle ()));
- // There is not going to be any data read. So we can use the
- // <message_block> itself to take the <remote_address> as well as
- // the size of that address.
-
- // We will have atleast 2 * (sizeof (sockaddr_in) + sizeof (sockaddr)).
- size_t buffer_size = sizeof (sockaddr_in) + sizeof (sockaddr);
-
- // Parameters for the <accept> call.
- int *address_size = (int *)result->message_block ().wr_ptr ();
- *address_size = buffer_size;
-
- // Increment the wr_ptr.
- result->message_block ().wr_ptr (sizeof (int));
-
// Issue <accept> now.
// @@ We shouldnt block here since we have already done poll/select
// thru reactor. But are we sure?
- ACE_HANDLE new_handle = ACE_OS::accept (result->listen_handle (),
- (struct sockaddr *) result->message_block ().wr_ptr (),
- address_size);
+ ACE_HANDLE new_handle = ACE_OS::accept (result->listen_handle (), 0, 0);
if (new_handle == ACE_INVALID_HANDLE)
ACE_ERROR_RETURN ((LM_ERROR,
"Error:(%P | %t):%p:\n",
@@ -937,14 +921,6 @@ ACE_Asynch_Accept_Handler::handle_input (ACE_HANDLE fd)
// Accept has completed.
- // Update the <wr_ptr> for the <message block>.
- result->message_block ().wr_ptr (*address_size);
-
- // @@ Just debugging.
- ACE_DEBUG ((LM_DEBUG,
- "%N:%l:Address_size = [%d], New_handle = [%d]\n",
- *address_size, new_handle));
-
// Store the new handle.
result->accept_handle_ = new_handle;
diff --git a/ace/Proactor.cpp b/ace/Proactor.cpp
index 9ce47bd03de..b4023a1efaa 100644
--- a/ace/Proactor.cpp
+++ b/ace/Proactor.cpp
@@ -196,7 +196,10 @@ private:
ACE_AIO_Accept_Handler::ACE_AIO_Accept_Handler (ACE_Proactor* proactor)
: proactor_ (proactor),
+ // @@ The size can be less than this, since I read only the
+ // pointer.
message_block_ (sizeof (ACE_Asynch_Accept::Result))
+
{
// Open the pipe.
this->pipe_.open ();