Merge pull request #77 from runderwo/unmalloc

Remove heap manipulation from fast path.
pull/88/head
David Schweikert 10 years ago
commit 8fc9fa37c7

@ -259,6 +259,7 @@ unsigned int perhost_interval = DEFAULT_PERHOST_INTERVAL * 100;
float backoff = DEFAULT_BACKOFF_FACTOR;
unsigned int ping_data_size = DEFAULT_PING_DATA_SIZE;
unsigned int ping_pkt_size;
char *ping_buffer;
unsigned int count = 1;
unsigned int trials;
unsigned int report_interval = 0;
@ -822,6 +823,9 @@ int main( int argc, char **argv )
}/* FOR */
ping_pkt_size = ping_data_size + SIZE_ICMP_HDR;
ping_buffer = ( char* )malloc( ( size_t )ping_pkt_size );
if( !ping_buffer )
crash_and_burn( "can't malloc ping packet" );
signal( SIGINT, finish );
@ -1398,24 +1402,19 @@ void print_global_stats( void )
int send_ping( int s, HOST_ENTRY *h )
{
char *buffer;
FPING_ICMPHDR *icp;
int n;
int myseq;
int ret = 1;
buffer = ( char* )malloc( ( size_t )ping_pkt_size );
if( !buffer )
crash_and_burn( "can't malloc ping packet" );
if (random_data_flag) {
for (n = 0; n < ping_pkt_size; ++n) {
buffer[n] = random() & 0xFF;
ping_buffer[n] = random() & 0xFF;
}
} else {
memset( buffer, 0, ping_pkt_size * sizeof( char ) );
memset( ping_buffer, 0, ping_pkt_size * sizeof( char ) );
}
icp = ( FPING_ICMPHDR* )buffer;
icp = ( FPING_ICMPHDR* )ping_buffer;
gettimeofday( &h->last_send_time, &tz );
myseq = seqmap_add(h->i, h->num_sent, &h->last_send_time);
@ -1441,7 +1440,7 @@ int send_ping( int s, HOST_ENTRY *h )
printf( "sending [%d] to %s\n", h->num_sent, h->host );
#endif /* DEBUG || _DEBUG */
n = sendto( s, buffer, ping_pkt_size, 0,
n = sendto( s, ping_buffer, ping_pkt_size, 0,
( struct sockaddr* )&h->saddr, sizeof( FPING_SOCKADDR ) );
if(
@ -1475,7 +1474,6 @@ int send_ping( int s, HOST_ENTRY *h )
h->waiting++;
num_pingsent++;
last_send_time = h->last_send_time;
free( buffer );
return(ret);
}

Loading…
Cancel
Save