Timeout for echo ping does not work

Bug #1022870 reported by Daniel
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
echoping (Ubuntu)
New
Undecided
Unassigned

Bug Description

When using echoping for pinging to tcp/7 (echo), and the remote hosts opens the connection but does not answer, the timeout parameter does not work.

== Steps to reproduce ==

Server side:
  sudo nc -l -p 7
  do NOT type anything into it

Client side:
  echoping -t 1 127.0.0.1

Expected result:
  netcat (nc) shows some random data,
  echoping returns after 1 second with exit code 1

What happened instead:
  netcat shows some random data,
  echoping waits forever or until somthing was typed into the netcat console (in my test I waited 12 minutes). In that case, echoping prints "Timeout while reading (2 byte(s) read)" and returns with exit code 1
---
~$ time echoping -t 1 127.0.0.1
Timeout while reading (2 byte(s) read)

real 12m14.953s
user 0m0.000s
sys 0m0.008s
~$ echo $?
1
---

It seems that timeout is only used for connecting, probably also for sending, but not for receiving the answer.

In contrast, pinging to a non-existing host works perfectly:
---
~$ time echoping -t 1 1.1.1.1
Timeout while connecting

real 0m1.006s
user 0m0.004s
sys 0m0.008s
~$ time echoping -t 2 1.1.1.1
Timeout while connecting

real 0m2.006s
user 0m0.000s
sys 0m0.008s
~$
---

Tags: patch
Revision history for this message
Daniel (hackie) wrote :

Sorry, I forgot to mention the version:
Version: 6.0.2-4, and also the latest from git repository

uname -a:
Linux cisgimli 3.2.0-26-generic #41-Ubuntu SMP Thu Jun 14 16:26:01 UTC 2012 i686 i686 i386 GNU/Linux

Revision history for this message
Daniel (hackie) wrote :

See http://stackoverflow.com/questions/384391/how-to-signal-select-to-return-immediately: signal() blocks until it received something from the socket, or until a timeout occours. We can either do the pipe trick as mentioned in the link, or we explicitly set a timeout for the select().

Attached patch does the latter.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "patch which explicitly sets timeout for the select() function" of this bug report has been identified as being a patch. The ubuntu-reviewers team has been subscribed to the bug report so that they can review the patch. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-reviewers team please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]

tags: added: patch
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.