Tcl Source Code

Artifact [01aa2fbb2e]
Login

Artifact 01aa2fbb2e4c0d73a12182b2b4d9d76c2703cd63:

Attachment "tcl-8.4.14_stats.patch" to ticket [1604352fff] added by julien_dumont 2006-11-28 16:42:16.
diff -Naur tcl8.4.14/unix/tclUnixChan.c tcl8.4.14-jd/unix/tclUnixChan.c
--- tcl8.4.14/unix/tclUnixChan.c	2006-09-07 10:50:35.000000000 +0200
+++ tcl8.4.14-jd/unix/tclUnixChan.c	2006-11-28 10:35:26.000000000 +0100
@@ -1807,7 +1807,21 @@
     if (native == NULL) {
 	return NULL;
     }
-    fd = TclOSopen(native, mode, permissions);
+    // use stats for check if file exist before trying to open it. 
+    // this is very  usefull on nfs / autofs / network remote filesystem for avoid lags 
+    // due to remote filesystem implementation.
+    struct stat sts;
+    int ret;
+    ret = stat(native, &sts);
+    if (ret == 0) {
+      // file exist we can try to open it.
+      fd = TclOSopen(native, mode, permissions);
+    } else {
+      // file don't exist, set error.
+      fd = -1;
+    }
+    // end stats 
+
 #ifdef SUPPORTS_TTY
     ctl_tty = (strcmp (native, "/dev/tty") == 0);
 #endif /* SUPPORTS_TTY */