﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc	mlocked
12034	Ping incorrectly sets the TTL rather than the timeout - setting an http proxy fails	Greg Brackley <greg.brackley-mythtv-trac-2014@…>	Stuart Auchterlonie	"The function:
{{{
  bool ping(const QString &host, int timeout) file mythmiscutil.cpp line 220
}}}
has a timeout parameter, but in both the win32 and other code paths it is passed as a TTL parameter.

This means attempts to ping a host more than one hop away will fail. If I run the command manually it fails as I would expect:
{{{
# ping -t 1 -c 1 proxy.lucidsolutions.co.nz
PING proxy.lucidsolutions.co.nz (10.20.5.3) 56(84) bytes of data.
From gbe-12.orange.lucidsolutions.co.nz (10.20.12.1) icmp_seq=1 Time to live exceeded

--- proxy.lucidsolutions.co.nz ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 1ms
}}}

The function: 
{{{
  void setHttpProxy(void), file mythmiscutil.cpp line 831
}}}
uses the ping function to check if the proxy is available. My proxy is on another network.  When I run mythfilldatabase I get the error:

{{{
E  setHttpProxy() - cannot locate host proxy.lucidsolutions.co.nz
                        Please check HTTP_PROXY environment variable!
}}}

I am having this issue with 0.27. The code appears to be the same on master.

== Fix ==

The non-WIN32 ping command is:
{{{
 QString cmd = QString(""ping -t %1 -c 1 %2 >/dev/null 2>&1"")
                  .arg(timeout).arg(host);
}}}

I think the '-t' option should be '-W'.

The WIN32 ping command is:
{{{
    QString cmd = QString(""%systemroot%\\system32\\ping.exe -i %1 -n 1 %2>NUL"")
                  .arg(timeout).arg(host);
}}}
I think it should use the '-w' switch instead of '-i' and convert the 1 second to 1000 milli-seconds.

I believe the current code will appear to work if the proxy is on the same network as the machine running the mythtv code. If the proxy is down, then the intended short timeout behaviour will not be observed.

== Links ==
[https://github.com/MythTV/mythtv/blob/fixes/0.27/mythtv/libs/libmythbase/mythmiscutil.cpp]
[https://github.com/MythTV/mythtv/blob/master/mythtv/libs/libmythbase/mythmiscutil.cpp]"	Bug Report - General	closed	minor	29.1	MythTV - General	Master Head	medium	fixed			0
