diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-09-17 06:06:52 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-09-17 06:06:52 +0000 |
commit | 285cd57c7853c3f21a3d8e9a8ee7598ab323410b (patch) | |
tree | 3fd9679b2f390aab3df949da80278f54b105bc96 /netsvcs | |
parent | 74fb1ea5cd72c0cbaaa74cd8a0f13ba042852b40 (diff) | |
download | ATCD-285cd57c7853c3f21a3d8e9a8ee7598ab323410b.tar.gz |
*** empty log message ***
Diffstat (limited to 'netsvcs')
-rw-r--r-- | netsvcs/lib/Client_Logging_Handler.cpp | 93 | ||||
-rw-r--r-- | netsvcs/servers/main.cpp | 27 |
2 files changed, 76 insertions, 44 deletions
diff --git a/netsvcs/lib/Client_Logging_Handler.cpp b/netsvcs/lib/Client_Logging_Handler.cpp index 64b61c5c758..e180fd4b165 100644 --- a/netsvcs/lib/Client_Logging_Handler.cpp +++ b/netsvcs/lib/Client_Logging_Handler.cpp @@ -105,57 +105,84 @@ ACE_Client_Logging_Handler::get_handle (void) const int ACE_Client_Logging_Handler::handle_input (ACE_HANDLE handle) { + ACE_DEBUG ((LM_DEBUG, "in handle_input, handle = %u\n", handle)); + if (handle == this->peer ().get_handle ()) // We're getting a message from the logging server! ACE_ERROR_RETURN ((LM_ERROR, "received data from server!\n"), -1); #if defined (ACE_LACKS_FIFO) else if (handle == this->acceptor_.get_handle ()) { - ACE_SOCK_Stream msg_queue; + ACE_SOCK_Stream client_stream; - if (this->acceptor_.accept (msg_queue) == -1) + if (this->acceptor_.accept (client_stream) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "accept"), -1); // Register message socket to receive input from clients. else if (ACE_Reactor::instance ()->register_handler - (msg_queue_.get_handle (), + (client_stream.get_handle (), this, ACE_Event_Handler::READ_MASK) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%n: %p\n", "register_handler"), -1); return 0; } +#endif /* ACE_LACKS_FIFO */ - // For the duration of this call store the socket into the FIFO so - // that we can use the ol' 2-read trick... Note that this assumes - // we aren't using STREAM pipes (if we were, we wouldn't need to use - // sockets!). - this->msg_queue_.set_handle (handle); + // We're getting a logging message from a local application. -#endif /* ACE_LACKS_FIFO */ - { - // We're getting a logging message from a local application. + ACE_Log_Record log_record; + ACE_Str_Buf msg ((void *) &log_record, + 0, + sizeof log_record); - ACE_Log_Record log_record; - ACE_Str_Buf msg ((void *) &log_record, - 0, - sizeof log_record); +#if defined (ACE_LACKS_FIFO) + long length; - ACE_DEBUG ((LM_DEBUG, "in handle_input\n")); + // We need to use the ol' two-read trick here since TCP sockets + // don't support framing natively. - if (this->msg_queue_.recv (msg) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "ACE_FIFO_Recv_Msg::recv"), - -1); - else if (this->send (log_record) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "send"), - 0); - return 0; - } - + switch (ACE_OS::recv (handle, + (char *) &length, + sizeof length, + MSG_PEEK)) + { + // Handle shutdown and error cases. + default: + case -1: + case 0: + if (ACE_Reactor::instance ()->remove_handler + (handle, + ACE_Event_Handler::READ_MASK + | ACE_Event_Handler::DONT_CALL) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%n: %p\n", + "remove_handler"), -1); + ACE_OS::closesocket (handle); + ACE_DEBUG ((LM_DEBUG, "client closing down\n")); + return 0; + /* NOTREACHED */ + + case sizeof length: + // Process normal data reception. + if (ACE_OS::recv (handle, + (char *) &log_record, + (int) length) != length) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "recv"), -1); + } +#else + // We've got a framed IPC mechanism, so we can just to a recv(). + if (this->msg_queue_.recv (msg) == -1) + ACE_ERROR_RETURN ((LM_ERROR, + "%p\n", + "ACE_FIFO_Recv_Msg::recv"), + 0); +#endif /* ACE_LACKS_FIFO */ + + // Forward the logging record to the server. + if (this->send (log_record) == -1) + ACE_ERROR ((LM_ERROR, + "%p\n", + "send")); return 0; } @@ -178,7 +205,8 @@ ACE_Client_Logging_Handler::close (u_long) #if defined (ACE_LACKS_FIFO) if (ACE_Reactor::instance ()->remove_handler (this->acceptor_.get_handle (), - ACE_Event_Handler::ACCEPT_MASK) == -1) + ACE_Event_Handler::ACCEPT_MASK + | ACE_Event_Handler::DONT_CALL) == -1) ACE_ERROR ((LM_ERROR, "%n: %p\n", "remove_handler")); #else @@ -353,7 +381,10 @@ ACE_Client_Logging_Connector::parse_args (int argc, char *argv[]) } } - this->server_addr_.set (this->server_port_, this->server_host_); + if (this->server_addr_.set (this->server_port_, + this->server_host_) == -1) + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "set"), -1); + return 0; } diff --git a/netsvcs/servers/main.cpp b/netsvcs/servers/main.cpp index af29e08863b..4c5c4d5de72 100644 --- a/netsvcs/servers/main.cpp +++ b/netsvcs/servers/main.cpp @@ -35,7 +35,7 @@ main (int argc, char *argv[]) if (daemon.open (argc, argv) == -1) { if (errno != ENOENT) - ACE_ERROR ((LM_ERROR, "%p\n%a", "open", 1)); + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), 1); else // Use static linking. { char *l_argv[3]; @@ -76,13 +76,6 @@ main (int argc, char *argv[]) if (sp_5->init (1, l_argv) == -1) ACE_ERROR ((LM_ERROR, "%p\n%a", "Threaded Logging Server", 1)); -#endif - l_argv[0] = "-p " ACE_DEFAULT_LOGGING_SERVER_PORT_STR; - l_argv[1] = 0; - ACE_Service_Object_Ptr sp_6 = ACE_SVC_INVOKE (ACE_Client_Logging_Connector); - - if (sp_6->init (1, l_argv) == -1) - ACE_ERROR ((LM_ERROR, "%p\n%a", "Logging Client", 1)); l_argv[0] = "-p " ACE_DEFAULT_LOGGING_SERVER_PORT_STR; l_argv[1] = 0; @@ -90,14 +83,22 @@ main (int argc, char *argv[]) if (sp_7->init (1, l_argv) == -1) ACE_ERROR ((LM_ERROR, "%p\n%a", "Logging Server", 1)); - } - // Run forever, performing the configured services until we are shut - // down by a SIGINT/SIGQUIT signal. +#endif + l_argv[0] = "-p " ACE_DEFAULT_LOGGING_SERVER_PORT_STR; + l_argv[1] = "-hflamenco.cs.wustl.edu"; + ACE_Service_Object_Ptr sp_6 = ACE_SVC_INVOKE (ACE_Client_Logging_Connector); - ACE_Reactor::run_event_loop (); + if (sp_6->init (2, l_argv) == -1) + ACE_ERROR ((LM_ERROR, "%p\n%a", "Logging Client", 1)); - // Destructors of ACE_Service_Object_Ptr's automagically call fini(). + // Run forever, performing the configured services until we are shut + // down by a SIGINT/SIGQUIT signal. + + ACE_Reactor::run_event_loop (); + + // Destructors of ACE_Service_Object_Ptr's automagically call fini(). + } } else // Use dynamic linking. |