summaryrefslogtreecommitdiff
path: root/tests/Conn_Test.cpp
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1998-08-22 00:56:43 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1998-08-22 00:56:43 +0000
commit7c48efdb65254428973217391037befc3a512b8d (patch)
tree03af35374dc0d74c199ec5e6479cde5e97247880 /tests/Conn_Test.cpp
parent848b63fd26b71a0d53e1d5d9e18a310fdece5056 (diff)
downloadATCD-7c48efdb65254428973217391037befc3a512b8d.tar.gz
*** empty log message ***
Diffstat (limited to 'tests/Conn_Test.cpp')
-rw-r--r--tests/Conn_Test.cpp124
1 files changed, 87 insertions, 37 deletions
diff --git a/tests/Conn_Test.cpp b/tests/Conn_Test.cpp
index 26a590f43fb..de5167f9006 100644
--- a/tests/Conn_Test.cpp
+++ b/tests/Conn_Test.cpp
@@ -51,20 +51,26 @@ Svc_Handler::Svc_Handler (ACE_Thread_Manager *)
int
Svc_Handler::open (void *)
{
- ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("(%P|%t) opening Svc_Handler %d with handle %d\n"),
- this, this->peer ().get_handle ()));
+ ACE_DEBUG ((LM_DEBUG,
+ ASYS_TEXT ("(%P|%t) opening Svc_Handler %d with handle %d\n"),
+ this,
+ this->peer ().get_handle ()));
// Enable non-blocking I/O.
if (this->peer ().enable (ACE_NONBLOCK) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, ASYS_TEXT ("(%P|%t) %p\n"), ASYS_TEXT ("enable")), -1);
-
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ASYS_TEXT ("(%P|%t) %p\n"),
+ ASYS_TEXT ("enable")),
+ -1);
return 0;
}
int
Svc_Handler::recycle (void *)
{
- ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("(%P|%t) recycling Svc_Handler %d with handle %d\n"),
- this, this->peer ().get_handle ()));
+ ACE_DEBUG ((LM_DEBUG,
+ ASYS_TEXT ("(%P|%t) recycling Svc_Handler %d with handle %d\n"),
+ this,
+ this->peer ().get_handle ()));
return 0;
}
@@ -75,7 +81,9 @@ Svc_Handler::send_data (void)
for (char *c = ACE_ALPHABET; *c != '\0'; c++)
if (this->peer ().send_n (c, 1) == -1)
- ACE_ERROR ((LM_ERROR, ASYS_TEXT ("(%P|%t) %p\n"), ASYS_TEXT ("send_n")));
+ ACE_ERROR ((LM_ERROR,
+ ASYS_TEXT ("(%P|%t) %p\n"),
+ ASYS_TEXT ("send_n")));
}
void
@@ -97,7 +105,9 @@ Svc_Handler::recv_data (void)
if (ACE_OS::select (int (new_stream.get_handle ()) + 1,
handle_set,
0, 0, 0) == -1)
- ACE_ERROR ((LM_ERROR, ASYS_TEXT ("(%P|%t) %p\n"), ASYS_TEXT ("select")));
+ ACE_ERROR ((LM_ERROR,
+ ASYS_TEXT ("(%P|%t) %p\n"),
+ ASYS_TEXT ("select")));
else
{
char c;
@@ -124,7 +134,9 @@ Svc_Handler::recv_data (void)
// since we're going to recycle it for the next
// iteration).
if (new_stream.close () == -1)
- ACE_ERROR ((LM_ERROR, ASYS_TEXT ("(%P|%t) %p\n"), ASYS_TEXT ("close")));
+ ACE_ERROR ((LM_ERROR,
+ ASYS_TEXT ("(%P|%t) %p\n"),
+ ASYS_TEXT ("close")));
break;
}
else if (r_bytes == -1)
@@ -133,7 +145,9 @@ Svc_Handler::recv_data (void)
ACE_DEBUG ((LM_DEBUG,
ASYS_TEXT ("(%P|%t) no input available, going back to reading\n")));
else
- ACE_ERROR ((LM_ERROR, ASYS_TEXT ("(%P|%t) %p\n"), ASYS_TEXT ("recv_n")));
+ ACE_ERROR ((LM_ERROR,
+ ASYS_TEXT ("(%P|%t) %p\n"),
+ ASYS_TEXT ("recv_n")));
}
}
}
@@ -144,8 +158,9 @@ Svc_Handler::close (u_long side)
{
// Only run this protocol if we're the write-side (i.e., "1").
if (side == 1 && this->peer ().close () == -1)
- ACE_ERROR ((LM_ERROR, ASYS_TEXT ("(%P|%t) %p\n"), ASYS_TEXT ("close_writer")));
-
+ ACE_ERROR ((LM_ERROR,
+ ASYS_TEXT ("(%P|%t) %p\n"),
+ ASYS_TEXT ("close_writer")));
// Trigger the shutdown.
return this->handle_close ();
}
@@ -153,8 +168,10 @@ Svc_Handler::close (u_long side)
int
Svc_Handler::idle (u_long flags)
{
- ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("(%P|%t) idling Svc_Handler %d with handle %d\n"),
- this, this->peer ().get_handle ()));
+ ACE_DEBUG ((LM_DEBUG,
+ ASYS_TEXT ("(%P|%t) idling Svc_Handler %d with handle %d\n"),
+ this,
+ this->peer ().get_handle ()));
return ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>::idle (flags);
}
@@ -225,7 +242,9 @@ timed_blocking_connect (CONNECTOR &con,
// connect quickly since we're in the same address space or same
// host).
if (con.connect (svc_handler, server_addr, options) == -1)
- ACE_ERROR ((LM_ERROR, ASYS_TEXT ("(%P|%t) %p\n"), ASYS_TEXT ("connection failed")));
+ ACE_ERROR ((LM_ERROR,
+ ASYS_TEXT ("(%P|%t) %p\n"),
+ ASYS_TEXT ("connection failed")));
else
{
// Send the data to the server.
@@ -233,7 +252,9 @@ timed_blocking_connect (CONNECTOR &con,
// Close the connection completely.
if (svc_handler->close (1) == -1)
- ACE_ERROR ((LM_ERROR, ASYS_TEXT ("(%P|%t) %p\n"), ASYS_TEXT ("close")));
+ ACE_ERROR ((LM_ERROR,
+ ASYS_TEXT ("(%P|%t) %p\n"),
+ ASYS_TEXT ("close")));
}
}
@@ -246,7 +267,9 @@ blocking_connect (CONNECTOR &con,
// Perform a blocking connect to the server.
if (con.connect (svc_handler, server_addr) == -1)
- ACE_ERROR ((LM_ERROR, ASYS_TEXT ("(%P|%t) %p\n"), ASYS_TEXT ("connection failed")));
+ ACE_ERROR ((LM_ERROR,
+ ASYS_TEXT ("(%P|%t) %p\n"),
+ ASYS_TEXT ("connection failed")));
else
{
// Send the data to the server.
@@ -254,7 +277,9 @@ blocking_connect (CONNECTOR &con,
// Close the connection completely.
if (svc_handler->close (1) == -1)
- ACE_ERROR ((LM_ERROR, ASYS_TEXT ("(%P|%t) %p\n"), ASYS_TEXT ("close")));
+ ACE_ERROR ((LM_ERROR,
+ ASYS_TEXT ("(%P|%t) %p\n"),
+ ASYS_TEXT ("close")));
}
}
@@ -271,11 +296,14 @@ cached_connect (STRAT_CONNECTOR &con,
{
// Perform a blocking connect to the server using the Strategy
// Connector with a connection caching strategy. Since we are
- // connecting to the same <server_addr> these calls will return the
- // same dynamically allocated <Svc_Handler> for each <connect>.
+ // connecting to the same <server_addr> these calls will return
+ // the same dynamically allocated <Svc_Handler> for each
+ // <connect>.
if (con.connect (svc_handler, server_addr) == -1)
{
- ACE_ERROR ((LM_ERROR, ASYS_TEXT ("(%P|%t) %p\n"), ASYS_TEXT ("connection failed")));
+ ACE_ERROR ((LM_ERROR,
+ ASYS_TEXT ("(%P|%t) %p\n"),
+ ASYS_TEXT ("connection failed")));
return;
}
@@ -318,7 +346,8 @@ client_connections (void *arg)
Client_Info *info = (Client_Info *) arg;
// Run the timed-blocking test.
- ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("(%P|%t) **** starting timed-blocking connect\n")));
+ ACE_DEBUG ((LM_DEBUG,
+ ASYS_TEXT ("(%P|%t) **** starting timed-blocking connect\n")));
timed_blocking_connect (*info->connector_,
*info->server_addr_);
@@ -328,7 +357,8 @@ client_connections (void *arg)
#endif /* ACE_HAS_THREADS */
// Run the blocking test.
- ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("(%P|%t) **** starting blocking connect\n")));
+ ACE_DEBUG ((LM_DEBUG,
+ ASYS_TEXT ("(%P|%t) **** starting blocking connect\n")));
blocking_connect (*info->connector_,
*info->server_addr_);
@@ -338,7 +368,8 @@ client_connections (void *arg)
#endif /* ACE_HAS_THREADS */
// Run the cached blocking test.
- ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("(%P|%t) **** starting cached blocking connect\n")));
+ ACE_DEBUG ((LM_DEBUG,
+ ASYS_TEXT ("(%P|%t) **** starting cached blocking connect\n")));
cached_connect (*info->strat_connector_,
*info->server_addr_);
@@ -382,7 +413,9 @@ client (void *arg)
(ACE_THR_FUNC) client_connections,
(void *) &info,
THR_NEW_LWP) == -1)
- ACE_ERROR ((LM_ERROR, ASYS_TEXT ("(%P|%t) %p\n%a"), ASYS_TEXT ("client thread spawn failed")));
+ ACE_ERROR ((LM_ERROR,
+ ASYS_TEXT ("(%P|%t) %p\n%a"),
+ ASYS_TEXT ("client thread spawn failed")));
// Wait for the threads to exit.
client_manager.wait ();
@@ -399,7 +432,8 @@ static void *
server (void *arg)
{
#if defined (VXWORKS)
- ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("(%P|%t) server stack size is %u\n"),
+ ACE_DEBUG ((LM_DEBUG,
+ ASYS_TEXT ("(%P|%t) server stack size is %u\n"),
ACE_OS::thr_min_stack ()));
#endif /* VXWORKS */
@@ -437,7 +471,8 @@ server (void *arg)
ASYS_TEXT ("accept failed, shutting down")),
0);
}
- ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("(%P|%t) client %s connected from %d\n"),
+ ACE_DEBUG ((LM_DEBUG,
+ ASYS_TEXT ("(%P|%t) client %s connected from %d\n"),
cli_addr.get_host_name (),
cli_addr.get_port_number ()));
@@ -475,7 +510,9 @@ spawn_processes (ACCEPTOR *acceptor,
switch (pid)
{
case -1:
- ACE_ERROR ((LM_ERROR, ASYS_TEXT ("(%P|%t) %p\n%a"), ASYS_TEXT ("fork failed")));
+ ACE_ERROR ((LM_ERROR,
+ ASYS_TEXT ("(%P|%t) %p\n%a"),
+ ASYS_TEXT ("fork failed")));
ACE_OS::exit (-1);
/* NOTREACHED */
case 0: // In the child.
@@ -499,14 +536,18 @@ spawn_processes (ACCEPTOR *acceptor,
for (i = 0; i < n_servers; i++)
// Shutdown the servers.
if (ACE_OS::kill (children[i], SIGTERM) == -1)
- ACE_ERROR ((LM_ERROR, ASYS_TEXT ("(%P|%t) %p for %d\n"), children[i]));
+ ACE_ERROR ((LM_ERROR,
+ ASYS_TEXT ("(%P|%t) %p for %d\n"),
+ children[i]));
pid_t child;
do
{
child = ACE_OS::wait ();
- ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("(%P|%t) reaping %d\n"), child));
+ ACE_DEBUG ((LM_DEBUG,
+ ASYS_TEXT ("(%P|%t) reaping %d\n"),
+ child));
}
while (child != -1);
@@ -538,8 +579,9 @@ spawn_threads (ACCEPTOR *acceptor,
for (i = 0; i < n_servers; ++i)
{
ACE_NEW (server_name[i], ASYS_TCHAR[32]);
- ACE_OS::sprintf (server_name[i], ASYS_TEXT ("server%u"), i);
-
+ ACE_OS::sprintf (server_name[i],
+ ASYS_TEXT ("server%u"),
+ i);
stack_size[i] = 40000;
ACE_NEW (stack[i], char[stack_size[i]]);
@@ -570,7 +612,8 @@ spawn_threads (ACCEPTOR *acceptor,
, stack_size
#endif /* VXWORKS */
) == -1)
- ACE_ERROR ((LM_ERROR, ASYS_TEXT ("(%P|%t) %p\n%a"),
+ ACE_ERROR ((LM_ERROR,
+ ASYS_TEXT ("(%P|%t) %p\n%a"),
ASYS_TEXT ("server thread create failed")));
if (ACE_Thread_Manager::instance ()->spawn
@@ -581,7 +624,8 @@ spawn_threads (ACCEPTOR *acceptor,
, &client_name
#endif /* VXWORKS */
) == -1)
- ACE_ERROR ((LM_ERROR, ASYS_TEXT ("(%P|%t) %p\n%a"),
+ ACE_ERROR ((LM_ERROR,
+ ASYS_TEXT ("(%P|%t) %p\n%a"),
ASYS_TEXT ("client thread create failed")));
// Wait for the threads to exit.
@@ -627,15 +671,21 @@ main (int argc, ASYS_TCHAR *argv[])
// Bind acceptor to any port and then find out what the port was.
if (acceptor.open ((const ACE_INET_Addr &) ACE_Addr::sap_any) == -1
|| acceptor.acceptor ().get_local_addr (server_addr) == -1)
- ACE_ERROR ((LM_ERROR, ASYS_TEXT ("(%P|%t) %p\n"), ASYS_TEXT ("open")));
+ ACE_ERROR ((LM_ERROR,
+ ASYS_TEXT ("(%P|%t) %p\n"),
+ ASYS_TEXT ("open")));
else
{
- ACE_DEBUG ((LM_DEBUG, ASYS_TEXT ("(%P|%t) starting server at port %d\n"),
+ ACE_DEBUG ((LM_DEBUG,
+ ASYS_TEXT ("(%P|%t) starting server at port %d\n"),
server_addr.get_port_number ()));
#if !defined (ACE_LACKS_FORK)
if (spawn_processes (&acceptor, &server_addr) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, ASYS_TEXT ("(%P|%r) %p\n"), ASYS_TEXT ("spawn_processes")), 1);
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ASYS_TEXT ("(%P|%r) %p\n"),
+ ASYS_TEXT ("spawn_processes")),
+ 1);
#elif defined (ACE_HAS_THREADS)
spawn_threads (&acceptor, &server_addr);
#else /* ACE_LACKS_FORK && ! ACE_HAS_THREADS */