account for xp, which has a higher half-open allotment

This commit is contained in:
Marcos Pinto 2007-10-15 01:53:42 +00:00
parent f20d0485c3
commit 7d98d49803
1 changed files with 35 additions and 4 deletions

View File

@ -372,7 +372,17 @@ static PyObject *torrent_init(PyObject *self, PyObject *args)
M_settings->user_agent = std::string(user_agent); M_settings->user_agent = std::string(user_agent);
#if defined(_WIN32) #if defined(_WIN32)
DWORD windows_version = ::GetVersion();
if ((windows_version & 0xff) >= 6)
{
// on vista the limit is 5 (in home edition)
M_ses->set_max_half_open_connections(4); M_ses->set_max_half_open_connections(4);
}
else
{
// on XP SP2 it's 10
M_ses->set_max_half_open_connections(8);
}
#endif #endif
M_ses->set_download_rate_limit(-1); M_ses->set_download_rate_limit(-1);
@ -474,10 +484,31 @@ static PyObject *torrent_set_max_half_open(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "i", &arg)) if (!PyArg_ParseTuple(args, "i", &arg))
return NULL; return NULL;
#if defined(_WIN32) #if defined(_WIN32)
DWORD windows_version = ::GetVersion();
if ((windows_version & 0xff) >= 6)
{
// on vista the limit is 5 (in home edition)
if (arg > 4)
{
arg = 4;
}
else if (arg = -1)
{
arg = 4;
}
}
else
{
// on XP SP2 it's 10
if (arg > 8) if (arg > 8)
arg = 4; {
if (arg = -1) arg = 8;
arg = 4; }
else if (arg = -1)
{
arg = 8;
}
}
#endif #endif
M_ses->set_max_half_open_connections(arg); M_ses->set_max_half_open_connections(arg);