Skip to content

Commit 4aabc55

Browse files
author
Daniel Kinzler
committed
check protocol version against range
git-svn-id: https://svn.toolserver.org/svnroot/daniel/duesenstuff/trunk/gpClient@568 9f2c43bc-b3c0-43f4-b155-41619b16f219
1 parent 45d1be4 commit 4aabc55

File tree

1 file changed

+30
-10
lines changed

1 file changed

+30
-10
lines changed

python/gp/client.py

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,18 @@
5858
PORT = 6666
5959
"""Default GraphServ port"""
6060

61-
CLIENT_PROTOCOL_VERSION = 3
62-
"""Expected GraphServ protocol version. If GraphServ (resp. GraphCore)
63-
reports a different protocol version, the conenction will be aborted."""
61+
CLIENT_PROTOCOL_VERSION = 4
62+
"""Implemented GraphServ protocol version. May be used to determin which
63+
features are supported. Is not used to validate the peer's protocol version,
64+
see MIN_PROTOCOL_VERSION and MAX_PROTOCOL_VERSION for that."""
65+
66+
MIN_PROTOCOL_VERSION = 2.0
67+
"""Minimum GraphServ protocol version. If GraphServ (resp. GraphCore)
68+
reports a lower protocol version, the connection will be aborted."""
69+
70+
MAX_PROTOCOL_VERSION = 4.99
71+
"""Maximum GraphServ protocol version. If GraphServ (resp. GraphCore)
72+
reports a higher protocol version, the connection will be aborted."""
6473

6574

6675
def __function__ (shift = 1): #XXX: wtf?
@@ -1283,23 +1292,34 @@ def setDebug(self, debug): #OK
12831292

12841293
def getProtocolVersion(self):
12851294
"""Return the protocol version reported by the peer."""
1286-
self.protocol_version()
1287-
version = self.statusMessage.strip()
1288-
return version
1295+
1296+
if not _protocol_version:
1297+
self.protocol_version()
1298+
_protocol_version = self.statusMessage.strip()
1299+
1300+
return self._protocol_version
12891301

12901302

12911303
def checkProtocolVersion(self):
12921304
"""Can raise a gpProtocolException.
12931305
12941306
It raises a gpProtocolException if the protocol version reported by the
1295-
peer is not compatible with CLIENT_PROTOCOL_VERSION.
1307+
peer is not compatible with MIN_PROTOCOL_VERSION and MAX_PROTOCOL_VERSION.
12961308
12971309
"""
12981310
version = self.getProtocolVersion()
1299-
if int(version) != int(CLIENT_PROTOCOL_VERSION):
1311+
version = float(version)
1312+
1313+
if version < MIN_PROTOCOL_VERSION:
1314+
raise gpProtocolException(
1315+
"Bad protocol version: expected at least "
1316+
+ str(MIN_PROTOCOL_VERSION)
1317+
+ ", but peer uses %s" % str(version) )
1318+
1319+
if version > MAX_PROTOCOL_VERSION:
13001320
raise gpProtocolException(
1301-
"Bad protocol version: expected "
1302-
+ str(CLIENT_PROTOCOL_VERSION)
1321+
"Bad protocol version: expected at most "
1322+
+ str(MAX_PROTOCOL_VERSION)
13031323
+ ", but peer uses %s" % str(version) )
13041324

13051325

0 commit comments

Comments
 (0)