g_idle killer ...
- From: Michael Meeks <michael helixcode com>
- To: Maciej Stachowiak <mjs eazel com>,Elliot Lee <sopwith redhat com>
- Cc: gnome-components-list gnome org
- Subject: g_idle killer ...
- Date: Mon, 17 Jul 2000 20:23:40 -0400 (EDT)
Hi there,
The attached patch adds a g_idle handler ( I feel this is
preferable to a timeout ) that kills the process if it has failed to
register the correct IID after a few idle loops. This can of course race
and cause grief; hence there is a function to turn this off before it
begins, however I feel it is a lot better than what was there.
Ok; it also adds a test case which is nice, and here is the
crunch; run the test program and see you get the nice message and the
correct exception back, _but_ then oafd goes and chews 99% of your CPU
which melts to a pile of slag.
Quite why this should happen I havn't diagnosed; it is outside my
immediate realm of expertiese. I imagine it is sitting polling file
descriptors from applied guesstimation...
Regards,
Michael.
--
mmeeks@gnu.org <><, Pseudo Engineer, itinerant idiot
? a.out
? mjs
? b.out
? test/oaf-slay
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/oaf/ChangeLog,v
retrieving revision 1.41
diff -u -r1.41 ChangeLog
--- ChangeLog 2000/07/15 11:42:16 1.41
+++ ChangeLog 2000/07/18 00:19:49
@@ -1,3 +1,22 @@
+2000-07-18 Michael Meeks <michael@helixcode.com>
+
+ * oafd/main.c (main): fix some brokenness.
+
+2000-07-17 Michael Meeks <michael@helixcode.com>
+
+ * test/broken.oafinfo: add NotInServer entry.
+
+ * test/oaf-test-client.c (TOTAL_TEST_SCORE): +=2
+ (main): add test for non-registering server.
+
+ * liboaf/oaf-servreg.c (oaf_active_server_register): make
+ need_printout module global, rename to need_ior_printout.
+ (oaf_idle_reg_check): implement catch for norberts.
+ (oaf_idle_reg_check_set): allow turning it off.
+
+ * liboaf/oaf-mainloop.c (oaf_postinit): hook in the check function
+ if appropriate, be a bit defensive.
+
2000-07-14 Michael Meeks <michael@helixcode.com>
* liboaf/oaf-servreg.c (oaf_active_server_register): add debug for
Index: liboaf/liboaf-private.h
===================================================================
RCS file: /cvs/gnome/oaf/liboaf/liboaf-private.h,v
retrieving revision 1.8
diff -u -r1.8 liboaf-private.h
--- liboaf/liboaf-private.h 2000/07/09 17:54:59 1.8
+++ liboaf/liboaf-private.h 2000/07/18 00:19:49
@@ -15,11 +15,12 @@
#endif
#endif
-
-CORBA_Object oaf_server_by_forking (const char **cmd, int fd_Arg,
- CORBA_Environment * ev);
-void oaf_rloc_file_register (void);
-int oaf_ior_fd_get (void);
+void oaf_idle_reg_check_set (gboolean on);
+gboolean oaf_idle_reg_check (gpointer data);
+CORBA_Object oaf_server_by_forking (const char **cmd, int fd_Arg,
+ CORBA_Environment * ev);
+void oaf_rloc_file_register (void);
+int oaf_ior_fd_get (void);
CORBA_Object oaf_activation_context_get (void);
extern gboolean oaf_private;
Index: liboaf/oaf-mainloop.c
===================================================================
RCS file: /cvs/gnome/oaf/liboaf/oaf-mainloop.c,v
retrieving revision 1.19
diff -u -r1.19 oaf-mainloop.c
--- liboaf/oaf-mainloop.c 2000/07/09 17:54:59 1.19
+++ liboaf/oaf-mainloop.c 2000/07/18 00:19:49
@@ -293,6 +293,11 @@
if (oaf_od_ior)
oaf_registration_location_add (&cmdline_regloc, -1000, NULL);
+ if (oaf_activate_iid)
+ g_idle_add (oaf_idle_reg_check, NULL);
+ else
+ oaf_idle_reg_check_set (FALSE);
+
is_initialized = TRUE;
}
Index: liboaf/oaf-servreg.c
===================================================================
RCS file: /cvs/gnome/oaf/liboaf/oaf-servreg.c,v
retrieving revision 1.7
diff -u -r1.7 oaf-servreg.c
--- liboaf/oaf-servreg.c 2000/07/15 11:42:17 1.7
+++ liboaf/oaf-servreg.c 2000/07/18 00:19:50
@@ -4,6 +4,36 @@
#include "liboaf/liboaf-private.h"
#include <stdio.h>
+static gboolean check_registration = TRUE;
+static gboolean need_ior_printout = TRUE;
+
+void
+oaf_idle_reg_check_set (gboolean on)
+{
+ check_registration = on;
+}
+
+gboolean
+oaf_idle_reg_check (gpointer data)
+{
+ static int delay = 5;
+
+ if (!check_registration)
+ return FALSE;
+
+ if (!--delay) {
+ if (need_ior_printout) {
+ g_error ("This process has not registered the required OafIID\n"
+ "your source code should register '%s'. If your code is\n"
+ "performing delayed registration and this message is trapped "
+ "in error, see oaf_idle_reg_check_set.",
+ oaf_activation_iid_get ());
+ }
+ }
+
+ return delay != 0;
+}
+
OAF_RegistrationResult
oaf_active_server_register (const char *iid, CORBA_Object obj)
{
@@ -13,18 +43,17 @@
CORBA_Environment ev;
OAF_RegistrationResult retval;
const char *actid;
- static gboolean need_printout = TRUE;
CORBA_exception_init (&ev);
actid = oaf_activation_iid_get ();
- if (actid && !strcmp (actid, iid) && need_printout) {
+ if (actid && !strcmp (actid, iid) && need_ior_printout) {
char *iorstr;
FILE *fh;
int iorfd = oaf_ior_fd_get ();
- need_printout = FALSE;
+ need_ior_printout = FALSE;
if (iorfd == 1)
fh = stdout;
@@ -47,7 +76,7 @@
close (iorfd);
}
#ifdef OAF_DEBUG
- else if (actid && need_printout) {
+ else if (actid && need_ior_printout) {
g_message ("Unusual '%s' was activated, but "
"'%s' is needed", iid, actid);
}
Index: oafd/main.c
===================================================================
RCS file: /cvs/gnome/oaf/oafd/main.c,v
retrieving revision 1.14
diff -u -r1.14 main.c
--- oafd/main.c 2000/07/14 23:43:14 1.14
+++ oafd/main.c 2000/07/18 00:19:50
@@ -89,7 +89,10 @@
real_od_source_dir = g_string_new (OAFINFODIR);
env_od_source_dir = g_getenv ("OAF_INFO_PATH");
gnome_env_od_source_dir = g_getenv ("GNOME_PATH");
- gnome_env_od_source_dir = (char *) g_strconcat (gnome_env_od_source_dir, "/share/oaf");
+ if (gnome_env_od_source_dir) {
+ gnome_env_od_source_dir = g_strconcat (gnome_env_od_source_dir,
+ "/share/oaf", NULL);
+ }
if (od_source_dir) {
g_string_append_c (real_od_source_dir, ':');
Index: test/broken.oafinfo
===================================================================
RCS file: /cvs/gnome/oaf/test/broken.oafinfo,v
retrieving revision 1.2
diff -u -r1.2 broken.oafinfo
--- test/broken.oafinfo 2000/06/02 23:03:55 1.2
+++ test/broken.oafinfo 2000/07/18 00:19:50
@@ -1,5 +1,8 @@
<oaf_info>
+<oaf_server iid="OAFIID:NotInServer:20000717" type="exe" location="./oaf-empty-server">
+</oaf_server>
+
<oaf_server iid="OAFIID:Bogus:20000526" type="factory" location="OAFIID:Empty:19991025-Deliberate-Typo">
</oaf_server>
Index: test/oaf-test-client.c
===================================================================
RCS file: /cvs/gnome/oaf/test/oaf-test-client.c,v
retrieving revision 1.9
diff -u -r1.9 oaf-test-client.c
--- test/oaf-test-client.c 2000/07/05 21:50:01 1.9
+++ test/oaf-test-client.c 2000/07/18 00:19:50
@@ -4,7 +4,7 @@
#include <stdlib.h>
#include "empty.h"
-#define TOTAL_TEST_SCORE 9
+#define TOTAL_TEST_SCORE 11
CORBA_Object name_service = CORBA_OBJECT_NIL;
@@ -169,6 +169,25 @@
fprintf (stderr, ", failed 2");
}
fprintf (stderr, "\n");
+
+
+ fprintf (stderr, "Server that doesn't register IID test ");
+ obj = oaf_activate_from_id ("OAFIID:NotInServer:20000717", 0, NULL, &ev);
+ if (obj || ev._major == CORBA_NO_EXCEPTION) {
+ fprintf (stderr, "failed 1");
+ } else {
+ fprintf (stderr, "passed 1 ('%s')", oaf_exception_id (&ev));
+ CORBA_exception_free (&ev);
+ passed++;
+ }
+ if (test_oafd (&ev, "with non-registering server")) {
+ fprintf (stderr, ", passed 2");
+ passed++;
+ } else {
+ fprintf (stderr, ", failed 2");
+ }
+ fprintf (stderr, "\n");
+
fprintf (stderr, "\n%d tests passed (%s)\n", passed,
passed == TOTAL_TEST_SCORE? "All": "some failures");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]