emacs-devel
[Top][All Lists]
Advanced

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

Re: Failing filename completion in large NFS-mounted directories


From: Stefan Monnier
Subject: Re: Failing filename completion in large NFS-mounted directories
Date: Thu, 01 Sep 2005 16:57:40 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

> I Google'd and came across Stefan Monnier's email:
>    http://lists.gnu.org/archive/html/emacs-devel/2005-08/msg00643.html
> including this patch to dired.c:

Somehow I failed to install that patch.  Huh!

Seeing how mobody else reacted, I suggest the patch below, which also fixes
an ugly bug on 64bit systems.


-- Stefan

        * dired.c (directory_files_internal_unwind): Use a proper pointer
        rather than a pair of 16bit integers to store the DIR*.
        (directory_files_internal, file_name_completion): Update use.
        Handle EAGAIN and EINTR consistently, and check QUIT.


--- dired.c     22 aoĆ» 2005 10:24:18 -0400      1.117
+++ dired.c     01 sep 2005 16:53:06 -0400      
@@ -131,7 +131,7 @@
 directory_files_internal_unwind (dh)
      Lisp_Object dh;
 {
-  DIR *d = (DIR *) ((XINT (XCAR (dh)) << 16) + XINT (XCDR (dh)));
+  DIR *d = (DIR *) XSAVE_VALUE (dh)->pointer;
   closedir (d);
   return Qnil;
 }
@@ -155,7 +155,6 @@
   int count = SPECPDL_INDEX ();
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
   DIRENTRY *dp;
-  int retry_p;
 
   /* Because of file name handlers, these functions might call
      Ffuncall, and cause a GC.  */
@@ -189,12 +188,6 @@
   /* Now *bufp is the compiled form of MATCH; don't call anything
      which might compile a new regexp until we're done with the loop!  */
 
-  /* Do this opendir after anything which might signal an error; if
-     an error is signaled while the directory stream is open, we
-     have to make sure it gets closed, and setting up an
-     unwind_protect to do so would be a pain.  */
- retry:
-
   d = opendir (SDATA (dirfilename));
   if (d == NULL)
     report_file_error ("Opening directory", Fcons (directory, Qnil));
@@ -203,8 +196,7 @@
      file-attributes on filenames, both of which can throw, so we must
      do a proper unwind-protect.  */
   record_unwind_protect (directory_files_internal_unwind,
-                        Fcons (make_number (((unsigned long) d) >> 16),
-                               make_number (((unsigned long) d) & 0xffff)));
+                        make_save_value (d, 0));
 
   directory_nbytes = SBYTES (directory);
   re_match_object = Qt;
@@ -222,10 +214,15 @@
       errno = 0;
       dp = readdir (d);
 
+      if (dp == NULL && (0
 #ifdef EAGAIN
-      if (dp == NULL && errno == EAGAIN)
-       continue;
+                        || errno == EAGAIN
+#endif
+#ifdef EINTR
+                        || errno == EINTR
 #endif
+                        ))
+       { QUIT; continue; }
 
       if (dp == NULL)
        break;
@@ -316,22 +313,11 @@
        }
     }
 
-  retry_p = 0;
-#ifdef EINTR
-  retry_p |= errno == EINTR;
-#endif
-
   closedir (d);
 
   /* Discard the unwind protect.  */
   specpdl_ptr = specpdl + count;
 
-  if (retry_p)
-    {
-      list = Qnil;
-      goto retry;
-    }
-
   if (NILP (nosort))
     list = Fsort (Fnreverse (list),
                  attrs ? Qfile_attributes_lessp : Qstring_lessp);
@@ -519,8 +505,7 @@
        report_file_error ("Opening directory", Fcons (dirname, Qnil));
 
       record_unwind_protect (directory_files_internal_unwind,
-                             Fcons (make_number (((unsigned long) d) >> 16),
-                                    make_number (((unsigned long) d) & 
0xffff)));
+                             make_save_value (d, 0));
 
       /* Loop reading blocks */
       /* (att3b compiler bug requires do a null comparison this way) */
@@ -532,8 +517,19 @@
 #ifdef VMS
          dp = (*readfunc) (d);
 #else
+         errno = 0;
          dp = readdir (d);
+         if (dp == NULL && (0
+# ifdef EAGAIN
+                            || errno == EAGAIN
+# endif
+# ifdef EINTR
+                            || errno == EINTR
+# endif
+                            ))
+           { QUIT; continue; }
 #endif
+
          if (!dp) break;
 
          len = NAMLEN (dp);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]