Re: librsync stream interface
Denis Corbin <[email protected]> Sun, 07 Jun 2015 19:01:33 +0200
| Newsgroups | gmane.network.librsync.general |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I get a strange behavior trying to mimic what rs_loadsig_file() then rs_delta_file() but replacing the call to rs_whole_run() by an equivalent routing relying on rs_job_iter() in place of rs_job_drive(). rs_signature_t *sumset = NULL; rs_job_t *job = rs_loadsig_begin(&sumset); rs_buffers_t buf; /* in a loop feeding buf with data */ res = rs_job_iter(job, &buf); /* then and extracting next_out/avail_out */ rs_job_free(job); first cycle: - - feeding 24 bytes in avail_in/next_in - - getting RS_BLOCKED as returned value, no data in next_out/avail_out second cycle: - - feeding 0 bytes and setting eof_in - - getting RS_DONE as returned value from rs_job_iter(). and no data in next_out/avail_out as expected. So far so good! I got the signature in memory pointed to by sumset. The problem occurs when I try to perform the delta, just the job creation differs: job = rs_delta_begin(sumset); /* in a loop feeding buf with data */ res = rs_job_iter(job, &buf); /* then and extracting next_out/avail_out */ first cycle: - - I feed 33 bytes in next_in/avail_in - - I get 4 bytes in next_out/avail_out with RS_BLOCKED returned by rs_job_iter() and all avail_in bytes have been consumed second cycle: - - I feed 0 bytes in next_in/avail_in (reached EOF) and thus set eof_in to 1 - - next_out points to a valid pointer with avail_out set to the allocated memory, I've double checked. calling rs_job_iter() then halts the program with the following error: Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7bd6050 in rs_search_for_block () from /usr/lib/x86_64-linux-gnu/librsync.so.1 What did I do wrong? Cheers, Denis. On 01/06/2015 20:43, Denis Corbin wrote : > On 01/06/2015 02:02, Martin Pool wrote: >> Have a look at the implementation of rs_loadsig_file, which shows >> that you construct a new job with rs_loadsig_begin, then feed >> data into it. > > OK, good idea, > > >> You can do this either through rs_job_drive which will call back >> to you, or by establishing your own callbacks then calling >> rs_job_iter. > -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQIVAwUBVXR47QgxsL0D2LGCAQLwehAAgLN9Jupwh12zRdreQ+b2h8r5T6b4sLJJ 3DsjGg4jvaTa2WOYGYaALl/qqBJ35ua1C/kQUMOl/pRXmGh8w++5XmZrJuidv7rX mzC4o//5zl/pc+1jI4JgZp5mU3BNimYwYoswONeON//d/eS7rN2wFObyAsvbSZYd UGuRddBDR/sDDdaIP99oQHX5DxpWwCZpXez/6HdWXsgbjUb8PfDbMNb3U47bM8Om HpfYo7sd9CEtmPu3TH514aERZPp74PMgJT3pSoRj7FU3p382f/feAUNl+ni8kPdP krO5R6o+N//emMiMBEYbsgejfOEsNZdPYKlLDU9S6xsZn5cuuogn2OWWocANM2az 1So/VV5PMaJ6S/IgOa7wxQffrImY5DEjh7cNuuMmt95vwF4zIdtbsFon6uWFu09U AZj/GASnAcSVen9bp7tZunTMe1wZeFEGw6O9a72/t033Jq/hxPWrEoyKuB9tnY9b MEjRRMlr+BtuknX7nQ7mX8EGT1TUPXOjneA6DPPG/MehpTsW+V1SQ3FNRFkiryFe TZS9YstJS75tKMTQorVtqIPQQNluzvfffWY+tgA84Bucxd7DfovPbpCSl7IRd4ut fu+BMMcMRG2q8/q+g/mnTSedIgLzcP5LmYAG++eFNPnpHw7WKnEbT5L0R67pC8Nu W8JVsEtKYKo= =skdK -----END PGP SIGNATURE----- ------------------------------------------------------------------------------