Enlightenment CVS committal

Author  : azundris
Project : e17
Module  : apps/e

Dir     : e17/apps/e/src


Modified Files:
      Tag: SPLIT
        e_dir.c 


Log Message:
DESCRIPTION

Fixed crash reported by benr.  e17 tried to set efsd watches on
~/.e/desktop/<n>/.e_layout; if they didn't exist, realpath would
fail, the dir-string would hence become NULL, setting the monitor
would then fail, and the D() supposed to alert us to that failure
would to try to print the NULL string, which bombs out on Solaris
(but not on Lin).

MEASURES TAKEN

- e_dir_handle_fs_restart() will now do more error checking, and
  should not crash anymore if given dubious or invalid data; the
  error msgs should also be more elaborate

- if the realpath thingie fails in e_dir_set_dir() (which also has
  more error-checking now), we throw the whole idea of realpath out
  of the window and make a copy of the path the coder requested in
  the first place, assuming they really meant "...and if it doesn't
  exist YET, tell me if and when it is created!"  rather than failing
  right there and then, we hope the backend actually supports watching
  something it cannot determine an inode for (but we'll still throw a
  warning, just for good measure).  actually, it can't for now, so
  e_dir_handle_fs_restart() will complain that it can't set a monitor.

CAVEATS

This averts the crash.  However, e17 will not be informed if any of the
desktops suddenly pops into existence.

TODO

A possible remedy for a given parth

  /existentDir1/existentDir2/nonexistentDir1/nonexistentDir2/nonexistentFile

would be to place a dir-monitor on existentDir2.  once nonexistentDir1 is
created, the monitor will see it.  then, the monitor on existentDir2 should
be replaced with one on the newly created nonexistentDir1.  likewise for
nonexistentDir2.  only if nonexistentFile should be created in nonexistentDir2
should the high-level parts of the application be notified.

This functionality could reside in e17 or, preferably, in efsd.


===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/e_dir.c,v
retrieving revision 1.2.2.6
retrieving revision 1.2.2.7
diff -u -3 -r1.2.2.6 -r1.2.2.7
--- e_dir.c     30 Oct 2002 22:24:28 -0000      1.2.2.6
+++ e_dir.c     11 Jan 2003 08:36:54 -0000      1.2.2.7
@@ -66,39 +66,47 @@
 }
 
 static void
-e_dir_handle_fs_restart(void *data)
-{
+e_dir_handle_fs_restart(void *data) {
    E_Dir              *d;
 
    D_ENTER;
-   d = data;
-   D("e_dir_handle_fs_restart\n");
-   if (e_fs_get_connection())
-     {
-       EfsdOptions        *ops;
 
-       /* FIXME restart with metadata pending for views */
-
-       ops = efsd_ops(3,
-                      efsd_op_get_stat(),
-                      efsd_op_get_filetype(), efsd_op_list_all());
-       d->monitor_id = efsd_start_monitor(e_fs_get_connection(), d->dir,
-                                          ops, TRUE);
+   D("e_dir_handle_fs_restart\n");
 
-     }
-   D("restarted monitor id (connection = %p), %i for %s\n",
-     e_fs_get_connection(), d->monitor_id, d->dir);
+   if((d = data)) {
+     if(d->dir&&*(d->dir)) {
+       if (e_fs_get_connection()) {
+        EfsdOptions        *ops;
+
+        /* FIXME restart with metadata pending for views */
+
+        ops = efsd_ops(3,
+                       efsd_op_get_stat(),
+                       efsd_op_get_filetype(), efsd_op_list_all());
+        if((d->monitor_id=efsd_start_monitor(e_fs_get_connection(), d->dir,
+                                             ops, TRUE))<0) {
+          D("could not restart monitor (connx %p) for \"%s\" => %i\n",
+            e_fs_get_connection(), d->dir, d->monitor_id); }
+        else {
+          D("restarted monitor (connx %p) for \"%s\" => ID %i...\n",
+            e_fs_get_connection(), d->dir, d->monitor_id); }}
+       else {
+        D("could not restart, connection refused\n"); }}
+     else {
+        D("could not restart, no dir given!?\n"); }}
+   else {
+     D("could not restart, no data\n"); }
 
-   D_RETURN;
-}
+   D_RETURN; }
 
 void
 e_dir_set_dir(E_Dir * d, char *dir)
 {
    D_ENTER;
 
-   if (!d)
-      D_RETURN;
+   if (!d) {
+     D("e_dir_set_dir -- no E_Dir!\n");
+     D_RETURN; }
 
    /* stop monitoring old dir */
    if ((d->dir) && (d->monitor_id))
@@ -107,8 +115,29 @@
        d->monitor_id = 0;
      }
    IF_FREE(d->dir);
+
+   if(!dir||!*dir) {
+     D("e_dir_set_dir -- no dir!\n");
+     D_RETURN; }
+
    d->dir = e_file_realpath(dir);
-   
+
+   if(!d->dir||!*(d->dir)) {
+     /* realpath failed. this would mean that we tried to set a monitor
+        on a non-existent (or inacessible) file.  this may mean that the
+        programmer really meant "...and if it doesn't exist YET, tell me
+        if and when it is created", so rather than failing right here and
+        now, we'll forget about the realpath, stick in the path they
+        requested in the first place, and hope the backend actually supports
+        watching something it cannot determine an inode for...  we'll still
+        throw a warning though, just for good measure.  Azundris 2003/01/11 */
+     D("e_dir_set_dir -- e_file_realpath(\"%s\") failed...\n",dir);
+     if(d->dir)
+       free(d->dir);
+     if(!(d->dir=strdup(dir))) {
+       D("e_dir_set_dir: OOM");
+       D_RETURN; }}
+
    /* start monitoring new dir */
    d->restarter = e_fs_add_restart_handler(e_dir_handle_fs_restart, d);
    if (e_fs_get_connection())
@@ -120,7 +149,7 @@
                       efsd_op_get_filetype(), efsd_op_list_all());
        d->monitor_id = efsd_start_monitor(e_fs_get_connection(), d->dir,
                                           ops, TRUE);
-       D("monitor id for %s = %i\n", d->dir, d->monitor_id);
+       D("monitor id for \"%s\" = %i\n", d->dir, d->monitor_id);
      }
    D_RETURN;
 }




-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to