Opened 12 years ago
Closed 9 years ago
Last modified 9 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 by , 12 years ago
comment:3 by , 9 years ago
Added a patch at https://github.com/MythTV/mythtv/pull/145 to compile in the correct timeout flag for the operating system.
comment:4 by , 9 years ago
| Milestone: | unknown → 30.0 |
|---|---|
| Owner: | set to |
| Status: | new → accepted |
| Version: | Unspecified → Master Head |
comment:5 by , 9 years ago
| Resolution: | → fixed |
|---|---|
| Status: | accepted → closed |
comment:8 by , 9 years ago
| Milestone: | 30.0 → 29.1 |
|---|

FreeBSD seems to support the '-t' parameter.
CentOS 6 and Fedora
Usage: ping [-LRUbdfnqrvVaA] [-c count] [-i interval] [-w deadline] [-p pattern] [-s packetsize] [-t ttl] [-I interface or address] [-M mtu discovery hint] [-S sndbuf] [ -T timestamp option ] [ -Q tos ] [hop1 ...] destinationWindows 7
Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS] [-r count] [-s count] [[-j host-list] | [-k host-list]] [-w timeout] [-R] [-S srcaddr] [-4] [-6] target_name Options: -t Ping the specified host until stopped. To see statistics and continue - type Control-Break; To stop - type Control-C. -a Resolve addresses to hostnames. -n count Number of echo requests to send. -l size Send buffer size. -f Set Don't Fragment flag in packet (IPv4-only). -i TTL Time To Live. -v TOS Type Of Service (IPv4-only. This setting has been deprecated and has no effect on the type of service field in the IP Header). -r count Record route for count hops (IPv4-only). -s count Timestamp for count hops (IPv4-only). -j host-list Loose source route along host-list (IPv4-only). -k host-list Strict source route along host-list (IPv4-only). -w timeout Timeout in milliseconds to wait for each reply. -R Use routing header to test reverse route also (IPv6-only). -S srcaddr Source address to use. -4 Force using IPv4. -6 Force using IPv6.FreeBSD 9
usage: ping [-AaDdfnoQqRrv] [-c count] [-G sweepmaxsize] [-g sweepminsize] [-h sweepincrsize] [-i wait] [-l preload] [-M mask | time] [-m ttl] [-P policy] [-p pattern] [-S src_addr] [-s packetsize] [-t timeout] [-W waittime] [-z tos] host ping [-AaDdfLnoQqRrv] [-c count] [-I iface] [-i wait] [-l preload] [-M mask | time] [-m ttl] [-P policy] [-p pattern] [-S src_addr] [-s packetsize] [-T ttl] [-t timeout] [-W waittime] [-z tos] mcast-group