src/fuse/udcFuse/udcFuse.c 1.2

1.2 2009/11/06 05:16:01 angie
Set the udc cache timeout to an hour [need to add refresh button to hgTrackUi, then can make timeout very large], and if cache files are younger than that, use kernel caching (on top of udc's faster open) for almost-local performance.
Index: src/fuse/udcFuse/udcFuse.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/fuse/udcFuse/udcFuse.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -b -B -U 4 -r1.1 -r1.2
--- src/fuse/udcFuse/udcFuse.c	3 Nov 2009 01:04:20 -0000	1.1
+++ src/fuse/udcFuse/udcFuse.c	6 Nov 2009 05:16:01 -0000	1.2
@@ -196,8 +196,10 @@
 char buf[4096];
 char *url = udcPathToUrl(path, buf, sizeof(buf), NULL);
 if (url != NULL)
     {
+    if (udcCacheAge(url, NULL) < udcCacheTimeout())
+	fi->keep_cache = 1;
     udcf = udcFileMayOpen(url, NULL);
     fprintf(stderr, "...[%d] open -> udcFileMayOpen(%s) -> 0x%llx\n", pid, url, (long long)udcf);
     }
 else
@@ -205,9 +207,9 @@
     fprintf(stderr, "...[%d] open: Unable to translate path %s to URL!\n", pid, path);
     ERR_CATCH_FREE();
     return -1;
     }
-ERR_CATCH_END("udcPathToUrl or udcFileMayOpen");
+ERR_CATCH_END("udcPathToUrl, udcCacheAge or udcFileMayOpen");
 if (udcf == NULL)
     {
     fprintf(stderr, "...[%d] open: Unable to open udcFile for %s!\n", pid, path);
     return -1;
@@ -293,8 +295,12 @@
     // Fuse does not like getting an extra arg.
     argc--;
     }
 
+// Use kernel caching, and tell udc not to ping server, if cache files are 
+// less than an hour old.  (Should make this a command-line opt.)
+udcSetCacheTimeout(3600);
+
 #ifndef UDC_TEST
 
 return fuse_main(argc, argv, &udcfs_oper, NULL);