diff options
-rw-r--r-- | ace/Naming_Context.cpp | 2 | ||||
-rw-r--r-- | ace/Naming_Context.h | 5 | ||||
-rw-r--r-- | ace/OS.h | 12 | ||||
-rw-r--r-- | ace/Object_Manager.cpp | 2 | ||||
-rw-r--r-- | ace/Parse_Node.cpp | 12 | ||||
-rw-r--r-- | ace/Parse_Node.h | 8 | ||||
-rw-r--r-- | ace/Service_Config.cpp | 10 | ||||
-rw-r--r-- | ace/Service_Config.h | 2 | ||||
-rw-r--r-- | ace/Service_Types.cpp | 18 | ||||
-rw-r--r-- | ace/Service_Types.h | 9 | ||||
-rw-r--r-- | ace/Svc_Conf.h | 4 | ||||
-rw-r--r-- | ace/Svc_Conf.y | 11 | ||||
-rw-r--r-- | ace/Svc_Conf_y.cpp | 37 |
13 files changed, 80 insertions, 52 deletions
diff --git a/ace/Naming_Context.cpp b/ace/Naming_Context.cpp index 73ba300a94c..379cb4c5be9 100644 --- a/ace/Naming_Context.cpp +++ b/ace/Naming_Context.cpp @@ -19,7 +19,7 @@ typedef ACE_Local_Name_Space <ACE_LITE_MMAP_MEMORY_POOL, ACE_RW_Process_Mutex> // svc.conf file to dynamically initialize the state of the Name // Server client. -ACE_SVC_FACTORY_DEFINE (ACE_Naming_Context) +ACE_FACTORY_DEFINE (ACE, ACE_Naming_Context) // The ACE_Naming_Context static service object is now defined // by the ACE_Object_Manager, in Object_Manager.cpp. diff --git a/ace/Naming_Context.h b/ace/Naming_Context.h index 8ffc7e0f066..ce7afd246da 100644 --- a/ace/Naming_Context.h +++ b/ace/Naming_Context.h @@ -324,9 +324,6 @@ private: // The context in which the naming database will be created. }; -// We can't use the ACE_SVC_FACTORY_DECLARE macro here because this -// needs to be in the ACE_Export context rather than the -// ACE_Svc_Export context. -extern "C" ACE_Export ACE_Service_Object *_make_ACE_Naming_Context (void); +ACE_FACTORY_DECLARE (ACE, ACE_Naming_Context); #endif /* ACE_NAMING_CONTEXT_H */ @@ -1364,6 +1364,8 @@ private: #undef ctime #endif /* ACE_HAS_BROKEN_CTIME */ +typedef void (*ACE_Service_Object_Exterminator)(void *); + // Static service macros #define ACE_STATIC_SVC_DECLARE(X) extern ACE_Static_Svc_Descriptor ace_svc_desc_##X ; #define ACE_STATIC_SVC_DEFINE(X, NAME, TYPE, FN, FLAGS, ACTIVE) \ @@ -1377,12 +1379,16 @@ static ACE_Static_Svc_##X ace_static_svc_##X; // More generic dynamic/static service macros. -#define ACE_FACTORY_DECLARE(CLS,X) extern "C" CLS##_Export ACE_Service_Object *_make_##X (void); -#define ACE_FACTORY_DEFINE(CLS,X) extern "C" ACE_Service_Object *_make_##X () { ACE_TRACE (#X); return new X; } +#define ACE_FACTORY_DECLARE(CLS,X) extern "C" CLS##_Export ACE_Service_Object *_make_##X (ACE_Service_Object_Exterminator *); +#define ACE_FACTORY_DEFINE(CLS,X) \ +extern "C" void _gobble_##X (void *p) { delete p;} \ +extern "C" ACE_Service_Object *_make_##X (ACE_Service_Object_Exterminator *gobbler) \ +{ ACE_TRACE (#X); \ +if (gobbler != 0) *gobbler = _gobble_##X; return new X; } // Dynamic/static service macros. #define ACE_SVC_FACTORY_DECLARE(X) ACE_FACTORY_DECLARE (ACE_Svc, X) -#define ACE_SVC_INVOKE(X) _make_##X () +#define ACE_SVC_INVOKE(X) _make_##X (0) #define ACE_SVC_NAME(X) _make_##X #define ACE_SVC_FACTORY_DEFINE(X) ACE_FACTORY_DEFINE (ACE_Svc, X) diff --git a/ace/Object_Manager.cpp b/ace/Object_Manager.cpp index 3b288ba9af3..7485b205f9f 100644 --- a/ace/Object_Manager.cpp +++ b/ace/Object_Manager.cpp @@ -113,7 +113,7 @@ ACE_Object_Manager_Preallocations *ace_object_manager_preallocations = 0; // We can't use the ACE_SVC_FACTORY_DECLARE macro here because this // needs to be in the ACE_Export context rather than the // ACE_Svc_Export context. -extern "C" ACE_Export ACE_Service_Object *_make_ACE_Service_Manager (void); +extern "C" ACE_Export ACE_Service_Object *_make_ACE_Service_Manager (ACE_Service_Object_Exterminator *); ACE_Object_Manager_Preallocations::ACE_Object_Manager_Preallocations () { diff --git a/ace/Parse_Node.cpp b/ace/Parse_Node.cpp index 841f13da081..03fd2d685be 100644 --- a/ace/Parse_Node.cpp +++ b/ace/Parse_Node.cpp @@ -423,7 +423,7 @@ ACE_Object_Node::ACE_Object_Node (const char *path, } void * -ACE_Object_Node::symbol (void) +ACE_Object_Node::symbol (ACE_Service_Object_Exterminator *) { ACE_TRACE ("ACE_Object_Node::symbol"); if (this->open_handle () != 0) @@ -483,12 +483,12 @@ ACE_Function_Node::ACE_Function_Node (const char *path, } void * -ACE_Function_Node::symbol (void) +ACE_Function_Node::symbol (ACE_Service_Object_Exterminator *gobbler) { ACE_TRACE ("ACE_Function_Node::symbol"); if (this->open_handle () != 0) { - void *(*func) (void) = 0; + void *(*func) (ACE_Service_Object_Exterminator *) = 0; this->symbol_ = 0; // Locate the factory function <function_name> in the shared @@ -497,7 +497,7 @@ ACE_Function_Node::symbol (void) ASYS_TCHAR *wname = ACE_const_cast (ASYS_TCHAR *, ASYS_WIDE_STRING (this->function_name_)); - func = (void *(*)(void)) + func = (void *(*)(ACE_Service_Object_Exterminator *)) ACE_OS::dlsym ((ACE_SHLIB_HANDLE) this->handle (), wname); @@ -527,7 +527,7 @@ ACE_Function_Node::symbol (void) } } // Invoke the factory function and record it's return value. - this->symbol_ = (*func) (); + this->symbol_ = (*func) (gobbler); if (this->symbol_ == 0) { @@ -596,7 +596,7 @@ ACE_Static_Function_Node::ACE_Static_Function_Node (const char *func_name) } void * -ACE_Static_Function_Node::symbol (void) +ACE_Static_Function_Node::symbol (ACE_Service_Object_Exterminator *) { ACE_TRACE ("ACE_Static_Function_Node::symbol"); diff --git a/ace/Parse_Node.h b/ace/Parse_Node.h index 8f7ca0491bd..cd1cf422240 100644 --- a/ace/Parse_Node.h +++ b/ace/Parse_Node.h @@ -168,7 +168,7 @@ class ACE_Export ACE_Location_Node // Keep track of where a shared library is located. public: ACE_Location_Node (void); - virtual void *symbol (void) = 0; + virtual void *symbol (ACE_Service_Object_Exterminator * = 0) = 0; virtual void set_symbol (void *h); ACE_SHLIB_HANDLE handle (void) const; void handle (const ACE_SHLIB_HANDLE h); @@ -206,7 +206,7 @@ class ACE_Export ACE_Object_Node : public ACE_Location_Node // Keeps track of the symbol name for a shared object. public: ACE_Object_Node (const char *pathname, const char *obj_name); - virtual void *symbol (void); + virtual void *symbol (ACE_Service_Object_Exterminator * = 0); virtual ~ACE_Object_Node (void); void dump (void) const; @@ -226,7 +226,7 @@ class ACE_Export ACE_Function_Node : public ACE_Location_Node // Keeps track of the symbol name of for a shared function. public: ACE_Function_Node (const char *pathname, const char *func_name); - virtual void *symbol (void); + virtual void *symbol (ACE_Service_Object_Exterminator *gobbler = 0); virtual ~ACE_Function_Node (void); void dump (void) const; @@ -269,7 +269,7 @@ class ACE_Export ACE_Static_Function_Node : public ACE_Location_Node // application. public: ACE_Static_Function_Node (const char *func_name); - virtual void *symbol (void); + virtual void *symbol (ACE_Service_Object_Exterminator * = 0); virtual ~ACE_Static_Function_Node (void); void dump (void) const; diff --git a/ace/Service_Config.cpp b/ace/Service_Config.cpp index 9e7aee972ae..c7667b271f9 100644 --- a/ace/Service_Config.cpp +++ b/ace/Service_Config.cpp @@ -35,7 +35,7 @@ ACE_Service_Config::dump (void) const // Allocate a Service Manager. -ACE_SVC_FACTORY_DEFINE (ACE_Service_Manager) +ACE_FACTORY_DEFINE (ACE, ACE_Service_Manager) // ---------------------------------------- @@ -351,11 +351,15 @@ ACE_Service_Config::load_static_svcs (void) { ACE_Static_Svc_Descriptor *ssd = *ssdp; + ACE_Service_Object_Exterminator gobbler; + void *sym = (*ssd->alloc_)(&gobbler); + ACE_Service_Type_Impl *stp = ace_create_service_type (ssd->name_, ssd->type_, - (*ssd->alloc_)(), - ssd->flags_); + sym, + ssd->flags_, + gobbler); if (stp == 0) continue; diff --git a/ace/Service_Config.h b/ace/Service_Config.h index 3cd1222727b..cbc9c362619 100644 --- a/ace/Service_Config.h +++ b/ace/Service_Config.h @@ -30,7 +30,7 @@ class ACE_Thread_Manager; extern "C" { - typedef ACE_Service_Object *(*ACE_SERVICE_ALLOCATOR) (void); + typedef ACE_Service_Object *(*ACE_SERVICE_ALLOCATOR) (ACE_Service_Object_Exterminator *); } struct ACE_Static_Svc_Descriptor diff --git a/ace/Service_Types.cpp b/ace/Service_Types.cpp index 7d634bdba02..c77f5e7c119 100644 --- a/ace/Service_Types.cpp +++ b/ace/Service_Types.cpp @@ -24,10 +24,12 @@ ACE_Service_Type_Impl::dump (void) const ACE_Service_Type_Impl::ACE_Service_Type_Impl (void *so, const ASYS_TCHAR *s_name, - u_int f) + u_int f, + void (*gobbler)(void*)) : name_ (0), obj_ (so), - flags_ (f) + flags_ (f), + gobbler_ (gobbler) { ACE_TRACE ("ACE_Service_Type_Impl::ACE_Service_Type_Impl"); this->name (s_name); @@ -54,7 +56,12 @@ ACE_Service_Type_Impl::fini (void) const #if 1 if (ACE_BIT_ENABLED (this->flags_, ACE_Service_Type::DELETE_OBJ)) - operator delete ((void *) this->object ()); // cast to remove const-ness + { + if (gobbler_ != 0) + gobbler_ (this->object ()); + else + operator delete ((void *) this->object ()); // cast to remove const-ness + } #endif /* 0 */ if (ACE_BIT_ENABLED (this->flags_, ACE_Service_Type::DELETE_THIS)) @@ -65,8 +72,9 @@ ACE_Service_Type_Impl::fini (void) const ACE_Service_Object_Type::ACE_Service_Object_Type (void *so, const ASYS_TCHAR *s_name, - u_int f) - : ACE_Service_Type_Impl (so, s_name, f) + u_int f, + void (*gobbler)(void *)) + : ACE_Service_Type_Impl (so, s_name, f, gobbler) { ACE_TRACE ("ACE_Service_Object_Type::ACE_Service_Object_Type"); } diff --git a/ace/Service_Types.h b/ace/Service_Types.h index 34bd9dc2737..d6724062e63 100644 --- a/ace/Service_Types.h +++ b/ace/Service_Types.h @@ -37,7 +37,8 @@ public: // = Initialization and termination methods. ACE_Service_Type_Impl (void *object, const ASYS_TCHAR *s_name, - u_int flags = 0); + u_int flags = 0, + ACE_Service_Object_Exterminator gobbler = 0); virtual ~ACE_Service_Type_Impl (void); // = Pure virtual interface (must be defined by the subclass). @@ -70,6 +71,9 @@ protected: // Pointer to object that implements the service. This actually // points to an <ACE_Service_Object>, <ACE_Module>, or <ACE_Stream>. + ACE_Service_Object_Exterminator gobbler_; + // Destroy function to deallocate obj_. + u_int flags_; // Flags that control serivce behavior (particularly deletion). }; @@ -83,7 +87,8 @@ public: // = Initialization method. ACE_Service_Object_Type (void *so, const ASYS_TCHAR *name, - u_int flags = 0); + u_int flags = 0, + ACE_Service_Object_Exterminator gobbler = 0); // = Implement the hooks for <ACE_Service_Objects>. virtual int suspend (void) const; diff --git a/ace/Svc_Conf.h b/ace/Svc_Conf.h index ab711cf451d..08e3c9fa143 100644 --- a/ace/Svc_Conf.h +++ b/ace/Svc_Conf.h @@ -63,7 +63,9 @@ extern int ace_yyleng; extern ACE_Obstack *ace_obstack; // Efficient memory allocation technique -ACE_Service_Type_Impl *ace_create_service_type (const ASYS_TCHAR *, int, void *, unsigned int); +ACE_Service_Type_Impl *ace_create_service_type (const ASYS_TCHAR *, int, + void *, unsigned int, + ACE_Service_Object_Exterminator = 0); // Factory that creates a new ACE_Service_Type_Impl. typedef union diff --git a/ace/Svc_Conf.y b/ace/Svc_Conf.y index 1979ca959c4..e4fc9bcb441 100644 --- a/ace/Svc_Conf.y +++ b/ace/Svc_Conf.y @@ -198,12 +198,13 @@ svc_location u_int flags = ACE_Service_Type::DELETE_THIS | ($3->dispose () == 0 ? 0 : ACE_Service_Type::DELETE_OBJ); - void *sym = $3->symbol (); + ACE_Service_Object_Exterminator gobbler; + void *sym = $3->symbol (&gobbler); if (sym != 0) { ACE_Service_Type_Impl *stp - = ace_create_service_type (ASYS_WIDE_STRING ($1), $2, sym, flags); + = ace_create_service_type (ASYS_WIDE_STRING ($1), $2, sym, flags, gobbler); $$ = new ACE_Service_Type (ASYS_WIDE_STRING ($1), stp, $3->handle (), $4); } else @@ -343,7 +344,8 @@ ACE_Service_Type_Impl * ace_create_service_type (const ASYS_TCHAR *name, int type, void *symbol, - u_int flags) + u_int flags, + ACE_Service_Object_Exterminator gobbler = 0) { ACE_Service_Type_Impl *stp = 0; @@ -356,7 +358,8 @@ ace_create_service_type (const ASYS_TCHAR *name, case ACE_SVC_OBJ_T: ACE_NEW_RETURN (stp, ACE_Service_Object_Type ((ACE_Service_Object *) symbol, - ASYS_WIDE_STRING (name), flags), + ASYS_WIDE_STRING (name), flags, + gobbler), 0); break; case ACE_MODULE_T: diff --git a/ace/Svc_Conf_y.cpp b/ace/Svc_Conf_y.cpp index f7b95330435..71c7e9518cc 100644 --- a/ace/Svc_Conf_y.cpp +++ b/ace/Svc_Conf_y.cpp @@ -244,7 +244,7 @@ YYSTYPE ace_yylval; #define ace_yystacksize YYSTACKSIZE short ace_yyss[YYSTACKSIZE]; YYSTYPE ace_yyvs[YYSTACKSIZE]; -#line 274 "Svc_Conf.y" +#line 275 "Svc_Conf.y" // Prints the error string to standard output. Cleans up the error // messages. @@ -317,7 +317,8 @@ ACE_Service_Type_Impl * ace_create_service_type (const ASYS_TCHAR *name, int type, void *symbol, - u_int flags) + u_int flags, + ACE_Service_Object_Exterminator gobbler) { ACE_Service_Type_Impl *stp = 0; @@ -330,7 +331,8 @@ ace_create_service_type (const ASYS_TCHAR *name, case ACE_SVC_OBJ_T: ACE_NEW_RETURN (stp, ACE_Service_Object_Type ((ACE_Service_Object *) symbol, - ASYS_WIDE_STRING (name), flags), + ASYS_WIDE_STRING (name), flags, + gobbler), 0); break; case ACE_MODULE_T: @@ -373,7 +375,7 @@ main (int argc, char *argv[]) return ace_yyparse (); } #endif /* DEBUGGING */ -#line 377 "Svc_Conf_y.cpp" +#line 379 "Svc_Conf_y.cpp" #define YYABORT goto ace_yyabort #define YYACCEPT goto ace_yyaccept #define YYERROR goto ace_yyerrlab @@ -848,12 +850,13 @@ case 30: u_int flags = ACE_Service_Type::DELETE_THIS | (ace_yyvsp[-1].location_node_->dispose () == 0 ? 0 : ACE_Service_Type::DELETE_OBJ); - void *sym = ace_yyvsp[-1].location_node_->symbol (); + ACE_Service_Object_Exterminator gobbler; + void *sym = ace_yyvsp[-1].location_node_->symbol (&gobbler); if (sym != 0) { ACE_Service_Type_Impl *stp - = ace_create_service_type (ASYS_WIDE_STRING (ace_yyvsp[-3].ident_), ace_yyvsp[-2].type_, sym, flags); + = ace_create_service_type (ASYS_WIDE_STRING (ace_yyvsp[-3].ident_), ace_yyvsp[-2].type_, sym, flags, gobbler); ace_yyval.svc_record_ = new ACE_Service_Type (ASYS_WIDE_STRING (ace_yyvsp[-3].ident_), stp, ace_yyvsp[-1].location_node_->handle (), ace_yyvsp[0].type_); } else @@ -865,64 +868,64 @@ case 30: } break; case 31: -#line 220 "Svc_Conf.y" +#line 221 "Svc_Conf.y" { ace_yyval.type_ = 1; } break; case 32: -#line 224 "Svc_Conf.y" +#line 225 "Svc_Conf.y" { ace_yyval.type_ = 0; } break; case 33: -#line 228 "Svc_Conf.y" +#line 229 "Svc_Conf.y" { ace_yyval.type_ = 1; } break; case 34: -#line 235 "Svc_Conf.y" +#line 236 "Svc_Conf.y" { ace_yyval.location_node_ = new ACE_Object_Node (ace_yyvsp[-2].ident_, ace_yyvsp[0].ident_); } break; case 35: -#line 239 "Svc_Conf.y" +#line 240 "Svc_Conf.y" { ace_yyval.location_node_ = new ACE_Function_Node (ace_yyvsp[-4].ident_, ace_yyvsp[-2].ident_); } break; case 36: -#line 243 "Svc_Conf.y" +#line 244 "Svc_Conf.y" { ace_yyval.location_node_ = new ACE_Static_Function_Node (ace_yyvsp[-2].ident_); } break; case 37: -#line 250 "Svc_Conf.y" +#line 251 "Svc_Conf.y" { ace_yyval.type_ = ACE_MODULE_T; } break; case 38: -#line 254 "Svc_Conf.y" +#line 255 "Svc_Conf.y" { ace_yyval.type_ = ACE_SVC_OBJ_T; } break; case 39: -#line 258 "Svc_Conf.y" +#line 259 "Svc_Conf.y" { ace_yyval.type_ = ACE_STREAM_T; } break; case 41: -#line 265 "Svc_Conf.y" +#line 266 "Svc_Conf.y" { ace_yyval.ident_ = 0; } break; -#line 925 "Svc_Conf_y.cpp" +#line 928 "Svc_Conf_y.cpp" } ace_yyssp -= ace_yym; ace_yystate = *ace_yyssp; |