From c98ca590a8fcbe65a7ce668529d2fdcea5654de6 Mon Sep 17 00:00:00 2001 From: Jonathan Warren Date: Mon, 20 Jan 2014 15:25:02 -0500 Subject: [PATCH] Fix #566 --- src/bitmessagemain.py | 9 ++++++--- src/helper_startup.py | 12 ++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/bitmessagemain.py b/src/bitmessagemain.py index 4b210443..e4a073d9 100755 --- a/src/bitmessagemain.py +++ b/src/bitmessagemain.py @@ -15,7 +15,8 @@ import singleton import os from SimpleXMLRPCServer import SimpleXMLRPCServer -from api import MySimpleXMLRPCRequestHandler +from api import MySimpleXMLRPCRequestHandler +from helper_startup import isOurOperatingSystemLimitedToHavingVeryFewHalfOpenConnections import shared from helper_sql import sqlQuery @@ -59,10 +60,12 @@ def connectToStream(streamNumber): for row in queryData: shared.inventorySets[streamNumber].add(row[0]) - if sys.platform[0:3] == 'win': + + if isOurOperatingSystemLimitedToHavingVeryFewHalfOpenConnections(): + # Some XP and Vista systems can only have 10 outgoing connections at a time. maximumNumberOfHalfOpenConnections = 9 else: - maximumNumberOfHalfOpenConnections = 32 + maximumNumberOfHalfOpenConnections = 64 for i in range(maximumNumberOfHalfOpenConnections): a = outgoingSynSender() a.setup(streamNumber, selfInitiatedConnections) diff --git a/src/helper_startup.py b/src/helper_startup.py index 0e35e594..0bae9496 100644 --- a/src/helper_startup.py +++ b/src/helper_startup.py @@ -5,6 +5,8 @@ import os import locale import random import string +import platform +from distutils.version import StrictVersion from namecoin import ensureNamecoinOptions @@ -119,3 +121,13 @@ def loadConfig(): os.umask(0o077) with open(shared.appdata + 'keys.dat', 'wb') as configfile: shared.config.write(configfile) + +def isOurOperatingSystemLimitedToHavingVeryFewHalfOpenConnections(): + try: + VER_THIS=StrictVersion(platform.version()) + if sys.platform[0:3]=="win": + return StrictVersion("5.1.2600")VER_THIS + return False + except Exception as err: + print 'An Exception occurred within isOurOperatingSystemLimitedToHavingVeryFewHalfOpenConnections:', err + return False \ No newline at end of file