[Http-crcsync] crccache ready for some testing I think

Alex Wulms alex.wulms at scarlet.be
Sun Apr 5 11:07:50 EDT 2009


All,

I have updated crccache as per below mail. Changes are in the git repository.


Rusty,

I have slightly chanced crcsync for how it handles the final_size. 
Your code was expecting: 0 < final_size <= block_size
I have changed it into: 0 <= final_size < block_size

Reason for the change is that it makes both your code and the crccache code 
simpler.

Here below is the diff for crcsync. Can you please apply it to the upstream 
ccan repository?

Thanks and kind regards,
Alex


diff --git a/ccan/crcsync/crcsync.c b/ccan/crcsync/crcsync.c
index 459010a..f077b99 100644
--- a/ccan/crcsync/crcsync.c
+++ b/ccan/crcsync/crcsync.c
@@ -72,18 +72,14 @@ struct crc_context *crc_context_new(size_t block_size, 
unsigned crcbits,

        assert(num_crcs > 0);
        assert(block_size > 0);
-       assert(final_size > 0);
-       assert(final_size <= block_size);
+       assert(final_size < block_size);

        ctx = malloc(sizeof(*ctx) + sizeof(crc[0])*num_crcs);
        if (ctx) {
                ctx->block_size = block_size;
-               if (final_size != block_size) {
-                       ctx->final_size = final_size;
+               ctx->final_size = final_size; // If it is 0, we never compare 
against it
+               if (final_size != 0) {
                        ctx->final_crc = crc[--num_crcs];
-               } else {
-                       /* If this is 0, we never compare against it. */
-                       ctx->final_size = 0;
                }

                /* Technically, 1 << 32 is undefined. */
diff --git a/ccan/crcsync/crcsync.h b/ccan/crcsync/crcsync.h
index 4b25562..9447639 100644
--- a/ccan/crcsync/crcsync.h
+++ b/ccan/crcsync/crcsync.h
@@ -23,7 +23,7 @@ void crc_of_blocks(const void *data, size_t len, unsigned 
int blocksize,
  * @crcbits: the bits valid in the CRCs (<= 32)
  * @crc: array of block crcs
  * @num_crcs: number of block crcs
- * @final_size: the final block size (<= blocksize).
+ * @final_size: the final block size (0 <= final_size < blocksize).
  *
  * Returns an allocated pointer to the structure for crc_find_block,
  * or NULL.  Makes a copy of @crc and @num_crcs.





Op zondag 5 april 2009, schreef Alex Wulms:
> Hi Rusty,
>
> Many thanks!!!
>
> I'll adapt crccache code this sunday to support the improved algorithm and
> submit all to the git repo.
>
> Hi Toby,
>
> I'll change the crccache-client to send the original file size in stead  of
> the blocksize in the header. In that way, the crccache-server can calculate
> the blocksize and the tailsize by itself. It is more efficient then using
> two headers (one with blocksize, one with tailsize). I'll also adapt the
> client to put the crc of all 21 blocks (the 20 full blocks + the 1 tail
> block) in the header. I must still figure out what to do in case that the
> tail has a zero size (e.g. if filesize is exact multiple of 20) but I think
> that while writing the code, the answer will crystalize by itself.
>
> Thanks and brs,
> Alex
>


More information about the Http-crcsync mailing list