3
#include <orbit/orbit.h>
5
#include "orbit-debug.h"
6
#include "orb-core-private.h"
8
static glong alive_root_objects = 0;
9
static glong total_refs = 0;
13
static GHashTable *object_hash = NULL;
15
#define TYPE_CASE(e,n) \
16
case ORBIT_ROT_##e: str = g_strdup (n); break;
19
object_hash_dump (gpointer key,
24
ORBit_RootObject obj = key;
25
const ORBit_RootObject_Interface *interface = obj->interface;
27
switch (interface->type) {
28
TYPE_CASE (NULL, "Null");
29
case ORBIT_ROT_OBJREF: {
30
CORBA_Object o = (CORBA_Object) obj;
31
str = g_strdup_printf ("Object (type '%s')",
32
g_quark_to_string (o->type_qid));
36
TYPE_CASE (ORB, "ORB");
37
TYPE_CASE (ADAPTOR, "Adaptor");
38
TYPE_CASE (POLICY, "Policy");
39
TYPE_CASE (TYPECODE, "TypeCode");
40
TYPE_CASE (REQUEST, "Request");
41
TYPE_CASE (SERVERREQUEST, "Server Request");
42
TYPE_CASE (CONTEXT, "Context");
43
TYPE_CASE (DYNANY, "Dynany");
44
TYPE_CASE (OAOBJECT, "Object Adaptor Object");
45
TYPE_CASE (ORBGROUP, "ORB Group");
46
TYPE_CASE (POAMANAGER, "POA Manager");
47
TYPE_CASE (POACURRENT, "Current POA");
51
str = g_strdup_printf ("Error unknown type '%d'",
54
fprintf (stderr, "%3d ref%c to '%s'\n",
55
obj->refs, obj->refs ? 's' : ' ', str);
62
ORBit_RootObject_shutdown (void)
64
int valid_running = 1; /* The ORB */
66
if (!ORBit_RootObject_lifecycle_lock &&
67
alive_root_objects - valid_running)
68
g_warning ("ORB: a total of %ld refs to %ld ORB "
69
"objects were leaked",
70
total_refs - valid_running,
71
alive_root_objects - valid_running);
72
else if (total_refs - valid_running)
73
g_warning ("ORB: a total of %ld refs to ORB "
74
"objects were leaked",
75
total_refs - valid_running);
80
if (_orbit_debug_flags & ORBIT_DEBUG_REFS)
81
g_hash_table_foreach (
82
object_hash, object_hash_dump, NULL);
90
ORBit_RootObject_init (ORBit_RootObject obj,
91
const ORBit_RootObject_Interface *interface)
93
if (!ORBit_RootObject_lifecycle_lock) /* No locking */
98
object_hash = g_hash_table_new (NULL, NULL);
100
if (_orbit_debug_flags & ORBIT_DEBUG_REFS)
101
g_hash_table_insert (object_hash, obj, obj);
104
obj->interface = interface;
109
ORBit_RootObject_duplicate (gpointer obj)
111
ORBit_RootObject robj = obj;
113
if (robj && robj->refs != ORBIT_REFCOUNT_STATIC) {
114
LINC_MUTEX_LOCK (ORBit_RootObject_lifecycle_lock);
117
LINC_MUTEX_UNLOCK (ORBit_RootObject_lifecycle_lock);
124
ORBit_RootObject_duplicate_T (gpointer obj)
126
ORBit_RootObject robj = obj;
128
if (robj && robj->refs != ORBIT_REFCOUNT_STATIC) {
137
do_unref (ORBit_RootObject robj)
139
g_assert (robj->refs < ORBIT_REFCOUNT_MAX && robj->refs > 0);
144
if (robj->refs == 0) {
145
if (!ORBit_RootObject_lifecycle_lock) /* No locking */
146
alive_root_objects--;
147
#ifdef G_ENABLE_DEBUG
148
if (_orbit_debug_flags & ORBIT_DEBUG_REFS)
149
g_hash_table_remove (object_hash, robj);
152
if (robj->interface && robj->interface->destroy)
153
robj->interface->destroy (robj);
160
ORBit_RootObject_release_T (gpointer obj)
162
ORBit_RootObject robj = obj;
164
if (robj && robj->refs != ORBIT_REFCOUNT_STATIC)
169
ORBit_RootObject_release (gpointer obj)
171
ORBit_RootObject robj = obj;
173
if (robj && robj->refs != ORBIT_REFCOUNT_STATIC) {
175
LINC_MUTEX_LOCK (ORBit_RootObject_lifecycle_lock);
179
LINC_MUTEX_UNLOCK (ORBit_RootObject_lifecycle_lock);