Simplified captive_sandbox_spawn() prototype.
authorshort <>
Fri, 4 Jul 2003 04:55:01 +0000 (04:55 +0000)
committershort <>
Fri, 4 Jul 2003 04:55:01 +0000 (04:55 +0000)
Implemented 3-stage image_iochannel GIOChannel sequence for commits.
+captive_sandbox_parent_vfs_commit()

src/libcaptive/sandbox/parent-Vfs.c

index a894cf3..862f27b 100644 (file)
@@ -29,6 +29,7 @@
 #include "server-CaptiveIOChannel.h"
 #include <signal.h>    /* for kill(2) */
 #include <wait.h>
+#include "../client/giochannel-blind.h"        /* for captive_giochannel_blind_commit() */
 
 
 GnomeVFSResult captive_sandbox_parent_vfs_new(CaptiveVfsObject *captive_vfs_object)
@@ -39,14 +40,7 @@ gboolean errbool;
 
        captive_vfs_object->is_sandbox_parent=TRUE;
 
-       errbool=captive_sandbox_spawn(
-                       captive_vfs_object,     /* child_captive_vfs_object */
-                       &captive_vfs_object->corba_Vfs_object,  /* corba_Vfs_object_return */
-                       &captive_vfs_object->corba_GLogFunc_object,     /* corba_GLogFunc_object_return */
-                       &captive_vfs_object->corba_CaptiveIOChannel_object,     /* corba_CaptiveIOChannel_object_return */
-                       &captive_vfs_object->corba_parent_giochanel_blind,      /* corba_parent_giochanel_blind_ptr */
-                       &captive_vfs_object->corba_parentheart_fds_1,   /* parentheart_fds_1_return */
-                       &captive_vfs_object->corba_child_pid);  /* child_pid_return */
+       errbool=captive_sandbox_spawn(captive_vfs_object);
        g_return_val_if_fail(errbool==TRUE,GNOME_VFS_ERROR_GENERIC);
 
        return GNOME_VFS_OK;
@@ -86,13 +80,6 @@ GIOStatus erriostatus;
        g_assert(validate_CORBA_Environment(&captive_corba_ev));
        impl_Captive_CaptiveIOChannel__destroy(CaptiveIOChannel_servant,&captive_corba_ev);
        g_assert(validate_CORBA_Environment(&captive_corba_ev));
-       erriostatus=g_io_channel_flush(
-                       captive_vfs_object->corba_parent_giochanel_blind,       /* channel */
-                       NULL);  /* error */
-       g_assert(erriostatus==G_IO_STATUS_NORMAL);
-#if 0
-       g_io_channel_unref(captive_vfs_object->corba_parent_giochanel_blind);
-#endif
 
        /* Close parentheart_fd_write. */
        if (captive_vfs_object->corba_parentheart_fds_1!=-1) {
@@ -117,5 +104,34 @@ GIOStatus erriostatus;
                                WNOHANG);       /* options */
                }
 
+       if (r==GNOME_VFS_OK) {
+               erriostatus=captive_giochannel_blind_commit(captive_vfs_object->corba_parent_giochanel_blind);
+               g_assert(erriostatus==G_IO_STATUS_NORMAL);
+               }
+       else {  /* sandbox child failure */
+               /* Flush the channel to catch all the disk accesses to the bugreport. */
+               erriostatus=g_io_channel_flush(
+                               captive_vfs_object->corba_parent_giochanel_blind,       /* channel */
+                               NULL);  /* error */
+               g_assert(erriostatus==G_IO_STATUS_NORMAL);
+
+               /* TODO: Summarize the bugreport. */
+               }
+       g_io_channel_unref(captive_vfs_object->corba_parent_giochanel_blind);
+       captive_vfs_object->corba_parent_giochanel_blind=NULL;
+
        return r;
 }
+
+
+GnomeVFSResult captive_sandbox_parent_vfs_commit(CaptiveVfsObject *captive_vfs_object)
+{
+GnomeVFSResult r_close,r_new;
+
+       g_return_val_if_fail(captive_vfs_object!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
+
+       r_close=captive_sandbox_parent_vfs_close(captive_vfs_object);   /* errors ignored */
+       r_new=captive_sandbox_parent_vfs_new(captive_vfs_object);
+
+       return (r_new!=GNOME_VFS_OK ? r_new : r_close);
+}