OAF patch



Hi,

With this patch OAF finally does report errors such as "oafd not
found" if oaf_activate_from_id() fails. Also, it doesn't start oafd if
you pass EXISTING_ONLY, which keeps postinstalls that e.g. run
gconftool to install schemas from spawning off oafds.

Havoc

Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/oaf/ChangeLog,v
retrieving revision 1.126.2.62
diff -u -p -u -r1.126.2.62 ChangeLog
--- ChangeLog	2001/07/13 00:16:16	1.126.2.62
+++ ChangeLog	2001/07/16 16:31:57
@@ -1,3 +1,17 @@
+2001-07-09  Havoc Pennington  <hp redhat com>
+
+	* liboaf/oaf-activate.c (oaf_activate_from_id): use 
+	below functions to report error properly if we can't fork 
+	oafd
+	
+	* liboaf/oaf-mainloop.c
+	(oaf_internal_activation_context_get_extended): another
+	internal function hack
+
+	* liboaf/oaf-registration.c
+	(oaf_internal_service_get_extended): new function, 
+	to be used internally by OAF only for now
+
 2001-07-13  Richard Hult  <rhult codefactory se>
 
 	* liboaf/oaf-registration.c (rloc_file_check): Don't write the
Index: liboaf/liboaf-private.h
===================================================================
RCS file: /cvs/gnome/oaf/liboaf/liboaf-private.h,v
retrieving revision 1.12.2.1
diff -u -p -u -r1.12.2.1 liboaf-private.h
--- liboaf/liboaf-private.h	2001/04/18 22:38:26	1.12.2.1
+++ liboaf/liboaf-private.h	2001/07/16 16:31:57
@@ -60,5 +60,13 @@ extern gboolean oaf_private;
 
 #define OAF_STR_NULL_OR_MATCH(x, y) ((x == NULL) || (x != NULL && y != NULL && strcmp (x, y) != 0))
 
+/* Rename oaf_service_get () in unstable branch */
+CORBA_Object oaf_internal_service_get_extended  (const OAFBaseService         *base_service,
+                                                 gboolean                     existing_only,
+                                                 CORBA_Environment          *ev);
+CORBA_Object oaf_internal_activation_context_get_extended (gboolean           existing_only,
+                                                           CORBA_Environment *ev);
+
+
 #endif
 
Index: liboaf/oaf-activate.c
===================================================================
RCS file: /cvs/gnome/oaf/liboaf/oaf-activate.c,v
retrieving revision 1.20.2.2
diff -u -p -u -r1.20.2.2 oaf-activate.c
--- liboaf/oaf-activate.c	2001/04/18 22:38:26	1.20.2.2
+++ liboaf/oaf-activate.c	2001/07/16 16:31:57
@@ -277,8 +277,11 @@ oaf_activate_from_id (const OAF_Activati
 	OAFActivationInfo *ai;
 
 	g_return_val_if_fail (aid, CORBA_OBJECT_NIL);
-	ac = oaf_activation_context_get ();
-	g_return_val_if_fail (ac, CORBA_OBJECT_NIL);
+
+        ac = oaf_internal_activation_context_get_extended ((flags & OAF_FLAG_EXISTING_ONLY) != 0, ev);
+
+        if (ac == CORBA_OBJECT_NIL)
+                return CORBA_OBJECT_NIL;
 
 	ai = oaf_actid_parse (aid);
 
Index: liboaf/oaf-fork-server.c
===================================================================
RCS file: /cvs/gnome/oaf/liboaf/oaf-fork-server.c,v
retrieving revision 1.1.2.1
diff -u -p -u -r1.1.2.1 oaf-fork-server.c
--- liboaf/oaf-fork-server.c	2001/04/18 21:39:52	1.1.2.1
+++ liboaf/oaf-fork-server.c	2001/07/16 16:31:57
@@ -62,10 +62,25 @@ handle_exepipe (GIOChannel * source,
 {
 	gboolean retval = TRUE;
 
-	*data->iorbuf = '\0';
-	if (!(condition & G_IO_IN)
-	    || !fgets (data->iorbuf, sizeof (data->iorbuf), data->fh))
-		retval = FALSE;
+        /* The expected thing is to get this callback maybe twice,
+         * once with G_IO_IN and once G_IO_HUP, of course we need to handle
+         * other cases.
+         */
+        
+        if (data->iorbuf[0] == '\0' &&
+            (condition & G_IO_IN)) {
+                if (!fgets (data->iorbuf, sizeof (data->iorbuf), data->fh)) {
+                        g_snprintf (data->iorbuf, 128,
+                                    _("Failed to read from child process: %s\n"),
+                                    strerror (errno));
+
+                        retval = FALSE;
+                } else {
+                        retval = TRUE;
+                }
+        } else {                
+                retval = FALSE;
+        }
 
 	if (retval && !strncmp (data->iorbuf, "IOR:", 4))
 		retval = FALSE;
@@ -168,7 +183,8 @@ oaf_server_by_forking (const char **cmd,
 				g_snprintf (cbuf, sizeof (cbuf),
 					    _("Unknown non-exit error (status is %u)"),
 					    status);
-			errval->description = CORBA_string_dup (cbuf);
+
+                        errval->description = CORBA_string_dup (cbuf);
 			CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
 					     ex_OAF_GeneralError, errval);
 			return CORBA_OBJECT_NIL;
@@ -215,7 +231,12 @@ oaf_server_by_forking (const char **cmd,
 #endif
 
 			errval = OAF_GeneralError__alloc ();
-			errval->description = CORBA_string_dup (ai.iorbuf);
+
+                        if (*ai.iorbuf == '\0')
+                                errval->description =
+                                        CORBA_string_dup (_("Child process did not give an error message, unknown failure occurred"));
+                        else
+                                errval->description = CORBA_string_dup (ai.iorbuf);
 			CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
 					     ex_OAF_GeneralError, errval);
 			retval = CORBA_OBJECT_NIL;
@@ -243,8 +264,9 @@ oaf_server_by_forking (const char **cmd,
 		execvp (cmd[0], (char **) cmd);
 		if (iopipes[1] != 1)
 			dup2 (iopipes[1], 1);
-		g_print (_("Exec failed: %d (%s)\n"), errno,
-			 g_strerror (errno));
+		g_print (_("Failed to execute %s: %d (%s)\n"),
+                         cmd[0],
+                         errno, g_strerror (errno));
 		_exit (1);
 	}
 
Index: liboaf/oaf-mainloop.c
===================================================================
RCS file: /cvs/gnome/oaf/liboaf/oaf-mainloop.c,v
retrieving revision 1.27.2.7
diff -u -p -u -r1.27.2.7 oaf-mainloop.c
--- liboaf/oaf-mainloop.c	2001/05/23 03:32:32	1.27.2.7
+++ liboaf/oaf-mainloop.c	2001/07/16 16:31:57
@@ -169,6 +169,20 @@ oaf_domain_get (void)
 }
 
 CORBA_Object
+oaf_internal_activation_context_get_extended (gboolean           existing_only,
+                                               CORBA_Environment *ev)
+{
+	OAFBaseService base_service = {};
+
+	base_service.name = "IDL:OAF/ActivationContext:1.0";
+	base_service.session_name = oaf_session_name_get ();
+	base_service.domain = "session";
+
+	return oaf_internal_service_get_extended (&base_service, existing_only,
+                                                   ev);
+}
+
+CORBA_Object
 oaf_activation_context_get (void)
 {
 	OAFBaseService base_service = {};
Index: liboaf/oaf-registration.c
===================================================================
RCS file: /cvs/gnome/oaf/liboaf/oaf-registration.c,v
retrieving revision 1.24.2.5
diff -u -p -u -r1.24.2.5 oaf-registration.c
--- liboaf/oaf-registration.c	2001/07/13 00:16:17	1.24.2.5
+++ liboaf/oaf-registration.c	2001/07/16 16:31:57
@@ -343,12 +343,14 @@ oaf_activators_use (const OAFBaseService
 	return retval;
 }
 
-CORBA_Object
-oaf_service_get (const OAFBaseService *base_service)
+static CORBA_Object
+oaf_service_get_internal (const OAFBaseService *base_service,
+                          gboolean              existing_only,
+                          CORBA_Environment    *ev)
 {
 	CORBA_Object retval = CORBA_OBJECT_NIL;
 	int i;
-	CORBA_Environment *ev, myev;
+	CORBA_Environment myev, important_error_ev;
 	gboolean ne;
 
 	g_return_val_if_fail (base_service, CORBA_OBJECT_NIL);
@@ -362,7 +364,8 @@ oaf_service_get (const OAFBaseService *b
 		return retval;
 
 	CORBA_exception_init (&myev);
-	ev = &myev;
+        CORBA_exception_init (&important_error_ev);
+        
 	retval = existing_check (base_service, &activatable_servers[i]);
 	if (!CORBA_Object_non_existent (retval, ev))
 		goto out;
@@ -371,16 +374,16 @@ oaf_service_get (const OAFBaseService *b
 
 	retval = oaf_registration_check (base_service, &myev);
 	ne = CORBA_Object_non_existent (retval, &myev);
-	if (ne) {
+	if (ne && !existing_only) {
 		CORBA_Object race_condition;
 
 		CORBA_Object_release (retval, &myev);
-
+                
 		retval =
 			oaf_activators_use (base_service,
 					    activatable_servers[i].cmd,
 					    activatable_servers[i].fd_arg,
-					    ev);
+					    &important_error_ev);
 
 		race_condition = oaf_registration_check (base_service, &myev);
 
@@ -398,10 +401,43 @@ oaf_service_get (const OAFBaseService *b
 		oaf_existing_set (base_service, &activatable_servers[i], retval, ev);
 
       out:
-	CORBA_exception_free (&myev);
+        /* If we overwrote ev with some stupid junk, replace
+         * it with the real error
+         */
+        if (important_error_ev._major != CORBA_NO_EXCEPTION) {
+                CORBA_exception_free (ev);
+                /* This transfers memory ownership */
+                *ev = important_error_ev;
+        }
+        
+        CORBA_exception_free (&myev);
 
 	return retval;
 }
+
+CORBA_Object
+oaf_service_get (const OAFBaseService *base_service)
+{
+        CORBA_Environment ev;
+        CORBA_Object obj;
+        
+        CORBA_exception_init (&ev);
+        
+        obj = oaf_service_get_internal (base_service, FALSE, &ev);
+
+        CORBA_exception_free (&ev);
+
+        return obj;
+}
+
+CORBA_Object
+oaf_internal_service_get_extended (const OAFBaseService *base_service,
+                                   gboolean              existing_only,
+                                   CORBA_Environment    *ev)
+{
+        return oaf_service_get_internal (base_service, existing_only, ev);
+}
+
 
 /*****Implementation of the IOR registration system via plain files ******/
 static int lock_fd = -1;





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]