+UNRELEASED David Schweikert <david@schweikert.ch>
+ * Fix random output on socket error (reported by Aleksandrs Saveljevs, #56)
+
2013-11-08 David Schweikert <david@schweikert.ch>
* Version 3.8
* Fix segmentation fault introduced in version 3.7 with loop mode (reported
/* response time array flags */
#define RESP_WAITING -1
#define RESP_UNUSED -2
+#define RESP_ERROR -3
/* debugging flags */
#if defined( DEBUG ) || defined( _DEBUG )
/* Send the ping */
/*printf("Sending ping after %d ms\n", lt/100); */
- if(!send_ping(s, h)) goto wait_for_reply;
+ send_ping(s, h);
/* Check what needs to be done next */
if(!loop_flag && !count_flag) {
char *buffer;
FPING_ICMPHDR *icp;
int n;
- int myseq;
+ int myseq;
+ int ret = 1;
buffer = ( char* )malloc( ( size_t )ping_pkt_size );
if( !buffer )
&& errno != EHOSTDOWN
#endif
) {
- if( verbose_flag || unreachable_flag )
- {
+ if( verbose_flag || unreachable_flag ) {
printf( "%s", h->host );
if( verbose_flag )
printf( " error while sending ping: %s\n", strerror( errno ) );
printf( "\n" );
-
- }/* IF */
+ }
- h->num_sent++;
- h->num_sent_i++;
- h->waiting++;
- num_pingsent++;
- last_send_time = h->last_send_time;
- free( buffer );
- return(1);
- }
+ if( !loop_flag )
+ h->resp_times[h->num_sent] = RESP_ERROR;
- /* mark this trial as outstanding */
- if( !loop_flag )
- h->resp_times[h->num_sent] = RESP_WAITING;
+ ret = 0;
+ }
+ else {
+ /* mark this trial as outstanding */
+ if( !loop_flag )
+ h->resp_times[h->num_sent] = RESP_WAITING;
#if defined( DEBUG ) || defined( _DEBUG )
- if( sent_times_flag )
- h->sent_times[h->num_sent] = timeval_diff( &h->last_send_time, &start_time );
-#endif /* DEBUG || _DEBUG */
+ if( sent_times_flag )
+ h->sent_times[h->num_sent] = timeval_diff( &h->last_send_time, &start_time );
+#endif
+ }
h->num_sent++;
h->num_sent_i++;
h->waiting++;
num_pingsent++;
last_send_time = h->last_send_time;
-
free( buffer );
- return(1);
+
+ return(ret);
}
{
if( ( this_count >= 0 ) && ( this_count < trials ) )
{
- if( h->resp_times[this_count] != RESP_WAITING )
+ if( h->resp_times[this_count] >= 0 )
{
if( !per_recv_flag )
{