diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-03-14 06:55:12 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1997-03-14 06:55:12 +0000 |
commit | b9f4b52e69fa852942a1d7102559fdddf0a9f2e2 (patch) | |
tree | 0a135b4d504125a10a24c5274de0c63df2559390 | |
parent | 793d527cb0a297a08dd83499ac26736dcec2950d (diff) | |
download | ATCD-b9f4b52e69fa852942a1d7102559fdddf0a9f2e2.tar.gz |
*** empty log message ***
-rw-r--r-- | README | 1 | ||||
-rw-r--r-- | ace/Event_Handler.h | 1 | ||||
-rw-r--r-- | ace/Log_Msg.cpp | 2 | ||||
-rw-r--r-- | ace/OS.cpp | 16 | ||||
-rw-r--r-- | ace/OS.i | 16 | ||||
-rw-r--r-- | ace/Reactor.cpp | 9 | ||||
-rw-r--r-- | ace/Stream.cpp | 2 | ||||
-rw-r--r-- | ace/Timer_Heap.cpp | 6 | ||||
-rw-r--r-- | ace/Timer_List.cpp | 6 | ||||
-rw-r--r-- | ace/Timer_List.h | 2 | ||||
-rw-r--r-- | ace/Timer_Queue.h | 16 | ||||
-rw-r--r-- | examples/Mem_Map/IO-tests/IO_Test.cpp | 9 | ||||
-rw-r--r-- | tests/Timer_Queue_Test.cpp | 25 |
13 files changed, 65 insertions, 46 deletions
@@ -484,6 +484,7 @@ Paul Han <phan@CCGATE.HAC.COM> Jeff Morgan <jeff@audioactive.com> Arturo <mitosys@colomsat.net.co> Elliot Lau <eeklau@post1.com> +Mark Wright <markw@odi.com.au> I would particularly like to thank Paul Stephenson, who worked with me at Ericsson and is now at ObjectSpace. Paul devised the recursive diff --git a/ace/Event_Handler.h b/ace/Event_Handler.h index 6d7ba541cfe..1595a3c43c5 100644 --- a/ace/Event_Handler.h +++ b/ace/Event_Handler.h @@ -53,6 +53,7 @@ public: EXCEPT_MASK = 0x2, #endif /* ACE_USE_POLL */ ACCEPT_MASK = 0x8, + TIMER_MASK = 0x10, ALL_EVENTS_MASK = READ_MASK | WRITE_MASK | EXCEPT_MASK | ACCEPT_MASK, RWE_MASK = ALL_EVENTS_MASK, DONT_CALL = 0x100 diff --git a/ace/Log_Msg.cpp b/ace/Log_Msg.cpp index aba62a23ced..58fa7159698 100644 --- a/ace/Log_Msg.cpp +++ b/ace/Log_Msg.cpp @@ -521,7 +521,7 @@ ACE_Log_Msg::log (const char *format_str, else { #if defined (ACE_WIN32) - LPTSTR lpMsgBuf; + LPTSTR lpMsgBuf = 0; ::FormatMessage (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, diff --git a/ace/OS.cpp b/ace/OS.cpp index df9d2210b79..9c7db564cb1 100644 --- a/ace/OS.cpp +++ b/ace/OS.cpp @@ -2193,6 +2193,22 @@ siginfo_t::siginfo_t (ACE_HANDLE *handles) } #endif /* ACE_HAS_SIGINFO_T */ +pid_t +ACE_OS::fork (const char *program_name) +{ + // ACE_TRACE ("ACE_OS::fork"); +#if defined (ACE_WIN32) || defined (VXWORKS) + ACE_NOTSUP_RETURN (pid_t (-1)); +#else + pid_t pid = ::fork (); + + if (pid == 0) + ACE_LOG_MSG->sync (program_name); + + return pid; +#endif /* ACE_WIN32 */ +} + // This is necessary to work around nasty problems with MVS C++. extern "C" void @@ -6412,20 +6412,4 @@ ACE_OS::thr_suspend (const ACE_Thread_ID &thr_id) return ACE_OS::thr_suspend (thr_id.handle ()); } -ACE_INLINE pid_t -ACE_OS::fork (const char *program_name) -{ - // ACE_TRACE ("ACE_OS::fork"); -#if defined (ACE_WIN32) || defined (VXWORKS) - ACE_NOTSUP_RETURN (pid_t (-1)); -#else - pid_t pid = ::fork (); - - if (pid == 0) - ACE_LOG_MSG->sync (program_name); - - return pid; -#endif /* ACE_WIN32 */ -} - #endif /* 0 */ diff --git a/ace/Reactor.cpp b/ace/Reactor.cpp index f07960fedff..f598a7b1eb6 100644 --- a/ace/Reactor.cpp +++ b/ace/Reactor.cpp @@ -54,7 +54,7 @@ ACE_Reactor_Handler_Repository::handle_in_range (ACE_HANDLE handle) // Win32 due to the way that they implement SOCKET HANDLEs. if (handle != ACE_INVALID_HANDLE) #else /* !ACE_WIN32 */ - if (handle >= 0 || handle < this->max_handlep1_) + if (handle >= 0 && handle < this->max_handlep1_) #endif /* ACE_WIN32 */ return 1; else @@ -177,7 +177,7 @@ ACE_Reactor_Handler_Repository::find (ACE_HANDLE handle, // is out of range, so keep it happy by defining i here . . . i = 0; - if (eh && index_p != 0) + if (eh != 0 && index_p != 0) *index_p = i; else errno = ENOENT; @@ -1530,8 +1530,9 @@ ACE_Reactor::dispatch (int number_of_active_handles, { ACE_Sig_Handler::sig_pending (0); - // If any HANDLES are activated as a result of signals they - // should be dispatched since they may be time critical... + // If any HANDLES in the <ready_set_> are activated as a + // result of signals they should be dispatched since + // they may be time critical... number_of_active_handles = this->any_ready (dispatch_set); } else diff --git a/ace/Stream.cpp b/ace/Stream.cpp index 830d51211c9..19508414540 100644 --- a/ace/Stream.cpp +++ b/ace/Stream.cpp @@ -233,7 +233,7 @@ ACE_Stream<ACE_SYNCH_2>::push_module (ACE_Module<ACE_SYNCH_2> *new_top, } #if 0 -int +template <ACE_SYNCH_1> int ACE_Stream<ACE_SYNCH_2>::open (void *a, ACE_Multiplexor &muxer, ACE_Module<ACE_SYNCH_2> *head) diff --git a/ace/Timer_Heap.cpp b/ace/Timer_Heap.cpp index a08255d3c52..059f9f8570b 100644 --- a/ace/Timer_Heap.cpp +++ b/ace/Timer_Heap.cpp @@ -484,6 +484,9 @@ ACE_Timer_Heap::cancel (int timer_id, { ACE_Timer_Node *temp = this->remove (timer_node_slot); + // Call the close hook. + temp->handler_->handle_close (ACE_INVALID_HANDLE, + ACE_Event_Handler::TIMER_MASK); if (arg != 0) *arg = temp->arg_; @@ -509,6 +512,9 @@ ACE_Timer_Heap::cancel (ACE_Event_Handler *handler) if (this->heap_[i]->handler_ == handler) { ACE_Timer_Node *temp = this->remove (i); + // Call the close hook. + temp->handler_->handle_close (ACE_INVALID_HANDLE, + ACE_Event_Handler::TIMER_MASK); this->free_node (temp); number_of_cancellations++; } diff --git a/ace/Timer_List.cpp b/ace/Timer_List.cpp index 965b6a81a4c..48599d4e555 100644 --- a/ace/Timer_List.cpp +++ b/ace/Timer_List.cpp @@ -229,6 +229,9 @@ ACE_Timer_List::cancel (int timer_id, if (arg != 0) *arg = curr->arg_; + // Call the close hook. + curr->handler_->handle_close (ACE_INVALID_HANDLE, + ACE_Event_Handler::TIMER_MASK); this->free_node (curr); return 1; } @@ -255,6 +258,9 @@ ACE_Timer_List::cancel (ACE_Event_Handler *handler) { number_of_cancellations++; + // Call the close hook. + curr->handler_->handle_close (ACE_INVALID_HANDLE, + ACE_Event_Handler::TIMER_MASK); if (prev == 0) { this->head_ = curr->next_; diff --git a/ace/Timer_List.h b/ace/Timer_List.h index 34a47d0fd9b..379471ae2be 100644 --- a/ace/Timer_List.h +++ b/ace/Timer_List.h @@ -96,7 +96,7 @@ public: // timers. As long as timers don't stay around longer than this // there should be no problems with accidentally deleting the wrong // timer. Returns -1 on failure (which is guaranteed never to be a - // valid <timer_id>. + // valid <timer_id>). virtual int cancel (ACE_Event_Handler *event_handler); // Cancel all <event_handlers> that match the address of diff --git a/ace/Timer_Queue.h b/ace/Timer_Queue.h index 5aa61b1ed0f..b5aa653801c 100644 --- a/ace/Timer_Queue.h +++ b/ace/Timer_Queue.h @@ -102,17 +102,9 @@ class ACE_Export ACE_Timer_Queue // Provides an interface to timers. // // = DESCRIPTION - // This implementation uses a linked list of absolute times. - // Therefore, in the average case, scheduling and canceling - // <ACE_Event_Handler> timers is O(N) (where N is the total - // number of timers) and expiring timers is O(K) (where K is - // the total number of timers that are < the current time of - // day). - // - // More clever implementations could use a delta-list, a heap, - // or timing wheels, etc. For instance, <ACE_Timer_Heap> - // is a subclass of <ACE_Timer_Queue> that implements a - // heap-based callout queue. + // This is an abstract base class that provides hook for + // implementing specialized policies such as <ACE_Timer_List> + // and <ACE_Timer_Heap>. { public: // = Initialization and termination methods. @@ -145,7 +137,7 @@ public: // timers. As long as timers don't stay around longer than this // there should be no problems with accidentally deleting the wrong // timer. Returns -1 on failure (which is guaranteed never to be a - // valid <timer_id>. + // valid <timer_id>). virtual int cancel (ACE_Event_Handler *event_handler) = 0; // Cancel all <event_handlers> that match the address of diff --git a/examples/Mem_Map/IO-tests/IO_Test.cpp b/examples/Mem_Map/IO-tests/IO_Test.cpp index bed887dc2b1..aef0b12c597 100644 --- a/examples/Mem_Map/IO-tests/IO_Test.cpp +++ b/examples/Mem_Map/IO-tests/IO_Test.cpp @@ -140,8 +140,11 @@ Mmap1_Test::run_test (int iterations, FILE *input_fp, FILE *output_fp) this->tm_.start (); while (--iterations >= 0) - if (ACE_OS::write (fileno (output_fp), src, map_input.size ()) == -1) - return -1; + { + if (ACE_OS::write (fileno (output_fp), src, map_input.size ()) == -1) + return -1; + ACE_OS::lseek (fileno (output_fp), 0, SEEK_SET); + } this->tm_.stop (); } @@ -161,7 +164,7 @@ int Mmap2_Test::run_test (int iterations, FILE *input_fp, FILE *output_fp) { ACE_Mem_Map map_input (fileno (input_fp)); - int size = map_input.size (); + int size = map_input.size (); ACE_Mem_Map map_output (fileno (output_fp), size, PROT_WRITE, MAP_SHARED); void *src = 0; void *dst = 0; diff --git a/tests/Timer_Queue_Test.cpp b/tests/Timer_Queue_Test.cpp index 5509d3bb46b..09af29f23ab 100644 --- a/tests/Timer_Queue_Test.cpp +++ b/tests/Timer_Queue_Test.cpp @@ -16,7 +16,7 @@ // command line arguments are needed to run the test. // // = AUTHOR -// Prashant Jain and Douglas C. Schmidt +// Douglas C. Schmidt and Prashant Jain // // ============================================================================ @@ -34,11 +34,20 @@ static int *timer_ids = 0; class Example_Handler : public ACE_Event_Handler { public: + virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask mask) + { + ACE_ASSERT (mask == ACE_Event_Handler::TIMER_MASK); + return 0; + } + virtual int handle_timeout (const ACE_Time_Value &, const void *arg) { - ACE_ASSERT ((int) arg == 42); - return 0; + ACE_ASSERT ((int) arg == 42 || (int) arg == 007); + if ((int) arg != 42) + return -1; + else + return 0; } }; @@ -63,13 +72,13 @@ test_functionality (ACE_Timer_Queue *tq) ACE_ASSERT (tq->expire () == 2); - ACE_ASSERT (tq->schedule (&eh, (const void *) 4, ACE_OS::gettimeofday - ()) != -1); - ACE_ASSERT (tq->schedule (&eh, (const void *) 5, ACE_OS::gettimeofday - ()) != -1); + ACE_ASSERT (tq->schedule (&eh, (const void *) 4, ACE_OS::gettimeofday ()) != -1); + ACE_ASSERT (tq->schedule (&eh, (const void *) 5, ACE_OS::gettimeofday ()) != -1); ACE_ASSERT (tq->cancel (&eh) == 2); ACE_ASSERT (tq->is_empty ()); ACE_ASSERT (tq->expire () == 0); + ACE_ASSERT (tq->schedule (&eh, (const void *) 007, ACE_OS::gettimeofday ()) != -1); + ACE_ASSERT (tq->expire () == 1); } static void @@ -78,7 +87,7 @@ test_performance (ACE_Timer_Queue *tq, { Example_Handler eh; ACE_Profile_Timer timer; - int i; + size_t i; ACE_ASSERT (tq->is_empty ()); ACE_ASSERT (ACE_Time_Value::zero == ACE_Time_Value (0)); |