diff options
Diffstat (limited to 'ace')
-rw-r--r-- | ace/Mem_Map.cpp | 10 | ||||
-rw-r--r-- | ace/Object_Manager.cpp | 2 | ||||
-rw-r--r-- | ace/Service_Object.cpp | 9 | ||||
-rw-r--r-- | ace/Service_Types.cpp | 17 | ||||
-rw-r--r-- | ace/Service_Types.h | 11 | ||||
-rw-r--r-- | ace/Signal.h | 16 | ||||
-rw-r--r-- | ace/Signal.i | 19 | ||||
-rw-r--r-- | ace/Strategies_T.cpp | 8 | ||||
-rw-r--r-- | ace/Svc_Conf.y | 15 | ||||
-rw-r--r-- | ace/Svc_Conf_y.cpp | 77 | ||||
-rw-r--r-- | ace/Timer_Queue_T.cpp | 28 | ||||
-rw-r--r-- | ace/Timer_Queue_T.h | 18 |
12 files changed, 136 insertions, 94 deletions
diff --git a/ace/Mem_Map.cpp b/ace/Mem_Map.cpp index b2b11ac203b..db77c013710 100644 --- a/ace/Mem_Map.cpp +++ b/ace/Mem_Map.cpp @@ -34,13 +34,11 @@ ACE_Mem_Map::close (void) this->unmap (); - if (this->file_mapping_ != this->handle_ - && this->file_mapping_ != ACE_INVALID_HANDLE) - ACE_OS::close (this->file_mapping_); - if (this->close_handle_) - return ACE_OS::close (this->handle_); - + { + this->close_handle_ = 0; + return ACE_OS::close (this->handle_); + } return 0; } diff --git a/ace/Object_Manager.cpp b/ace/Object_Manager.cpp index 6b57002667d..6011dd84352 100644 --- a/ace/Object_Manager.cpp +++ b/ace/Object_Manager.cpp @@ -4,7 +4,7 @@ #include "ace/Object_Manager.h" #include "ace/Containers.h" -#include "ace/Service_Repository.h" +#include "ace/Service_Config.h" #include "ace/Log_Msg.h" #include "ace/Synch.h" diff --git a/ace/Service_Object.cpp b/ace/Service_Object.cpp index 324158145e9..7484cbf5813 100644 --- a/ace/Service_Object.cpp +++ b/ace/Service_Object.cpp @@ -3,15 +3,14 @@ // Service_Object.cpp #define ACE_BUILD_DLL -#include "ace/Service_Object.h" #include "ace/Service_Types.h" +#include "ace/Service_Object.h" #if !defined (__ACE_INLINE__) #include "ace/Service_Object.i" #endif /* __ACE_INLINE__ */ ACE_ALLOC_HOOK_DEFINE(ACE_Service_Object) - ACE_ALLOC_HOOK_DEFINE(ACE_Service_Type) void @@ -21,9 +20,9 @@ ACE_Service_Type::dump (void) const } ACE_Service_Type::ACE_Service_Type (const char *n, - ACE_Service_Type_Impl *t, - const ACE_SHLIB_HANDLE h, - int active) + ACE_Service_Type_Impl *t, + const ACE_SHLIB_HANDLE h, + int active) : name_ (0), type_ (t), handle_ (h), diff --git a/ace/Service_Types.cpp b/ace/Service_Types.cpp index 4b8c0719734..04b7b380592 100644 --- a/ace/Service_Types.cpp +++ b/ace/Service_Types.cpp @@ -4,6 +4,11 @@ #define ACE_BUILD_DLL #include "ace/Service_Types.h" #include "ace/Stream_Modules.h" +#include "ace/Stream.h" + +typedef ACE_Stream<ACE_SYNCH> MT_Stream; +typedef ACE_Module<ACE_SYNCH> MT_Module; +typedef ACE_Task<ACE_SYNCH> MT_Task; #if !defined (__ACE_INLINE__) #include "ace/Service_Types.i" @@ -56,10 +61,10 @@ ACE_Service_Type_Impl::fini (void) const return 0; } -ACE_Service_Object_Type::ACE_Service_Object_Type (ACE_Service_Object *so, +ACE_Service_Object_Type::ACE_Service_Object_Type (const void *so, const char *s_name, unsigned int f) - : ACE_Service_Type_Impl ((const void *) so, s_name, f) + : ACE_Service_Type_Impl (so, s_name, f) { ACE_TRACE ("ACE_Service_Object_Type::ACE_Service_Object_Type"); } @@ -85,10 +90,10 @@ ACE_Module_Type::dump (void) const ACE_TRACE ("ACE_Module_Type::dump"); } -ACE_Module_Type::ACE_Module_Type (MT_Module *m, +ACE_Module_Type::ACE_Module_Type (const void *m, const char *m_name, u_int f) - : ACE_Service_Type_Impl ((const void *) m, m_name, f) + : ACE_Service_Type_Impl (m, m_name, f) { ACE_TRACE ("ACE_Module_Type::ACE_Module_Type"); } @@ -229,10 +234,10 @@ ACE_Stream_Type::resume (void) const return 0; } -ACE_Stream_Type::ACE_Stream_Type (MT_Stream *s, +ACE_Stream_Type::ACE_Stream_Type (const void *s, const char *s_name, unsigned int f) - : ACE_Service_Type_Impl ((const void *) s, s_name, f), + : ACE_Service_Type_Impl (s, s_name, f), head_ (0) { ACE_TRACE ("ACE_Stream_Type::ACE_Stream_Type"); diff --git a/ace/Service_Types.h b/ace/Service_Types.h index 501c4e010c8..2b5255d0687 100644 --- a/ace/Service_Types.h +++ b/ace/Service_Types.h @@ -19,11 +19,6 @@ #include "ace/Service_Object.h" #include "ace/Synch.h" -#include "ace/Stream.h" - -typedef ACE_Stream<ACE_SYNCH> MT_Stream; -typedef ACE_Module<ACE_SYNCH> MT_Module; -typedef ACE_Task<ACE_SYNCH> MT_Task; class ACE_Export ACE_Service_Type_Impl // = TITLE @@ -86,7 +81,7 @@ class ACE_Export ACE_Service_Object_Type : public ACE_Service_Type_Impl { public: // = Initialization method. - ACE_Service_Object_Type (ACE_Service_Object *so, + ACE_Service_Object_Type (const void *so, const char *name, u_int flags = 0); @@ -105,7 +100,7 @@ class ACE_Export ACE_Module_Type : public ACE_Service_Type_Impl { public: // = Initialization method. - ACE_Module_Type (MT_Module *m, + ACE_Module_Type (const void *m, // Really an <ACE_Module> *. const char *identifier, u_int flags = 0); @@ -138,7 +133,7 @@ class ACE_Export ACE_Stream_Type : public ACE_Service_Type_Impl { public: // = Initialization method. - ACE_Stream_Type (MT_Stream *s, + ACE_Stream_Type (const void *s, // Really an <ACE_Stream> *. const char *identifier, u_int flags = 0); diff --git a/ace/Signal.h b/ace/Signal.h index 7c851869eea..30d9add0700 100644 --- a/ace/Signal.h +++ b/ace/Signal.h @@ -34,8 +34,17 @@ class ACE_Export ACE_Sig_Set { public: // = Initialization and termination methods. - ACE_Sig_Set (sigset_t *); + ACE_Sig_Set (sigset_t *sigset); + // Initialize <sigset_> with <sigset>. If <sigset> == 0 then fill + // the set. + + ACE_Sig_Set (ACE_Sig_Set *sigset); + // Initialize <sigset_> with <sigset>. If <sigset> == 0 then fill + // the set. + ACE_Sig_Set (int fill = 0); + // If <fill> == 0 then initialize the <sigset_> empty, else full. + ~ACE_Sig_Set (void); int empty_set (void); @@ -141,9 +150,12 @@ class ACE_Export ACE_Sig_Guard // Note that a "0" for mask causes all signals to be held. { public: - // = Set/remove mask. + // = Initialization and termination methods. ACE_Sig_Guard (ACE_Sig_Set *mask = 0); + // Block out signals in <mask>. Default is to block all signals! + ~ACE_Sig_Guard (void); + // Restore blocked signals. void dump (void) const; // Dump the state of an object. diff --git a/ace/Signal.i b/ace/Signal.i index b14818db0ff..1cb775cce87 100644 --- a/ace/Signal.i +++ b/ace/Signal.i @@ -5,15 +5,21 @@ ACE_INLINE ACE_Sig_Set::ACE_Sig_Set (sigset_t *ss) - : sigset_ (*ss) // Structure assignment { ACE_TRACE ("ACE_Sig_Set::ACE_Sig_Set"); + + if (ss == 0) + ACE_OS::sigfillset (&this->sigset_); + else + // Structure assignment. + this->sigset_ = *ss; } ACE_INLINE ACE_Sig_Set::ACE_Sig_Set (int fill) { ACE_TRACE ("ACE_Sig_Set::ACE_Sig_Set"); + if (fill) ACE_OS::sigfillset (&this->sigset_); else @@ -21,6 +27,17 @@ ACE_Sig_Set::ACE_Sig_Set (int fill) } ACE_INLINE +ACE_Sig_Set::ACE_Sig_Set (ACE_Sig_Set *ss) +{ + ACE_TRACE ("ACE_Sig_Set::ACE_Sig_Set"); + + if (ss == 0) + ACE_OS::sigfillset (&this->sigset_); + else + this->sigset_ = ss->sigset_; +} + +ACE_INLINE ACE_Sig_Set::~ACE_Sig_Set (void) { ACE_TRACE ("ACE_Sig_Set::~ACE_Sig_Set"); diff --git a/ace/Strategies_T.cpp b/ace/Strategies_T.cpp index ccca4fb1266..963813cef7a 100644 --- a/ace/Strategies_T.cpp +++ b/ace/Strategies_T.cpp @@ -150,12 +150,14 @@ template <class SVC_HANDLER> int ACE_DLL_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&sh) { ACE_TRACE ("ACE_DLL_Strategy<SVC_HANDLER>::make_svc_handler"); + // Open the shared library. ACE_SHLIB_HANDLE handle = ACE_OS::dlopen (this->shared_library_); // Extract the factory function. - SVC_HANDLER *(*factory)(void) = (SVC_HANDLER *(*)(void)) ACE_OS::dlsym - (handle, this->factory_function_); + SVC_HANDLER *(*factory)(void) = + (SVC_HANDLER *(*)(void)) ACE_OS::dlsym (handle, + this->factory_function_); // Call the factory function to obtain the new SVC_Handler (should // use RTTI here when it becomes available...) @@ -168,7 +170,7 @@ ACE_DLL_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&sh) // Create an ACE_Service_Type containing the SVC_Handler and // insert into this->svc_rep_; - ACE_Service_Type_Impl stp = + ACE_Service_Type_Impl *stp = new ACE_Service_Object_Type (svc_handler, this->svc_name_); if (stp == 0) diff --git a/ace/Svc_Conf.y b/ace/Svc_Conf.y index d29021c2274..ad457e8bc50 100644 --- a/ace/Svc_Conf.y +++ b/ace/Svc_Conf.y @@ -184,7 +184,8 @@ svc_location : ACE_IDENT type svc_initializer status { u_int flags - = ACE_Service_Type_Impl::DELETE_THIS | ($3->dispose () == 0 ? 0 : ACE_Service_Type_Impl::DELETE_OBJ); + = ACE_Service_Type::DELETE_THIS + | ($3->dispose () == 0 ? 0 : ACE_Service_Type::DELETE_OBJ); const void *sym = $3->symbol (); if (sym != 0) @@ -317,13 +318,19 @@ ace_create_service_type (const char *name, switch (type) { case ACE_SVC_OBJ_T: - stp = new ACE_Service_Object_Type ((ACE_Service_Object *) symbol, name, flags); + ACE_NEW_RETURN (stp, + ACE_Service_Object_Type ((ACE_Service_Object *) symbol, name, flags), + 0); break; case ACE_MODULE_T: - stp = new ACE_Module_Type ((MT_Module *) symbol, name, flags); + ACE_NEW_RETURN (stp, + ACE_Module_Type (symbol, name, flags), + 0); break; case ACE_STREAM_T: - stp = new ACE_Stream_Type ((MT_Stream *) symbol, name, flags); + ACE_NEW_RETURN (stp, + ACE_Stream_Type (symbol, name, flags), + 0); break; default: ACE_ERROR ((LM_ERROR, "unknown case\n")); diff --git a/ace/Svc_Conf_y.cpp b/ace/Svc_Conf_y.cpp index bd4fb9e9370..91ad9e54d93 100644 --- a/ace/Svc_Conf_y.cpp +++ b/ace/Svc_Conf_y.cpp @@ -1,5 +1,3 @@ -// $Id$ - #ifndef lint char ace_yysccsid[] = "@(#)yaccpar 1.4 (Berkeley) 02/25/90 \n\ Modified 5/2/90 by J. Roskind to support graphic debugging modes"; @@ -241,7 +239,7 @@ YYSTYPE ace_yylval; #define ace_yystacksize YYSTACKSIZE short ace_yyss[YYSTACKSIZE]; YYSTYPE ace_yyvs[YYSTACKSIZE]; -#line 264 "Svc_Conf.y" +#line 257 "Svc_Conf.y" // Prints the error string to standard output. Cleans up the error // messages. @@ -306,13 +304,19 @@ ace_create_service_type (const char *name, switch (type) { case ACE_SVC_OBJ_T: - stp = new ACE_Service_Object_Type ((ACE_Service_Object *) symbol, name, flags); + ACE_NEW_RETURN (stp, + ACE_Service_Object_Type ((ACE_Service_Object *) symbol, name, flags), + 0); break; case ACE_MODULE_T: - stp = new ACE_Module_Type ((MT_Module *) symbol, name, flags); + ACE_NEW_RETURN (stp, + ACE_Module_Type (symbol, name, flags), + 0); break; case ACE_STREAM_T: - stp = new ACE_Stream_Type ((MT_Stream *) symbol, name, flags); + ACE_NEW_RETURN (stp, + ACE_Stream_Type (symbol, name, flags), + 0); break; default: ACE_ERROR ((LM_ERROR, "unknown case\n")); @@ -344,7 +348,7 @@ main (int argc, char *argv[]) return ace_yyparse (); } #endif /* DEBUGGING */ -#line 346 "Svc_Conf_y.cpp" +#line 352 "Svc_Conf_y.cpp" #define YYABORT goto ace_yyabort #define YYACCEPT goto ace_yyaccept #define YYERROR goto ace_yyerrlab @@ -372,7 +376,7 @@ int ace_yyindent; #endif /* YYDEBUG_INDENT */ #ifndef YYDEBUG_REDUCE #ifdef __cplusplus -void YYDEBUG_REDUCE(int /* ace_yynew_state */, int /* ace_yyrule_num */, char *ace_yyrule_string, int ace_yynew_indent, int ace_yyrhs_count) +void YYDEBUG_REDUCE(int ace_yynew_state, int ace_yyrule_num, char *ace_yyrule_string, int ace_yynew_indent, int ace_yyrhs_count) #else YYDEBUG_REDUCE(ace_yynew_state, ace_yyrule_num, ace_yyrule_string, ace_yynew_indent, ace_yyrhs_count) int ace_yynew_state; @@ -402,7 +406,7 @@ int ace_yyrhs_count; #endif /* YYDEBUG_REDUCE */ #ifndef YYDEBUG_SHIFT_LEXEME #ifdef __cplusplus -void YYDEBUG_SHIFT_LEXEME(int /* ace_yyold_state */, int /* ace_yynew_state */, char *ace_yytoken_string, int ace_yynew_indent) +void YYDEBUG_SHIFT_LEXEME(int ace_yyold_state, int ace_yynew_state, char *ace_yytoken_string, int ace_yynew_indent) #else YYDEBUG_SHIFT_LEXEME(ace_yyold_state, ace_yynew_state, ace_yytoken_string, ace_yynew_indent) int ace_yyold_state; @@ -417,7 +421,7 @@ int ace_yynew_indent; #endif /* YYDEBUG_SHIFT_LEXEME */ #ifndef YYDEBUG_LOOK_AHEAD #ifdef __cplusplus -void YYDEBUG_LOOK_AHEAD(int /* ace_yynew_state */, int ace_yytoken_num, char *ace_yytoken_string, int ace_yyindent) +void YYDEBUG_LOOK_AHEAD(int ace_yynew_state, int ace_yytoken_num, char *ace_yytoken_string, int ace_yyindent) #else YYDEBUG_LOOK_AHEAD(ace_yynew_state, ace_yytoken_num, ace_yytoken_string, ace_yyindent) int ace_yynew_state; @@ -434,7 +438,7 @@ int ace_yyindent; #endif /* YYDEBUG_LOOK_AHEAD */ #ifndef YYDEBUG_DISCARD_STATE #ifdef __cplusplus -void YYDEBUG_DISCARD_STATE(int /* ace_yynew_state */, int ace_yyindent) +void YYDEBUG_DISCARD_STATE(int ace_yynew_state, int ace_yyindent) #else YYDEBUG_DISCARD_STATE(ace_yynew_state, ace_yyindent) int ace_yynew_state; @@ -462,7 +466,7 @@ int ace_yyindent; #endif /* YYDEBUG_DISCARD_STATE */ #ifndef YYDEBUG_DISCARD_TOKEN #ifdef __cplusplus -void YYDEBUG_DISCARD_TOKEN(int /* ace_yynew_state */, int /* ace_yytoken_num */, char *ace_yytoken_string, int ace_yyindent) +void YYDEBUG_DISCARD_TOKEN(int ace_yynew_state, int ace_yytoken_num, char *ace_yytoken_string, int ace_yyindent) #else YYDEBUG_DISCARD_TOKEN(ace_yynew_state, ace_yytoken_num, ace_yytoken_string, ace_yyindent) int ace_yynew_state; @@ -477,7 +481,7 @@ int ace_yyindent; #endif /* YYDEBUG_DISCARD_TOKEN */ #ifndef YYDEBUG_SHIFT_ERROR_LEXEME #ifdef __cplusplus -void YYDEBUG_SHIFT_ERROR_LEXEME(int /* ace_yyold_state */, int /* ace_yynew_state */, int ace_yyindent) +void YYDEBUG_SHIFT_ERROR_LEXEME(int ace_yyold_state, int ace_yynew_state, int ace_yyindent) #else YYDEBUG_SHIFT_ERROR_LEXEME(ace_yyold_state, ace_yynew_state, ace_yyindent) int ace_yyold_state; @@ -503,7 +507,7 @@ ace_yyparse() extern char *ace_foo(); #endif - if ((ace_yys = ACE_OS::getenv("YYDEBUG"))) + if (ace_yys = ACE_OS::getenv("YYDEBUG")) { ace_yyn = *ace_yys; if (ace_yyn >= '0' && ace_yyn <= '9') @@ -520,7 +524,7 @@ ace_yyparse() *ace_yyssp = ace_yystate = 0; ace_yyloop: - if ((ace_yyn = ace_yydefred[ace_yystate])) goto ace_yyreduce; + if (ace_yyn = ace_yydefred[ace_yystate]) goto ace_yyreduce; if (ace_yychar < 0) { if ((ace_yychar = ace_yylex()) < 0) ace_yychar = 0; @@ -756,11 +760,6 @@ case 25: ACE_ARGV args (ace_yyvsp[0].static_node_->parameters ()); ACE_Module_Type *mt = get_module (ace_yyvsp[-2].static_node_, ace_yyvsp[0].static_node_); - if (::strcmp (ace_yyvsp[0].static_node_->name (), - ((MT_Module *) mt->object ())->name ()) != 0) - ACE_ERROR ((LM_ERROR, "warning, service name %s is different from Module name %s\n", - ace_yyvsp[0].static_node_->name (), ((MT_Module *) mt->object ())->name ())); - if (mt->init (args.argc (), args.argv ()) == -1 || ((ACE_Stream_Type *) (ace_yyvsp[-2].static_node_)->record ()->type ())->push (mt) == -1) { @@ -771,19 +770,16 @@ case 25: } break; case 26: -#line 157 "Svc_Conf.y" +#line 152 "Svc_Conf.y" { ACE_Module_Type *mt = get_module (ace_yyvsp[-2].static_node_, ace_yyvsp[0].static_node_->name ()); - if (::strcmp (ace_yyvsp[0].static_node_->name (), - ((MT_Module *) mt->object ())->name ()) != 0) - ACE_ERROR ((LM_ERROR, "warning, service name %s is different from Module name %s\n", - ace_yyvsp[0].static_node_->name (), ((MT_Module *) mt->object ())->name ())); + if (((ACE_Stream_Type *) (ace_yyvsp[-2].static_node_)->record ()->type ())->push (mt) == -1) ace_yyerrno++; } break; case 27: -#line 167 "Svc_Conf.y" +#line 159 "Svc_Conf.y" { ACE_Module_Type *mt = get_module (ace_yyvsp[-2].static_node_, ace_yyvsp[0].static_node_->name ()); if (mt != 0) @@ -791,7 +787,7 @@ case 27: } break; case 28: -#line 173 "Svc_Conf.y" +#line 165 "Svc_Conf.y" { ACE_Module_Type *mt = get_module (ace_yyvsp[-2].static_node_, ace_yyvsp[0].static_node_->name ()); if (mt != 0) @@ -799,7 +795,7 @@ case 28: } break; case 29: -#line 179 "Svc_Conf.y" +#line 171 "Svc_Conf.y" { ACE_Module_Type *mt = get_module (ace_yyvsp[-2].static_node_, ace_yyvsp[0].static_node_->name ()); if (mt != 0 @@ -812,10 +808,11 @@ case 29: } break; case 30: -#line 193 "Svc_Conf.y" +#line 185 "Svc_Conf.y" { u_int flags - = ACE_Service_Type::DELETE_THIS | (ace_yyvsp[-1].location_node_->dispose () == 0 ? 0 : ACE_Service_Type::DELETE_OBJ); + = ACE_Service_Type::DELETE_THIS + | (ace_yyvsp[-1].location_node_->dispose () == 0 ? 0 : ACE_Service_Type::DELETE_OBJ); const void *sym = ace_yyvsp[-1].location_node_->symbol (); if (sym != 0) @@ -832,58 +829,58 @@ case 30: } break; case 31: -#line 214 "Svc_Conf.y" +#line 207 "Svc_Conf.y" { ace_yyval.type_ = 1; } break; case 32: -#line 218 "Svc_Conf.y" +#line 211 "Svc_Conf.y" { ace_yyval.type_ = 0; } break; case 33: -#line 222 "Svc_Conf.y" +#line 215 "Svc_Conf.y" { ace_yyval.type_ = 1; } break; case 34: -#line 229 "Svc_Conf.y" +#line 222 "Svc_Conf.y" { ace_yyval.location_node_ = new ACE_Object_Node (ace_yyvsp[-2].ident_, ace_yyvsp[0].ident_); } break; case 35: -#line 233 "Svc_Conf.y" +#line 226 "Svc_Conf.y" { ace_yyval.location_node_ = new ACE_Function_Node (ace_yyvsp[-4].ident_, ace_yyvsp[-2].ident_); } break; case 36: -#line 240 "Svc_Conf.y" +#line 233 "Svc_Conf.y" { ace_yyval.type_ = ACE_MODULE_T; } break; case 37: -#line 244 "Svc_Conf.y" +#line 237 "Svc_Conf.y" { ace_yyval.type_ = ACE_SVC_OBJ_T; } break; case 38: -#line 248 "Svc_Conf.y" +#line 241 "Svc_Conf.y" { ace_yyval.type_ = ACE_STREAM_T; } break; case 40: -#line 255 "Svc_Conf.y" +#line 248 "Svc_Conf.y" { ace_yyval.ident_ = 0; } break; -#line 884 "Svc_Conf_y.cpp" +#line 883 "Svc_Conf_y.cpp" } ace_yyssp -= ace_yym; ace_yystate = *ace_yyssp; diff --git a/ace/Timer_Queue_T.cpp b/ace/Timer_Queue_T.cpp index 039222edb2c..1c5e3babf02 100644 --- a/ace/Timer_Queue_T.cpp +++ b/ace/Timer_Queue_T.cpp @@ -290,8 +290,8 @@ template <class TQ> int ACE_Async_Timer_Queue_Adapter<TQ>::cancel (long timer_id, const void **act) { - // Block all signals. - ACE_Sig_Guard sg; + // Block designated signals. + ACE_Sig_Guard sg (&this->mask_); ACE_UNUSED_ARG (sg); return this->timer_queue_.cancel (timer_id, act); @@ -299,15 +299,15 @@ ACE_Async_Timer_Queue_Adapter<TQ>::cancel (long timer_id, template <class TQ> long ACE_Async_Timer_Queue_Adapter<TQ>::schedule (ACE_Event_Handler *eh, - const void *act, - const ACE_Time_Value &delay, - const ACE_Time_Value &interval) + const void *act, + const ACE_Time_Value &delay, + const ACE_Time_Value &interval) { ACE_UNUSED_ARG (act); ACE_UNUSED_ARG (interval); - // Block all signals. - ACE_Sig_Guard sg; + // Block designated signals. + ACE_Sig_Guard sg (&this->mask_); ACE_UNUSED_ARG (sg); long tid = this->timer_queue_.schedule (eh, 0, delay); @@ -327,23 +327,25 @@ ACE_Async_Timer_Queue_Adapter<TQ>::schedule (ACE_Event_Handler *eh, if (tv < ACE_Time_Value::zero) tv = ACE_Time_Value (0, 1); + // @@ This code should be clever enough to avoid updating the + // ualarm() if we haven't actually changed the earliest time. // Schedule a new timer. ACE_OS::ualarm (tv); return 0; } template <class TQ> -ACE_Async_Timer_Queue_Adapter<TQ>::ACE_Async_Timer_Queue_Adapter (void) +ACE_Async_Timer_Queue_Adapter<TQ>::ACE_Async_Timer_Queue_Adapter (ACE_Sig_Set *mask) + // If <mask> == 0, block *all* signals when the SIGARLM handler is + // running, else just block those in the mask. + : mask_ (mask) { // The following code is necessary to selectively "block" all // signals when SIGALRM is running. Also, we always restart system // calls that are interrupted by the signals. - // Block *all* signals when the SIGARLM handler is running! - ACE_Sig_Set ss (1); - ACE_Sig_Action sa ((ACE_SignalHandler) 0, - ss, + this->mask_, SA_RESTART); if (this->sig_handler_.register_handler (SIGALRM, this, &sa) == -1) @@ -376,6 +378,8 @@ ACE_Async_Timer_Queue_Adapter<TQ>::handle_signal (int signum, expired_timers)); // Only schedule a new timer if there is one in the list. + // @@ This code should also become smarter to avoid + // unnecessary calls to ualarm(). if (this->timer_queue_.is_empty () == 0) ACE_OS::ualarm (this->timer_queue_.earliest_time () - ACE_OS::gettimeofday ()); diff --git a/ace/Timer_Queue_T.h b/ace/Timer_Queue_T.h index 4b2b4321cd7..132e44cb020 100644 --- a/ace/Timer_Queue_T.h +++ b/ace/Timer_Queue_T.h @@ -363,8 +363,10 @@ class ACE_Async_Timer_Queue_Adapter : public ACE_Event_Handler public: typedef TQ TIMER_QUEUE; - ACE_Async_Timer_Queue_Adapter (void); - // Register the SIGALRM handler. + ACE_Async_Timer_Queue_Adapter (ACE_Sig_Set *mask = 0); + // Register the SIGALRM handler. If <mask> == 0 then block all + // signals when <SIGALRM> is run. Otherwise, just block the signals + // indicated in <mask>. long schedule (ACE_Event_Handler *type, const void *act, @@ -374,23 +376,27 @@ public: // <ACE_Timer_List>. However, this timer gets dispatched via a // signal, rather than by a user calling <expire>. - int cancel (long timer_id, const void **); - // Cancel the <timer_id>. + int cancel (long timer_id, const void **act = 0); + // Cancel the <timer_id> and pass back the <act> if an address is + // passed in. TQ &timer_queue (void); // Access the underlying <TIMER_QUEUE>. private: virtual int handle_signal (int signum, siginfo_t *, ucontext_t *); - // Called back by SIGALRM handler. + // Called back by <SIGALRM> handler. ACE_Sig_Handler sig_handler_; - // Handler for the SIGALRM signal, so that we can access our state + // Handler for the <SIGALRM> signal, so that we can access our state // without requiring global variables. TQ timer_queue_; // Implementation of the timer queue (e.g., <ACE_Timer_List>, // <ACE_Timer_Heap>, etc.). + + ACE_Sig_Set mask_; + // Mask of signals to be blocked when we're servicing <SIGALRM>. }; #if defined (__ACE_INLINE__) |