I have now had access to a fully equipped FreeBSD machine, and was able to
do more investigation.

I found that the patch appended to this message fixes the problem with the
leftover SHM and WAL files. They are seen each time an unversioned file is
accessed over the /uv web interface, with an IF-NONE-MATCH or
IF-MODIFIED-SINCE cache hit.

I was using the Fossil binary from here when I discovered the problem:

http://pkg.freebsd.org/FreeBSD:10:amd64/latest/All/fossil-2.6,2.txz

I have verified that a mere rebuild (without applying the patch) does not
fix the problem.

I'm using a simple CGI setup to run Fossil on my web server, where each CGI
request is answered by a newly spawned (and immediately terminated)
process. People with more sophisticated server configurations, where Fossil
keeps running in the background, may not see this problem, probably as the
database is "implicitly finalized" by subsequent SQL queries, or because
other running instances of Fossil immediately clean up the SHM and WAL
files, I don't know. Also, I could not reproduce the problem on Windows.

Anyway, this simple patch fixes my problem, and I'd be very happy if you
could incorporate it into the main Fossil code base. (I have already sent
you my signed Contributor Agreement last year, in case this matters.)

If there's cases where Fossil keeps running after serving a /doc or /uv
page, it may be worthwhile to free the allocated temporary string.

--Florian

===================== Patch for Fossil [04190488] ======================

--- Fossil-04190488\src\doc.c Fri May 11 17:02:34 2018
+++ Fossil-patched\src\doc.c Sat May 12 10:41:00 2018
@@ -636,27 +636,31 @@
          if( !file_is_simple_pathname(zName, 1) ){
            goto doc_not_found;
          }
        }else{
          goto doc_not_found;
        }
      }
      if( isUV ){
        if( db_table_exists("repository","unversioned") ){
          Stmt q;
+        char *zHash=0;
+        sqlite3_int64 mtime=0;
          db_prepare(&q, "SELECT hash, mtime FROM unversioned"
                         " WHERE name=%Q", zName);
          if( db_step(&q)==SQLITE_ROW ){
-          etag_check(ETAG_HASH, db_column_text(&q,0));
-          etag_last_modified(db_column_int64(&q,1));
+          zHash = fossil_strdup(db_column_text(&q,0));
+          mtime = db_column_int64(&q,1);
          }
          db_finalize(&q);
+        if( zHash ) etag_check(ETAG_HASH, zHash);
+        if( mtime ) etag_last_modified(mtime);
          if( unversioned_content(zName, &filebody)==0 ){
            rid = 1;
            zDfltTitle = zName;
          }
        }
      }else if( fossil_strcmp(zCheckin,"ckout")==0 ){
        /* Read from the local checkout */
        char *zFullpath;
        db_must_be_within_tree();
        zFullpath = mprintf("%s/%s", g.zLocalRoot, zName);

===================== Patch for Fossil [04190488] ======================
_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to