diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 2002-06-30 20:40:15 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 2002-06-30 20:40:15 +0000 |
commit | e433ff062dd99be4fff1e07c40791a8f05c55d88 (patch) | |
tree | 7dc422032b39d61afffd38924a22f293102deb7e /examples/C++NPv2 | |
parent | adc61ce9c224e09033e62f3ca8e311e9d32538ef (diff) | |
download | ATCD-e433ff062dd99be4fff1e07c40791a8f05c55d88.tar.gz |
ChangeLogTag:Sun Jun 30 15:32:47 2002 Douglas C. Schmidt <schmidt@ace.cs.wustl.edu>
Diffstat (limited to 'examples/C++NPv2')
-rw-r--r-- | examples/C++NPv2/AC_Client_Logging_Daemon.cpp | 18 | ||||
-rw-r--r-- | examples/C++NPv2/Client_Logging_Daemon.cpp | 18 | ||||
-rw-r--r-- | examples/C++NPv2/Reactor_Logging_Server_Adapter.cpp | 4 | ||||
-rw-r--r-- | examples/C++NPv2/TP_Logging_Server.h | 18 |
4 files changed, 31 insertions, 27 deletions
diff --git a/examples/C++NPv2/AC_Client_Logging_Daemon.cpp b/examples/C++NPv2/AC_Client_Logging_Daemon.cpp index 11b9a1687e6..ddaad3c7dc2 100644 --- a/examples/C++NPv2/AC_Client_Logging_Daemon.cpp +++ b/examples/C++NPv2/AC_Client_Logging_Daemon.cpp @@ -47,7 +47,7 @@ protected: virtual int svc (); // Send the buffered log records using a gather-write operation. - virtual int send (ACE_Message_Block *blocks[], size_t &count); + virtual int send (ACE_Message_Block *chunk[], size_t &count); }; class AC_Input_Handler @@ -209,7 +209,7 @@ int AC_Output_Handler::handle_input (ACE_HANDLE h) { } int AC_Output_Handler::svc () { - ACE_Message_Block *blocks[ACE_IOV_MAX]; + ACE_Message_Block *chunk[ACE_IOV_MAX]; size_t message_index = 0; ACE_Time_Value time_of_last_send (ACE_OS::gettimeofday ()); ACE_Time_Value timeout; @@ -233,30 +233,30 @@ int AC_Output_Handler::svc () { if (mblk->size () == 0 && mblk->msg_type () == ACE_Message_Block::MB_STOP) { mblk->release (); break; } - blocks[message_index] = mblk; + chunk[message_index] = mblk; ++message_index; } if (message_index >= ACE_IOV_MAX || (ACE_OS::gettimeofday () - time_of_last_send >= FLUSH_TIMEOUT)) { - if (send (blocks, message_index) == -1) break; + if (send (chunk, message_index) == -1) break; time_of_last_send = ACE_OS::gettimeofday (); } } - if (message_index > 0) send (blocks, message_index); + if (message_index > 0) send (chunk, message_index); no_sigpipe.restore_action (SIGPIPE, original_action); return 0; } -int AC_Output_Handler::send (ACE_Message_Block *blocks[], size_t &count) { +int AC_Output_Handler::send (ACE_Message_Block *chunk[], size_t &count) { iovec iov[ACE_IOV_MAX]; size_t iov_size; int result = 0; for (iov_size = 0; iov_size < count; ++iov_size) { - iov[iov_size].iov_base = blocks[iov_size]->rd_ptr (); - iov[iov_size].iov_len = blocks[iov_size]->length (); + iov[iov_size].iov_base = chunk[iov_size]->rd_ptr (); + iov[iov_size].iov_len = chunk[iov_size]->length (); } while (peer ().sendv_n (iov, iov_size) == -1) if (connector_->reconnect () == -1) { @@ -265,7 +265,7 @@ int AC_Output_Handler::send (ACE_Message_Block *blocks[], size_t &count) { } while (iov_size > 0) { - blocks[--iov_size]->release (); blocks[iov_size] = 0; + chunk[--iov_size]->release (); chunk[iov_size] = 0; } count = iov_size; return result; diff --git a/examples/C++NPv2/Client_Logging_Daemon.cpp b/examples/C++NPv2/Client_Logging_Daemon.cpp index 9571c5abdea..346596a7f79 100644 --- a/examples/C++NPv2/Client_Logging_Daemon.cpp +++ b/examples/C++NPv2/Client_Logging_Daemon.cpp @@ -51,7 +51,7 @@ protected: virtual void *forward (); // Send the buffered log records using a gather-write operation. - virtual int send (ACE_Message_Block *blocks[], size_t &count); + virtual int send (ACE_Message_Block *chunk[], size_t &count); // Entry point into forwarder thread of control. static void *run_svc (void *arg); @@ -149,7 +149,7 @@ void *CLD_Handler::run_svc (void *arg) { void *CLD_Handler::forward () { - ACE_Message_Block *blocks[ACE_IOV_MAX]; + ACE_Message_Block *chunk[ACE_IOV_MAX]; size_t message_index = 0; ACE_Time_Value time_of_last_send (ACE_OS::gettimeofday ()); ACE_Time_Value timeout; @@ -170,32 +170,32 @@ void *CLD_Handler::forward () { if (mblk->size () == 0 && mblk->msg_type () == ACE_Message_Block::MB_STOP) { mblk->release (); break; } - blocks[message_index] = mblk; + chunk[message_index] = mblk; ++message_index; } if (message_index >= ACE_IOV_MAX || (ACE_OS::gettimeofday () - time_of_last_send >= FLUSH_TIMEOUT)) { - if (send (blocks, message_index) == -1) break; + if (send (chunk, message_index) == -1) break; time_of_last_send = ACE_OS::gettimeofday (); } } - if (message_index > 0) send (blocks, message_index); + if (message_index > 0) send (chunk, message_index); msg_queue_.close (); no_sigpipe.restore_action (SIGPIPE, original_action); return 0; } -int CLD_Handler::send (ACE_Message_Block *blocks[], size_t &count) { +int CLD_Handler::send (ACE_Message_Block *chunk[], size_t &count) { iovec iov[ACE_IOV_MAX]; size_t iov_size; int result = 0; for (iov_size = 0; iov_size < count; ++iov_size) { - iov[iov_size].iov_base = blocks[iov_size]->rd_ptr (); - iov[iov_size].iov_len = blocks[iov_size]->length (); + iov[iov_size].iov_base = chunk[iov_size]->rd_ptr (); + iov[iov_size].iov_len = chunk[iov_size]->length (); } while (peer ().sendv_n (iov, iov_size) == -1) if (connector_->reconnect () == -1) { @@ -204,7 +204,7 @@ int CLD_Handler::send (ACE_Message_Block *blocks[], size_t &count) { } while (iov_size > 0) { - blocks[--iov_size]->release (); blocks[iov_size] = 0; + chunk[--iov_size]->release (); chunk[iov_size] = 0; } count = iov_size; return result; diff --git a/examples/C++NPv2/Reactor_Logging_Server_Adapter.cpp b/examples/C++NPv2/Reactor_Logging_Server_Adapter.cpp index a548612630e..dc4d32920c0 100644 --- a/examples/C++NPv2/Reactor_Logging_Server_Adapter.cpp +++ b/examples/C++NPv2/Reactor_Logging_Server_Adapter.cpp @@ -15,7 +15,9 @@ template <class ACCEPTOR> int Reactor_Logging_Server_Adapter<ACCEPTOR>::init (int argc, ACE_TCHAR *argv[]) { int i; - ACE_Auto_Array_Ptr<char *> char_argv (new char*[argc]); + char *array = 0; + ACE_NEW_RETURN (array, new char *[argc], -1); + ACE_Auto_Array_Ptr<char *> char_argv (array); for (i = 0; i < argc; ++i) char_argv[i] = ACE::strnew (ACE_TEXT_ALWAYS_CHAR (argv[i])); diff --git a/examples/C++NPv2/TP_Logging_Server.h b/examples/C++NPv2/TP_Logging_Server.h index f4149437b3e..58dae64d078 100644 --- a/examples/C++NPv2/TP_Logging_Server.h +++ b/examples/C++NPv2/TP_Logging_Server.h @@ -102,17 +102,19 @@ public: virtual int init (int argc, ACE_TCHAR *argv[]) { int i; - const int MAX_ARGS = 10; - char *char_argv[MAX_ARGS]; - for (i = 0; i < argc && i < MAX_ARGS; ++i) + char *array = 0; + ACE_NEW_RETURN (array, new char *[argc], -1); + ACE_Auto_Array_Ptr<char *> char_argv (array); + + for (i = 0; i < argc; ++i) char_argv[i] = ACE::strnew (ACE_TEXT_ALWAYS_CHAR (argv[i])); - ACE_NEW_RETURN + ACE_NEW_NORETURN (logging_dispatcher_, TP_Logging_Server::LOGGING_DISPATCHER - (i, char_argv, ACE_Reactor::instance ()), -1); - for (i = 0; i < argc && i < MAX_ARGS; ++i) - ACE::strdelete (char_argv[i]); - return TP_LOGGING_TASK::instance ()->open (); + (i, char_argv, ACE_Reactor::instance ()), -1); + for (i = 0; i < argc; ++i) ACE::strdelete (char_argv[i]); + if (logging_dispatcher_ == 0) return -1; + else return TP_LOGGING_TASK::instance ()->open (); } virtual int fini () { |