Hi all,
the attached patch against 1.23 limits the time a single client can
consume for one pull request on the server. The problem here is that
with background IO and larger delta chains, I often see transactions
with 2min or more runtime on my server. The NGINX instance in front is
configured for a reasonable timeout of 2min, so clients often receive
timeouts.

Joerg
$NetBSD$

--- src/xfer.c.orig     2012-08-08 13:49:21.000000000 +0200
+++ src/xfer.c  2013-01-15 17:51:19.000000000 +0100
@@ -20,6 +20,8 @@
 #include "config.h"
 #include "xfer.h"
 
+#include <time.h>
+
 /*
 ** This structure holds information about the current state of either
 ** a client or a server that is participating in xfer.
@@ -42,6 +44,7 @@ struct Xfer {
   int mxSend;         /* Stop sending "file" with pOut reaches this size */
   u8 syncPrivate;     /* True to enable syncing private content */
   u8 nextIsPrivate;   /* If true, next "file" received is a private */
+  time_t maxTime;     /* Time when this transfer should be finished */
 };
 
 
@@ -399,7 +402,7 @@ static void send_file(Xfer *pXfer, int r
     blob_reset(&uuid);
     return;
   }
-  if( pXfer->mxSend<=blob_size(pXfer->pOut) ){
+  if( time(NULL) >= pXfer->maxTime || pXfer->mxSend<=blob_size(pXfer->pOut) ){
     const char *zFormat = isPriv ? "igot %b 1\n" : "igot %b\n";
     blob_appendf(pXfer->pOut, zFormat, pUuid);
     pXfer->nIGotSent++;
@@ -873,6 +876,7 @@ void page_xfer(void){
   xfer.pIn = &g.cgiIn;
   xfer.pOut = cgi_output_blob();
   xfer.mxSend = db_get_int("max-download", 5000000);
+  xfer.maxTime = time(NULL) + db_get_int("max-download-time", 30);
   g.xferPanic = 1;
 
   db_begin_transaction();
@@ -1040,7 +1044,8 @@ void page_xfer(void){
         }
         blob_is_int(&xfer.aToken[2], &seqno);
         max = db_int(0, "SELECT max(rid) FROM blob");
-        while( xfer.mxSend>blob_size(xfer.pOut) && seqno<=max ){
+        while( xfer.mxSend>blob_size(xfer.pOut) && seqno<=max){
+          if( time(NULL) >= xfer.maxTime ) break;
           if( iVers>=3 ){
             send_compressed_file(&xfer, seqno);
           }else{
@@ -1321,6 +1326,7 @@ int client_sync(
   xfer.pIn = &recv;
   xfer.pOut = &send;
   xfer.mxSend = db_get_int("max-upload", 250000);
+  xfer.maxTime = -1;
   if( privateFlag ){
     g.perm.Private = 1;
     xfer.syncPrivate = 1;
_______________________________________________
fossil-users mailing list
[email protected]
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to