Check-in [bd3c1d0023]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Additional work on the xfer mechanism, trying to increase the use of delta compression.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: bd3c1d0023c2e573dbf92d19de29952603d24a92
User & Date: drh 2007-08-09 19:07:28.000
Context
2007-08-10
00:08
Complete rework of the xfer mechanism. Compiles but not yet working. check-in: 573a464cb7 user: drh tags: trunk
2007-08-09
19:07
Additional work on the xfer mechanism, trying to increase the use of delta compression. check-in: bd3c1d0023 user: drh tags: trunk
17:42
The delta compress on xfer is working better now, but still needs work. check-in: 73bddaebb9 user: drh tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/xfer.c.
234
235
236
237
238
239
240

241
242
243
244




245



246



247



248



249








250
251
252
253
254
255
256
257
258
259
260
261
262
263

264
265



266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
}


/*
** Send all pending files.
*/
static int send_all_pending(Blob *pOut){

  int iRidSent = 0;
  int sent = 0;
  int nSent = 0;
  int maxSize = db_get_int("http-msg-size", 500000);




  Stmt q;







  db_prepare(&q, "SELECT rid FROM pending ORDER BY rid");



  while( db_step(&q)==SQLITE_ROW ){



    int rid = db_column_int(&q, 0);








    if( sent<maxSize ){
      sent += send_file(rid, pOut);
      nSent++;
      iRidSent = rid;
    }else{
      char *zUuid = db_text(0,
                      "SELECT uuid FROM blob WHERE rid=%d AND size>=0", rid);
      if( zUuid ){
        if( pOut ){
          blob_appendf(pOut, "igot %s\n", zUuid);
        }else{
          cgi_printf("igot %s\n", zUuid);
        }
        free(zUuid);

      }
    }



  }
  db_finalize(&q);
  
  /* Delete the 'pending' records for all files just sent. Otherwise,
  ** we can wind up sending some files more than once.
  */
  if( nSent>0 ){
    db_multi_exec("DELETE FROM pending WHERE rid <= %d", iRidSent);
  }

  return nSent;
}


/*
** Check the signature on an application/x-fossil payload received by
** the HTTP server.  The signature is a line of the following form:







>
|



>
>
>
>
|
>
>
>

>
>
>
|
>
>
>
|
>
>
>
|
>
>
>
>
>
>
>
>



<










>


>
>
>
|
<
|
<
<
<
|
|
|
|







234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277

278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294

295



296
297
298
299
300
301
302
303
304
305
306
}


/*
** Send all pending files.
*/
static int send_all_pending(Blob *pOut){
  int rid, xid, i;
  int nIgot = 0;
  int sent = 0;
  int nSent = 0;
  int maxSize = db_get_int("http-msg-size", 500000);
  static const char *azQuery[] = {
      "SELECT srcid FROM delta JOIN pending ON pending.rid=delta.srcid"
      " WHERE delta.rid=%d"
      "   AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=srcid)",

      "SELECT delta.rid FROM delta JOIN pending ON pending.rid=delta.rid"
      " WHERE srcid=%d"
      "   AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=delta.rid)",

      "SELECT pid FROM plink JOIN pending ON rid=pid"
      " WHERE cid=%d"
      "   AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)",

      "SELECT cid FROM plink JOIN pending ON rid=cid"
      " WHERE pid=%d"
      "   AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=cid)",

      "SELECT pid FROM mlink JOIN pending ON rid=pid"
      " WHERE fid=%d"
      "   AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=pid)",

      "SELECT fid FROM mlink JOIN pending ON rid=fid"
      " WHERE pid=%d"
      "   AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=fid)",
  };

  rid = db_int(0, "SELECT rid FROM pending");
  while( rid && nIgot<200 ){
    db_multi_exec("DELETE FROM pending WHERE rid=%d", rid);
    if( sent<maxSize ){
      sent += send_file(rid, pOut);
      nSent++;

    }else{
      char *zUuid = db_text(0,
                      "SELECT uuid FROM blob WHERE rid=%d AND size>=0", rid);
      if( zUuid ){
        if( pOut ){
          blob_appendf(pOut, "igot %s\n", zUuid);
        }else{
          cgi_printf("igot %s\n", zUuid);
        }
        free(zUuid);
        nIgot++;
      }
    }
    xid = 0;
    for(i=0; xid==0 && i<sizeof(azQuery)/sizeof(azQuery[0]); i++){
      xid = db_int(0, azQuery[i], rid);
    }

    rid = xid;



    if( rid==0 ){
      rid = db_int(0, "SELECT rid FROM pending");
    }
  }
  return nSent;
}


/*
** Check the signature on an application/x-fossil payload received by
** the HTTP server.  The signature is a line of the following form: