Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions dnsperf.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include <events.h>
#include <sock.h>
#include <time.h>


/*
Expand Down Expand Up @@ -415,6 +416,10 @@ int dns_perf_parse_args(int argc, char **argv)
g_query_number = 100000000;
}

// limit the number of concurrent queries to the total number of queries
if ( g_concurrent_query > g_query_number )
g_concurrent_query = g_query_number;

return 0;
}

Expand Down Expand Up @@ -667,13 +672,12 @@ int dns_perf_query_send(void *arg)

int dns_perf_query_recv(void *arg)
{
static u_char input[1024];
//static u_char input[1024];
int ret;
unsigned short id;
unsigned short flags;
query_t *q = arg;


ret = recv(q->fd, q->recv_buf + q->recv_pos, sizeof(q->recv_buf) - q->recv_pos, 0);

if (ret < 0) {
Expand All @@ -692,8 +696,11 @@ int dns_perf_query_recv(void *arg)
close(q->fd);
q->state = F_UNUSED;

id = input[0] * 256 + input[1];
flags = input[2] * 256 + input[3];
//id = input[0] * 256 + input[1];
//flags = input[2] * 256 + input[3];

id = q->recv_buf[0] << 8 | q->recv_buf[1];
flags = q->recv_buf[2] << 8 | q->recv_buf[3];

dns_perf_query_process_response(q, id, flags & 0xF);
}
Expand Down Expand Up @@ -920,12 +927,14 @@ int dns_perf_setup(int argc, char **argv)
int main(int argc, char** argv)
{
timeval_t now, age;

int n_reading;

dns_perf_show_info();
signal(SIGINT, sig_handler);
signal(SIGTERM, sig_handler);

srandom( time( 0 ) );

if (dns_perf_setup(argc, argv) == -1) {
return -1;
}
Expand Down Expand Up @@ -975,6 +984,20 @@ int main(int argc, char** argv)
dns_perf_whip_query();
}

do {
query_t *query;
int i;

dns_perf_eventsys_dispatch(g_timeout);
dns_perf_cancel_timeout_query();

for ( n_reading = i = 0; i < g_concurrent_query ; i++) {
query = &g_query_array[i];
if (query->state == F_READING )
n_reading++;
}
} while ( n_reading > 0 );

gettimeofday(&g_query_end, NULL);

dns_perf_statistic();
Expand Down