From 4471d9e5709fc2a9992ef89f916dcb8bb8093d50 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Sat, 21 Apr 2007 18:40:42 +0000 Subject: [PATCH] Added a way to exchange a protocol's sub-protocol value. This will be 0 when a protocol goes final, and non-zero for an intermediary CVS version of a protocol that is in flux. If we find that we're talking to a CVS version with a different sub-protocol #, we automatically drop back to the prior protocol that the sides have in common. --- compat.c | 13 +++++++++++++ rsync.h | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/compat.c b/compat.c index 38618d51..4b57ec48 100644 --- a/compat.c +++ b/compat.c @@ -75,6 +75,19 @@ void setup_protocol(int f_out,int f_in) remote_protocol = read_int(f_in); if (protocol_version > remote_protocol) protocol_version = remote_protocol; + /* CVS support: fallback to finalized protocol if incompatible */ + if (protocol_version >= 30) { + int theirsub, oursub = PROTOCOL_SUBVERSION; + if (!read_batch) + write_varint(f_out, oursub); + theirsub = read_varint(f_in); + if (remote_protocol > PROTOCOL_VERSION) + theirsub = 0; /* 0 == final version */ + if (protocol_version < PROTOCOL_VERSION) + oursub = 0; + if (theirsub != oursub) + protocol_version--; + } } if (read_batch && remote_protocol > protocol_version) { rprintf(FERROR, "The protocol version in the batch file is too new (%d > %d).\n", diff --git a/rsync.h b/rsync.h index d947895a..eccbce02 100644 --- a/rsync.h +++ b/rsync.h @@ -83,6 +83,11 @@ /* update this if you make incompatible changes */ #define PROTOCOL_VERSION 30 +/* This is used when working on a new protocol version in CVS, and should + * be a new non-zero value for each CVS change that affects the protocol. + * It must ALWAYS be 0 when the protocol goes final! */ +#define PROTOCOL_SUBVERSION 1 + /* We refuse to interoperate with versions that are not in this range. * Note that we assume we'll work with later versions: the onus is on * people writing them to make sure that they don't send us anything -- 2.34.1