diff options
Diffstat (limited to 'performance-tests/SCTP/SOCK_SEQPACK_srv.cpp')
-rw-r--r-- | performance-tests/SCTP/SOCK_SEQPACK_srv.cpp | 98 |
1 files changed, 50 insertions, 48 deletions
diff --git a/performance-tests/SCTP/SOCK_SEQPACK_srv.cpp b/performance-tests/SCTP/SOCK_SEQPACK_srv.cpp index 0191628c60c..84db9afc541 100644 --- a/performance-tests/SCTP/SOCK_SEQPACK_srv.cpp +++ b/performance-tests/SCTP/SOCK_SEQPACK_srv.cpp @@ -44,7 +44,7 @@ struct ArgStruct { static ACE_THR_FUNC_RETURN unmarshalledOctetServer (void *arg){ // unbundle the arguments - ArgStruct * args = ACE_reinterpret_cast(ArgStruct *,arg); + ArgStruct * args = reinterpret_cast<ArgStruct *> (arg); ACE_SOCK_SEQPACK_Association * dataModeStream = args->stream; ACE_CDR::ULong numIterations = args->numIters; delete args; @@ -59,13 +59,13 @@ static ACE_THR_FUNC_RETURN unmarshalledOctetServer (void *arg){ // read the size of the buffer to follow if ((dataModeStream->recv_n(&msgBufSize, ACE_CDR::LONG_SIZE, 0, &bt)) == -1) ACE_ERROR_RETURN((LM_ERROR, - "%p\n", - "recv_n"), + ACE_TEXT ("%p\n"), + ACE_TEXT ("recv_n")), 0); msgBufSize = ACE_NTOHL(msgBufSize); // allocate the buffer for the message payload - ACE_CDR::Octet * msgBuf=NULL; + ACE_CDR::Octet * msgBuf = 0; ACE_NEW_RETURN(msgBuf, ACE_CDR::Octet[msgBufSize], 0); @@ -73,8 +73,8 @@ static ACE_THR_FUNC_RETURN unmarshalledOctetServer (void *arg){ // read the buffer if ((dataModeStream->recv_n(msgBuf, msgBufSize, 0, &bt)) == -1) ACE_ERROR_RETURN((LM_ERROR, - "%p\n", - "recv_n"), + ACE_TEXT ("%p\n"), + ACE_TEXT ("recv_n")), 0); // clean up the allocated buffer @@ -86,8 +86,8 @@ static ACE_THR_FUNC_RETURN unmarshalledOctetServer (void *arg){ ACE_CDR::Short reply; if ((dataModeStream->send_n(&reply, ACE_CDR::SHORT_SIZE, 0, &bt)) == -1) ACE_ERROR_RETURN((LM_ERROR, - "%p\n", - "send_n"), + ACE_TEXT ("%p\n"), + ACE_TEXT ("send_n")), 0); } while (--numIterations); @@ -96,7 +96,7 @@ static ACE_THR_FUNC_RETURN unmarshalledOctetServer (void *arg){ dataModeStream->close(); delete dataModeStream; - return NULL; + return 0; } // sets up the dataModeSocket Stream, reads the test header infomation @@ -112,8 +112,8 @@ static void run_server (ACE_HANDLE handle) // Make sure we're not in non-blocking mode. if (dataModeStream->disable (ACE_NONBLOCK) == -1){ ACE_ERROR ((LM_ERROR, - "%p\n", - "disable")); + ACE_TEXT ("%p\n"), + ACE_TEXT ("disable"))); return; } else if (dataModeStream->get_remote_addr (cli_addr) == -1){ @@ -135,13 +135,13 @@ static void run_server (ACE_HANDLE handle) if (-1 == dataModeStream->set_option(IPPROTO_SCTP, SCTP_NODELAY, &nagle, sizeof nagle)){ // can't ise ACE_ERROR_RETURN b/c function has void return value ACE_ERROR((LM_ERROR, - "%p\n", - "set_option")); + ACE_TEXT ("%p\n"), + ACE_TEXT ("set_option"))); return; } ACE_DEBUG ((LM_DEBUG, - "(%P|%t) client %s connected from %d\n", + ACE_TEXT("(%P|%t) client %C connected from %d\n"), cli_addr.get_host_name (), cli_addr.get_port_number ())); @@ -158,8 +158,8 @@ static void run_server (ACE_HANDLE handle) // read the header if ((dataModeStream->recv_n(hdrBuf_a, hdrBufSize, 0, &bt)) == -1){ ACE_ERROR ((LM_ERROR, - "%p\n", - "recv_n")); + ACE_TEXT ("%p\n"), + ACE_TEXT ("recv_n"))); return; } @@ -179,14 +179,14 @@ static void run_server (ACE_HANDLE handle) // make sure the stream is good after the extractions if (!hdrCDR.good_bit()){ ACE_ERROR((LM_ERROR, - "%p\n", - "hdrCDR")); + ACE_TEXT ("%p\n"), + ACE_TEXT ("hdrCDR"))); return; } ACE_DEBUG ((LM_DEBUG, - "(%P|%t) Test for %u iterations\n", + ACE_TEXT ("(%P|%t) Test for %u iterations\n"), numIterations)); // deallocate the header buffer @@ -201,37 +201,37 @@ static void run_server (ACE_HANDLE handle) // Spawn a new thread and run the new connection in that thread of // control using the <server> function as the entry point. if (ACE_Thread_Manager::instance ()->spawn (unmarshalledOctetServer, - ACE_reinterpret_cast(void *,args), + reinterpret_cast<void *> (args), THR_DETACHED) == -1) ACE_ERROR ((LM_ERROR, - "(%P|%t) %p\n", - "spawn")); + ACE_TEXT ("(%P|%t) %p\n"), + ACE_TEXT ("spawn"))); #else - (*unmarshalledOctetServer) (ACE_reinterpret_cast(void *, args)); + (*unmarshalledOctetServer) (reinterpret_cast<void *> (args)); #endif /* ACE_HAS_THREADS */ } -int main(int argc, char **argv){ +int ACE_TMAIN (int argc, ACE_TCHAR **argv){ - Options_Manager optsMgr(argc, argv, "server-opts"); + Options_Manager optsMgr(argc, argv, ACE_TEXT ("server-opts")); // show usage is requested if (optsMgr._usage) { - optsMgr._show_usage(cerr, "server-opts"); + optsMgr._show_usage(stderr, ACE_TEXT ("server-opts")); return 1; } #ifndef ACE_HAS_SCTP // SCTP is not installed. Exit with informative error message. ACE_ERROR_RETURN((LM_ERROR, - "SCTP was NOT installed/accessible when this binary was compiled.\n"), + ACE_TEXT ("SCTP was NOT installed/accessible when this binary was compiled.\n")), 1); #endif // check that valid options were specified if (optsMgr._error) { - cerr << "ERROR: " << optsMgr._error_message << endl; + ACE_OS::fprintf (stderr, "ERROR: %s\n", ACE_TEXT_ALWAYS_CHAR (optsMgr._error_message)); return 1; } @@ -259,8 +259,8 @@ int main(int argc, char **argv){ ACE_DEFAULT_BACKLOG, optsMgr.test_transport_protocol) == -1) ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "open"), + ACE_TEXT ("%p\n"), + ACE_TEXT ("open")), 1); // this function checks that the port that was actually bound was @@ -269,24 +269,26 @@ int main(int argc, char **argv){ // used. if (acceptor_socket.get_local_addr(serverAddr) == -1) ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "get_local_addr"), + ACE_TEXT ("%p\n"), + ACE_TEXT ("get_local_addr")), 1); sockaddr_in *addresses = new sockaddr_in[ 1 + serverAddr.get_num_secondary_addresses() ]; serverAddr.get_addresses( addresses, 1 + serverAddr.get_num_secondary_addresses() ) ; - ACE_DEBUG((LM_DEBUG, - "(%P|%t) Accepting connections, using %s on port %u " - "on interfaces %s", - (optsMgr.test_transport_protocol == IPPROTO_SCTP) ? "IPPROTO_SCTP" : "IPPROTO_TCP", - serverAddr.get_port_number(), + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) Accepting connections, using %C on ") + ACE_TEXT ("port %u on interfaces %C"), + (optsMgr.test_transport_protocol == IPPROTO_SCTP) ? "IPPROTO_SCTP" : "IPPROTO_TCP", + serverAddr.get_port_number(), ACE_OS::inet_ntoa( addresses[0].sin_addr) )); unsigned int i; - for(i=1; i < serverAddr.get_num_secondary_addresses() ; ++i ) { - ACE_DEBUG((LM_DEBUG, " and %s", ACE_OS::inet_ntoa( addresses[i].sin_addr) )); + for(i=1; i <= serverAddr.get_num_secondary_addresses() ; ++i ) { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT (" and %C"), + ACE_OS::inet_ntoa (addresses[i].sin_addr))); } - ACE_DEBUG((LM_DEBUG, "\n" )); + ACE_DEBUG((LM_DEBUG, ACE_TEXT ("\n"))); delete[] addresses; @@ -319,31 +321,31 @@ int main(int argc, char **argv){ // check that select did not end with an error. if (result == -1) ACE_ERROR ((LM_ERROR, - "(%P|%t) %p\n", - "select")); + ACE_TEXT ("(%P|%t) %p\n"), + ACE_TEXT ("select"))); // check to see if select timed out. else if (result == 0){ ACE_DEBUG ((LM_DEBUG, - "(%P|%t) select timed out\n")); + ACE_TEXT ("(%P|%t) select timed out\n"))); } else { // case where a file descriptor was actually set if (!(temp.is_set(acceptor_socket.get_handle()))){ // CANNOT BE REACHED ACE_ERROR ((LM_ERROR, - "(%P|%t) %p\n", - "select: NO ERROR BUT NO FD SET")); + ACE_TEXT ("(%P|%t) %p\n"), + ACE_TEXT ("select: NO ERROR BUT NO FD SET"))); } else { // call accept to set up the new stream. if (acceptor_socket.accept(new_stream) == -1) { ACE_ERROR ((LM_ERROR, - "%p\n", - "accept")); + ACE_TEXT ("%p\n"), + ACE_TEXT ("accept"))); continue; } else{ ACE_DEBUG ((LM_DEBUG, - "(%P|%t) spawning server\n")); + ACE_TEXT ("(%P|%t) spawning server\n"))); } // Run the server. |