Opened 11 years ago
Closed 7 years ago
Last modified 7 years ago
#12034 closed Bug Report - General (fixed)
Ping incorrectly sets the TTL rather than the timeout - setting an http proxy fails
Reported by: | Owned by: | Stuart Auchterlonie | |
---|---|---|---|
Priority: | minor | Milestone: | 29.1 |
Component: | MythTV - General | Version: | Master Head |
Severity: | medium | Keywords: | |
Cc: | Ticket locked: | no |
Description
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
Change History (8)
comment:1 Changed 11 years ago by
comment:3 Changed 7 years ago by
Added a patch at https://github.com/MythTV/mythtv/pull/145 to compile in the correct timeout flag for the operating system.
comment:4 Changed 7 years ago by
Milestone: | unknown → 30.0 |
---|---|
Owner: | set to Stuart Auchterlonie |
Status: | new → accepted |
Version: | Unspecified → Master Head |
comment:5 Changed 7 years ago by
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
comment:8 Changed 7 years ago by
Milestone: | 30.0 → 29.1 |
---|
FreeBSD seems to support the '-t' parameter.
CentOS 6 and Fedora
Windows 7
FreeBSD 9