19082N/A--- libbonobo-2.24.1/activation-server/object-directory-corba.c.ori 2009-03-16 05:39:49.839582342 +0000
19082N/A+++ libbonobo-2.24.1/activation-server/object-directory-corba.c 2009-03-16 05:50:28.624389842 +0000
19082N/A@@ -590,6 +590,16 @@
19082N/A finished_internal_registration = TRUE;
19082N/A }
19082N/A
19082N/A+static gboolean
19082N/A+check_quit_timeout (gpointer user_data)
19082N/A+{
19082N/A+#ifdef BONOBO_ACTIVATION_DEBUG
19082N/A+ fprintf(stderr, "Called check_quit_timeout\n");
19082N/A+#endif
19082N/A+ check_quit ();
19082N/A+ return FALSE;
19082N/A+}
19082N/A+
19082N/A void
19082N/A check_quit (void)
19082N/A {
19082N/A@@ -600,10 +610,21 @@
19082N/A g_source_remove (od->no_servers_timeout);
19082N/A od->no_servers_timeout = 0;
19082N/A
19082N/A- if (od->n_active_servers <= RESIDUAL_SERVERS &&
19082N/A- activation_clients_is_empty_scan ())
19082N/A- od->no_servers_timeout = g_timeout_add_seconds (
19082N/A+ if (od->n_active_servers <= RESIDUAL_SERVERS) {
19082N/A+ if (activation_clients_is_empty_scan ()) {
19082N/A+ od->no_servers_timeout = g_timeout_add_seconds (
19082N/A SERVER_IDLE_QUIT_TIMEOUT, quit_server_timeout, NULL);
19082N/A+ } else {
19082N/A+ /*
19082N/A+ * We expect that activation_clients_is_empty_scan will
19082N/A+ * return FALSE. If it does now we try again in a second
19082N/A+ * in case clients have died in the meantime.
19082N/A+ */
19082N/A+
19082N/A+ od->no_servers_timeout = g_timeout_add_seconds (
19082N/A+ SERVER_IDLE_QUIT_TIMEOUT, check_quit_timeout, NULL);
19082N/A+ }
19082N/A+ }
19082N/A
19082N/A od->time_active_changed = time (NULL);
19082N/A }
19082N/A@@ -671,8 +692,9 @@
19082N/A dead = (status == ORBIT_CONNECTION_DISCONNECTED);
19082N/A
19082N/A #ifdef BONOBO_ACTIVATION_DEBUG
19082N/A- fprintf (stderr, "IID '%20s' (%p), %s \n",
19082N/A+ fprintf (stderr, "IID '%20s' (%p %p), %s \n",
19082N/A (char *) key, servers->servers [i].server,
19082N/A+ ORBit_small_get_connection(servers->servers[i].server),
19082N/A dead ? "dead" : "alive");
19082N/A #endif
19082N/A if (dead) {
19082N/A@@ -692,6 +714,7 @@
19082N/A ObjectDirectory *od;
19082N/A static gboolean in_rescan = FALSE;
19082N/A static guint idle_id = 0;
19082N/A+ guint n_active_servers;
19082N/A
19082N/A server_lock ();
19082N/A
19082N/A@@ -709,15 +732,30 @@
19082N/A idle_id = g_timeout_add (100, as_rescan, GUINT_TO_POINTER (1));
19082N/A server_unlock ();
19082N/A return FALSE;
19082N/A+ } else {
19082N/A+ idle_id = 0;
19082N/A }
19082N/A in_rescan = TRUE;
19082N/A
19082N/A+ n_active_servers = od->n_active_servers;
19082N/A g_hash_table_foreach_remove (od->active_server_lists,
19082N/A prune_dead_servers, od);
19082N/A #ifdef BONOBO_ACTIVATION_DEBUG
19082N/A g_warning ("After prune: %d live servers",
19082N/A od->n_active_servers - RESIDUAL_SERVERS);
19082N/A #endif
19082N/A+ /*
19082N/A+ * If we still have have live servers and the pruning did not reduce
19082N/A+ * the number of active servers try again in a second in case the
19082N/A+ * servers are slow to go away.
19082N/A+ */
19082N/A+ if (n_active_servers == od->n_active_servers &&
19082N/A+ (od->n_active_servers - RESIDUAL_SERVERS) > 0) {
19082N/A+ if (!idle_id) {
19082N/A+ idle_id = g_timeout_add_seconds (SERVER_IDLE_QUIT_TIMEOUT,
19082N/A+ as_rescan, NULL);
19082N/A+ }
19082N/A+ }
19082N/A
19082N/A check_quit ();
19082N/A
19082N/A@@ -732,6 +770,9 @@
gpointer dummy)
{
+#ifdef BONOBO_ACTIVATION_DEBUG
+ fprintf(stderr, "active_server_cnx_broken for %p\n", cnx);
+#endif
as_rescan (NULL);
}