Ticket #153: remote-protocol-minor-version.patch

File remote-protocol-minor-version.patch, 3.9 KB (added by Olly Betts, 17 years ago)

Patch to implement minor protocol versions

  • docs/remote_protocol.html

     
    77<h1>Remote Backend Protocol</h1>
    88
    99<p>
    10 This document describes <em>version 29</em> of the protocol used by Xapian's
     10This document describes <em>version 30</em> of the protocol used by Xapian's
    1111remote backend.  The protocol assumes a reliable two-way connection across which
    1212arbitrary data can be sent - this could be provided by a TCP socket for example
    1313(as it is with xapian-tcpsrv), but any such connection could be used.  For
     
    5858<h2>Server greeting and statistics</h2>
    5959
    6060<ul>
    61 <li> <code>REPLY_GREETING &lt;protocol version&gt; I&lt;db doc count&gt; I&lt;last docid&gt; B&lt;has positions?&gt; F&lt;db average length&gt;</code>
     61<li> <code>REPLY_GREETING &lt;protocol major version&gt; &lt;protocol minor version&gt; I&lt;db doc count&gt; I&lt;last docid&gt; B&lt;has positions?&gt; F&lt;db average length&gt;</code>
    6262</ul>
    6363
    6464<p>
    65 The protocol version is simply passed as a single byte (<code>'\x09'</code>
    66 for version 9).
     65The protocol major and minor versions are passed as a single byte each (e.g.
     66<code>'\x1e\x01'</code> for version 30.1).  The server and client must
     67understand the same protocol major version, and the server protocol minor
     68version must be greater than or equal to that of the client (this means that
     69the server understands newer MSG_<i>XXX</i>, but will only send newer
     70REPLY_<i>YYY</i> in response to an appropriate client message.
    6771</p>
    6872
    6973<h2>Exception</h2>
  • net/remoteserver.cc

     
    9090
    9191    // Send greeting message.
    9292    string message;
    93     message += char(XAPIAN_REMOTE_PROTOCOL_VERSION);
     93    message += char(XAPIAN_REMOTE_PROTOCOL_MAJOR_VERSION);
     94    message += char(XAPIAN_REMOTE_PROTOCOL_MINOR_VERSION);
    9495    message += encode_length(db->get_doccount());
    9596    message += encode_length(db->get_lastdocid());
    9697    message += (db->has_positions() ? '1' : '0');
  • common/remoteprotocol.h

     
    3232// 27: Support for postlists (always passes the whole list across)
    3333// 28: Pass document length in reply to MSG_TERMLIST
    3434// 29: Serialisation of Xapian::Error includes error_string.
    35 #define XAPIAN_REMOTE_PROTOCOL_VERSION 29
     35#define XAPIAN_REMOTE_PROTOCOL_MAJOR_VERSION 30
     36#define XAPIAN_REMOTE_PROTOCOL_MINOR_VERSION 0
    3637
    3738/// Message types (client -> server).
    3839enum message_type {
  • backends/remote/remote-database.cc

     
    7474    const char *p = message.c_str();
    7575    const char *p_end = p + message.size();
    7676
    77     if (*p != XAPIAN_REMOTE_PROTOCOL_VERSION) {
     77    // The protocol major versions must match.  The protocol minor version of
     78    // the server must be >= that of the client.
     79    int protocol_major = static_cast<unsigned char>(*p++);
     80    int protocol_minor = static_cast<unsigned char>(*p++);
     81    if (protocol_major != XAPIAN_REMOTE_PROTOCOL_MAJOR_VERSION ||
     82        protocol_minor < XAPIAN_REMOTE_PROTOCOL_MINOR_VERSION) {
    7883        string errmsg("Unknown protocol version ");
     84        errmsg += om_tostring(protocol_major);
     85        errmsg += '.';
    7986        errmsg += om_tostring(int(*p));
    80         errmsg += " ("STRINGIZE(XAPIAN_REMOTE_PROTOCOL_VERSION)" supported)";
     87        errmsg += " ("STRINGIZE(XAPIAN_REMOTE_PROTOCOL_MAJOR_VERSION)"."STRINGIZE(XAPIAN_REMOTE_PROTOCOL_MINOR_VERSION)" supported)";
    8188        throw Xapian::NetworkError(errmsg, context);
    8289    }
    83     ++p;
    8490
    8591    doccount = decode_length(&p, p_end, false);
    8692    lastdocid = decode_length(&p, p_end, false);