diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1996-12-17 16:35:06 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1996-12-17 16:35:06 +0000 |
commit | 0d7a4c90918697451fc1cd7ebb39102aa162b0f5 (patch) | |
tree | f8543faeadf492ba2fec99ef62e289382d9f97ea /ace | |
parent | ff8c24a33730abc4e8703aab66a17c3d333541af (diff) | |
download | ATCD-0d7a4c90918697451fc1cd7ebb39102aa162b0f5.tar.gz |
foo
Diffstat (limited to 'ace')
-rw-r--r-- | ace/Local_Name_Space_T.cpp | 4 | ||||
-rw-r--r-- | ace/Memory_Pool.cpp | 2 | ||||
-rw-r--r-- | ace/OS.cpp | 9 | ||||
-rw-r--r-- | ace/OS.h | 3 | ||||
-rw-r--r-- | ace/OS.i | 26 | ||||
-rw-r--r-- | ace/ReactorEx.cpp | 105 | ||||
-rw-r--r-- | ace/ReactorEx.h | 53 | ||||
-rw-r--r-- | ace/Task.cpp | 2 | ||||
-rw-r--r-- | ace/Task_T.i | 5 |
9 files changed, 134 insertions, 75 deletions
diff --git a/ace/Local_Name_Space_T.cpp b/ace/Local_Name_Space_T.cpp index d89cf054b81..0f6c66f651b 100644 --- a/ace/Local_Name_Space_T.cpp +++ b/ace/Local_Name_Space_T.cpp @@ -378,8 +378,7 @@ ACE_Local_Name_Space<ACE_MEM_POOL_2, LOCK>::create_manager_i (void) ACE_OS::strcat (this->context_file_, ACE_DIRECTORY_SEPARATOR_STR); ACE_OS::strcat (this->context_file_, this->name_options_->database ()); - ACE_DEBUG ((LM_DEBUG, "contextfile is %s\n", - this->context_file_)); + // ACE_DEBUG ((LM_DEBUG, "contextfile is %s\n", this->context_file_)); ACE_MEM_POOL_OPTIONS options (this->name_options_->base_address ()); @@ -437,7 +436,6 @@ ACE_Local_Name_Space<ACE_MEM_POOL_2, LOCK>::create_manager_i (void) return 0; } - template <ACE_MEM_POOL_1, class LOCK> int ACE_Local_Name_Space<ACE_MEM_POOL_2, LOCK>::list_names (ACE_PWSTRING_SET &set, const ACE_WString &pattern) diff --git a/ace/Memory_Pool.cpp b/ace/Memory_Pool.cpp index 5f671db8c75..22acf5d3809 100644 --- a/ace/Memory_Pool.cpp +++ b/ace/Memory_Pool.cpp @@ -128,8 +128,10 @@ ACE_MMAP_Memory_Pool::ACE_MMAP_Memory_Pool (LPCTSTR backing_store_name, ACE_OS::strncpy (this->backing_store_name_, backing_store_name, sizeof this->backing_store_name_); +#if !defined (ACE_WIN32) if (this->signal_handler_.register_handler (SIGSEGV, this) == -1) ACE_ERROR ((LM_ERROR, "%p\n", this->backing_store_name_)); +#endif /* ACE_WIN32 */ } // Compute the new file_offset of the backing store and commit the diff --git a/ace/OS.cpp b/ace/OS.cpp index e0b395e66a1..f79760c1762 100644 --- a/ace/OS.cpp +++ b/ace/OS.cpp @@ -1443,7 +1443,14 @@ spa (FUNCPTR entry, ...) #if !defined (ACE_HAS_SIGINFO_T) siginfo_t::siginfo_t (ACE_HANDLE handle) - : si_handle_ (handle) + : si_handle_ (handle), + si_handles_ (&handle) +{ +} + +siginfo_t::siginfo_t (ACE_HANDLE *handles) + : si_handle_ (handles[0]), + si_handles_ (handles) { } #endif /* ACE_HAS_SIGINFO_T */ @@ -1827,6 +1827,9 @@ struct ACE_Export siginfo_t ACE_HANDLE si_handle_; // Win32 HANDLE that has become signaled. + + ACE_HANDLE *si_handles_; + // Array of Win32 HANDLEs all of which have become signaled. }; #endif /* ACE_HAS_SIGINFO_T */ @@ -666,8 +666,8 @@ ACE_OS::unlink (const char *path) #endif /* VXWORKS */ } -ACE_INLINE char * -ACE_OS::cuserid (char *user, size_t maxlen) +ACE_INLINE LPTSTR +ACE_OS::cuserid (LPTSTR user, size_t maxlen) { // ACE_TRACE ("ACE_OS::cuserid"); #if defined (VXWORKS) @@ -2675,8 +2675,10 @@ ACE_OS::inet_aton (const char *host_name, struct in_addr *addr) && ACE_OS::strcmp (host_name, "255.255.255.255") != 0) return 0; else if (addr != 0) - ACE_OS::memcpy ((void *) addr, (void *) &ip_addr, sizeof ip_addr); - return 1; + { + ACE_OS::memcpy ((void *) addr, (void *) &ip_addr, sizeof ip_addr); + return 1; + } } ACE_INLINE char * @@ -4195,7 +4197,7 @@ ACE_OS::hostname (char name[], size_t maxnamelen) { // ACE_TRACE ("ACE_OS::uname"); #if defined (ACE_WIN32) - ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::GetComputerName (name, LPDWORD (&maxnamelen)), + ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::GetComputerNameA (name, LPDWORD (&maxnamelen)), ace_result_), int, -1); #else /* !ACE_WIN32 */ struct utsname host_info; @@ -4353,7 +4355,7 @@ ACE_OS::dlopen (ACE_DL_TYPE filename, int mode) #elif defined (ACE_WIN32) ACE_UNUSED_ARG(mode); - ACE_OSCALL_RETURN (::LoadLibrary (filename), void *, 0); + ACE_OSCALL_RETURN (::LoadLibraryA (filename), void *, 0); #else ACE_NOTSUP_RETURN (0); #endif /* ACE_HAS_SVR4_DYNAMIC_LINKING */ @@ -4860,7 +4862,7 @@ ACE_OS::shmget (key_t key, int size, int flags) } ACE_INLINE ACE_HANDLE -ACE_OS::open (LPCTSTR filename, +ACE_OS::open (const char *filename, int mode, int perms) { @@ -4890,11 +4892,11 @@ ACE_OS::open (LPCTSTR filename, if (ACE_BIT_ENABLED (mode, _O_TEMPORARY)) flags |= FILE_FLAG_DELETE_ON_CLOSE; - ACE_HANDLE h = ::CreateFile (filename, access, - FILE_SHARE_READ | FILE_SHARE_WRITE, - 0, creation, - flags, - 0); + ACE_HANDLE h = ::CreateFileA (filename, access, + FILE_SHARE_READ | FILE_SHARE_WRITE, + 0, creation, + flags, + 0); if (h == ACE_INVALID_HANDLE) { diff --git a/ace/ReactorEx.cpp b/ace/ReactorEx.cpp index 9801021e9a9..fb2969f69d2 100644 --- a/ace/ReactorEx.cpp +++ b/ace/ReactorEx.cpp @@ -123,7 +123,8 @@ ACE_ReactorEx::schedule_timer (ACE_Event_Handler *handler, // how_long expired, and 1 if events were dispatched. int ACE_ReactorEx::handle_events (ACE_Time_Value *how_long, - int wait_all) + int wait_all, + ACE_Event_Handler *wait_all_callback) { ACE_TRACE ("ACE_ReactorEx::handle_events"); @@ -169,61 +170,87 @@ ACE_ReactorEx::handle_events (ACE_Time_Value *how_long, errno = ETIME; return 0; case WAIT_ABANDONED_0: - // We'll let dispatch_all worry about abandoned mutexes. + // We'll let dispatch worry about abandoned mutexes. default: // Dispatch. - return this->dispatch_all (wait_status - WAIT_OBJECT_0, wait_all); + if (wait_all != 0) + return this->dispatch (wait_all_callback); + else + return this->dispatch (wait_status - WAIT_OBJECT_0); + } +} + +int +ACE_ReactorEx::dispatch (ACE_Event_Handler *wait_all_callback) +{ + if (wait_all_callback != 0) + { + siginfo_t handles (this->handles_); + if (wait_call_callback->handle_signal (0, &handles) == -1) + // Tim, what should happen if this call fails? Should all of + // the handles be removed? + return -1; + } + else + { + int result = 0; + + for (int i = 0; i < this->active_handles_; i++) + if (this->dispatch_handler (i) == -1) + result = -1; + + // Tim, if a result is != 0 should it contain a single -1, or + // perhaps the number of bad handler dispatches (negated, of + // course!). + return result; } } // Dispatches any active handles from handles_[-index-] to // handles_[active_handles_] using WaitForMultipleObjects to poll // through our handle set looking for active handles. + int -ACE_ReactorEx::dispatch_all (size_t index, int wait_all) +ACE_ReactorEx::dispatch (size_t index) { - while (1) + while (index < active_handles_) { - if (this->dispatch_handler (index) == 0) - index++; - - // Check if we're all out of handles. - if (index == active_handles_) - return 0; - - // If wait_all is TRUE, then we know that every handle is active - // and there's no need to call WaitForMultipleObjects; We just - // iterate through and dispatch each handler. - if (wait_all == 0) + // Tim, if this call fails is there really anything we + // can/should do about it? It seems that regardless of the + // success or failure, we should increment the index since + // otherwise we might just iterate endlessly! + this->dispatch_handler (index); + index++; + + DWORD wait_status = + ::WaitForMultipleObjects (active_handles_ - index, + &handles_[index], + FALSE, 0); // We're polling. + + switch (wait_status) { - DWORD wait_status = - ::WaitForMultipleObjects (active_handles_ - index, - &(handles_[index]), - FALSE, 0); // We're polling. - - switch (wait_status) - { - case WAIT_FAILED: // Failure. - errno = ::GetLastError (); - return -1; - case WAIT_TIMEOUT: - // There are no more handles ready, we can return. - return 0; - default: // Dispatch. - // Check if a handle successfully became signaled. - if ((wait_status >= WAIT_OBJECT_0) && - (wait_status < WAIT_OBJECT_0 + active_handles_)) - index += (wait_status - WAIT_OBJECT_0); - else - // Otherwise, a handle was abandoned. - index += (wait_status - WAIT_ABANDONED_0); - } + case WAIT_FAILED: // Failure. + errno = ::GetLastError (); + return -1; + case WAIT_TIMEOUT: + // There are no more handles ready, we can return. + return 0; + default: // Dispatch. + // Check if a handle successfully became signaled. + if (wait_status >= WAIT_OBJECT_0 && + wait_status < WAIT_OBJECT_0 + active_handles_) + index += wait_status - WAIT_OBJECT_0; + else + // Otherwise, a handle was abandoned. + index += waitstatus - WAIT_ABANDONED_0; } } -} + return 0; +} // Dispatches a single handler. Returns 0 on success, -1 if the // handler was removed. + int ACE_ReactorEx::dispatch_handler (int index) { diff --git a/ace/ReactorEx.h b/ace/ReactorEx.h index e51f9edfac3..6c4ec881b8a 100644 --- a/ace/ReactorEx.h +++ b/ace/ReactorEx.h @@ -130,25 +130,30 @@ public: virtual ~ACE_ReactorEx (void); // Close down the ReactorEx and release all of its resources. - // = Event loop drivers. - // Main event loop driver that blocks for -how_long- before - // returning (will return earlier if I/O or signal events occur). - // Note that -how_long- can be 0, in which case this method blocks - // until I/O events or signals occur. Returns 0 if timed out, 1 if - // an event occurred, and -1 if an error occured. -how_long- is - // decremented to reflect how much time the call to handle_events - // took. For instance, if a time value of 3 seconds is passed to - // handle_events and an event occurs after 2 seconds, -how_long- - // will equal 1 second. This can be used if an application wishes - // to handle events for some fixed amount of time. If wait_all is - // TRUE, then handle_events will only dispatch the handlers if *all* - // handles become active. If a timeout occurs, then no handlers - // will be dispatched. + // = Event loop drivers. Main event loop driver that blocks for + // -how_long- before returning (will return earlier if I/O or signal + // events occur). Note that -how_long- can be 0, in which case this + // method blocks until I/O events or signals occur. Returns 0 if + // timed out, 1 if an event occurred, and -1 if an error occured. + // -how_long- is decremented to reflect how much time the call to + // handle_events took. For instance, if a time value of 3 seconds + // is passed to handle_events and an event occurs after 2 seconds, + // -how_long- will equal 1 second. This can be used if an + // application wishes to handle events for some fixed amount of + // time. If wait_all is TRUE, then handle_events will only dispatch + // the handlers if *all* handles become active. If a timeout + // occurs, then no handlers will be dispatched. If + // <wait_all_callback> is NULL then we dispatch the <handle_signal> + // method on each and every HANDLE in the dispatch array. + // Otherwise, we just call back the <handle_signal> method of the + // <wait_all_callback> object, after first assigning the siginfo_t + // <si_handles_> argument to point to the array of signaled handles. virtual int handle_events (ACE_Time_Value *how_long = 0, - int wait_all = 0); + int wait_all = 0, + ACE_Event_Handler *wait_all_callback = 0); virtual int handle_events (ACE_Time_Value &how_long, - int wait_all = 0); - + int wait_all = 0, + ACE_Event_Handler *wait_all_callback = 0); // = Register and remove Handlers. virtual int register_handler (ACE_Event_Handler *eh, @@ -204,11 +209,21 @@ public: // Declare the dynamic allocation hooks. protected: - int dispatch_all (size_t index, int wait_all); + int dispatch (size_t index); // Dispatches any active handles from handles_[-index-] to - // handles_[active_handles_] using WaitForMultipleObjects to poll + // handles_[active_handles_] using <WaitForMultipleObjects> to poll // through our handle set looking for active handles. + int dispatch (ACE_Event_Handler *wait_all_callback); + // This is called when the user called handle_events() with the + // <wait_all> parameter enabled. In this case, all the handlers are + // now signaled. If <wait_all_callback> is NULL then we dispatch + // the <handle_signal> method on each and every HANDLE in the + // dispatch array. Otherwise, we just call back the <handle_signal> + // method of the <wait_all_callback> object, after first assigning + // the siginfo_t <si_handles_> argument to point to the array of + // signaled handles. + int dispatch_handler (int index); // Dispatches a single handler. Returns 0 on success, -1 if the // handler was removed. diff --git a/ace/Task.cpp b/ace/Task.cpp index 8152f66fe9d..3046b40a9c3 100644 --- a/ace/Task.cpp +++ b/ace/Task.cpp @@ -175,7 +175,7 @@ ACE_Task_Base::activate (long flags, if (this->thr_count_ > 0 && force_active == 0) return 1; // Already active. else - this->thr_count_ = n_threads; + this->thr_count_ += n_threads; // Use the ACE_Thread_Manager singleton if we're running as an // active object and the caller didn't supply us with a diff --git a/ace/Task_T.i b/ace/Task_T.i index 9f5ba06054e..1a8837f24a3 100644 --- a/ace/Task_T.i +++ b/ace/Task_T.i @@ -57,6 +57,11 @@ template <ACE_SYNCH_1> ACE_INLINE void ACE_Task<ACE_SYNCH_2>::msg_queue (ACE_Message_Queue<ACE_SYNCH_2> *mq) { ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::msg_queue"); + if (this->delete_msg_queue_) + { + delete this->msg_queue_; + this->delete_msg_queue_ = 0; + } this->msg_queue_ = mq; } |