On Tue, Dec 06, 2005 at 01:50:30AM +0000, Thorsten Glaser
wrote:> any news on integrating the rsync diff to libz in the upstream sources?
I doubt that it will ever happen. The one kluge in the current
implementation is that rsync dummies up its own static-data block
for the receiving side to include all the omitted unchanged data,
and this is a little too "chummy" with the zlib internals (someone
would need to add a new function to the zlib code to implement this
detail via a standard function if it were to be added to the official
zlib version). Tridge has mentioned to me that he thinks the slight
savings in compression wasn''t really worth all the hassle, so some
future version of rsync may get rid of this optimization and start
to use the system''s zlib.
> Does anyone of you, for the meantime, have a non-intrusive diff which
> I can, as an operating system vendor, apply to our system libz, so
> that rsync can be dynamically linked against it [...]?
If you diff the zlib-1.2.3 source against the rsync/zlib directory,
you''ll end up with a good idea of what to change. I''ve edited
such a
diff to remove the build-oriented changes and attached the result to
this email. The changes needed to rsync''s Makefile to link against
your system zlib I''ll leave up to you.
..wayne..
-------------- next part --------------
--- zlib-1.2.3/deflate.c 2005-07-17 19:27:31.000000000 -0700
+++ rsync/zlib/deflate.c 2005-07-22 08:42:22.000000000 -0700
@@ -557,7 +557,7 @@
deflate_state *s;
if (strm == Z_NULL || strm->state == Z_NULL ||
- flush > Z_FINISH || flush < 0) {
+ flush > Z_INSERT_ONLY || flush < 0) {
return Z_STREAM_ERROR;
}
s = strm->state;
@@ -1419,6 +1419,11 @@
s->strstart += s->lookahead;
s->lookahead = 0;
+ if (flush == Z_INSERT_ONLY) {
+ s->block_start = s->strstart;
+ continue;
+ }
+
/* Emit a stored block if pending_buf will be full: */
max_start = s->block_start + max_block_size;
if (s->strstart == 0 || (ulg)s->strstart >= max_start) {
@@ -1434,6 +1439,11 @@
FLUSH_BLOCK(s, 0);
}
}
+ if (flush == Z_INSERT_ONLY) {
+ s->block_start = s->strstart;
+ return need_more;
+ }
+
FLUSH_BLOCK(s, flush == Z_FINISH);
return flush == Z_FINISH ? finish_done : block_done;
}
@@ -1473,6 +1483,12 @@
INSERT_STRING(s, s->strstart, hash_head);
}
+ if (flush == Z_INSERT_ONLY) {
+ s->strstart++;
+ s->lookahead--;
+ continue;
+ }
+
/* Find the longest match, discarding those <= prev_length.
* At this point we have always match_length < MIN_MATCH
*/
@@ -1541,6 +1557,10 @@
}
if (bflush) FLUSH_BLOCK(s, 0);
}
+ if (flush == Z_INSERT_ONLY) {
+ s->block_start = s->strstart;
+ return need_more;
+ }
FLUSH_BLOCK(s, flush == Z_FINISH);
return flush == Z_FINISH ? finish_done : block_done;
}
@@ -1580,6 +1600,12 @@
INSERT_STRING(s, s->strstart, hash_head);
}
+ if (flush == Z_INSERT_ONLY) {
+ s->strstart++;
+ s->lookahead--;
+ continue;
+ }
+
/* Find the longest match, discarding those <= prev_length.
*/
s->prev_length = s->match_length, s->prev_match =
s->match_start;
@@ -1663,6 +1689,10 @@
s->lookahead--;
}
}
+ if (flush == Z_INSERT_ONLY) {
+ s->block_start = s->strstart;
+ return need_more;
+ }
Assert (flush != Z_NO_FLUSH, "no flush?");
if (s->match_available) {
Tracevv((stderr,"%c", s->window[s->strstart-1]));
--- zlib-1.2.3/zlib.h 2005-07-17 19:26:49.000000000 -0700
+++ rsync/zlib/zlib.h 2005-07-22 08:42:22.000000000 -0700
@@ -166,6 +166,7 @@
#define Z_FINISH 4
#define Z_BLOCK 5
/* Allowed flush values; see deflate() and inflate() below for details */
+#define Z_INSERT_ONLY 6
#define Z_OK 0
#define Z_STREAM_END 1