Fix bug in reverse mode.
Этот коммит содержится в:
родитель
78a711169e
Коммит
8bdc8fffcf
@ -34,6 +34,7 @@ main( int argc, char** argv )
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
iperf_defaults( test );
|
||||
iperf_set_verbose( test, 1 );
|
||||
|
||||
/* This main program doesn't use SIGALRM, so the iperf API may use it. */
|
||||
iperf_set_test_may_use_sigalrm(test, 1);
|
||||
@ -41,6 +42,11 @@ main( int argc, char** argv )
|
||||
iperf_set_test_role( test, 'c' );
|
||||
iperf_set_test_server_hostname( test, host );
|
||||
iperf_set_test_server_port( test, port );
|
||||
/* iperf_set_test_reverse( test, 1 ); */
|
||||
iperf_set_test_omit( test, 3 );
|
||||
iperf_set_test_duration( test, 5 );
|
||||
iperf_set_test_reporter_interval( test, 1 );
|
||||
iperf_set_test_stats_interval( test, 1 );
|
||||
|
||||
if ( iperf_run_client( test ) < 0 ) {
|
||||
fprintf( stderr, "%s: error - %s\n", argv0, iperf_strerror( i_errno ) );
|
||||
|
@ -33,6 +33,7 @@ main( int argc, char** argv )
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
iperf_defaults( test );
|
||||
iperf_set_verbose( test, 1 );
|
||||
iperf_set_test_role( test, 's' );
|
||||
iperf_set_test_server_port( test, port );
|
||||
|
||||
|
@ -832,6 +832,44 @@ iperf_init_test(struct iperf_test *test)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
send_timer_proc(TimerClientData client_data, struct timeval *nowP)
|
||||
{
|
||||
struct iperf_stream *sp = client_data.p;
|
||||
|
||||
/* All we do here is set or clear the flag saying that this stream may
|
||||
** be sent to. The actual sending gets done in the send proc, after
|
||||
** checking the flag.
|
||||
*/
|
||||
iperf_check_throttle(sp, nowP);
|
||||
}
|
||||
|
||||
int
|
||||
iperf_create_send_timers(struct iperf_test * test)
|
||||
{
|
||||
struct timeval now;
|
||||
struct iperf_stream *sp;
|
||||
TimerClientData cd;
|
||||
|
||||
if (gettimeofday(&now, NULL) < 0) {
|
||||
i_errno = IEINITTEST;
|
||||
return -1;
|
||||
}
|
||||
SLIST_FOREACH(sp, &test->streams, streams) {
|
||||
sp->green_light = 1;
|
||||
if (test->settings->rate != 0) {
|
||||
cd.p = sp;
|
||||
sp->send_timer = tmr_create((struct timeval*) 0, send_timer_proc, cd, 100000L, 1);
|
||||
/* (Repeat every tenth second - arbitrary often value.) */
|
||||
if (sp->send_timer == NULL) {
|
||||
i_errno = IEINITTEST;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* iperf_exchange_parameters - handles the param_Exchange part for client
|
||||
*
|
||||
@ -1673,7 +1711,6 @@ iperf_print_results(struct iperf_test *test)
|
||||
avg_jitter += sp->jitter;
|
||||
}
|
||||
|
||||
if (bytes_sent > 0) {
|
||||
unit_snprintf(ubuf, UNIT_LEN, (double) bytes_sent, 'A');
|
||||
bandwidth = (double) bytes_sent / (double) end_time;
|
||||
unit_snprintf(nbuf, UNIT_LEN, bandwidth, test->settings->unit_format);
|
||||
@ -1703,8 +1740,6 @@ iperf_print_results(struct iperf_test *test)
|
||||
printf(report_sum_outoforder, start_time, end_time, sp->cnt_error);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bytes_received > 0) {
|
||||
unit_snprintf(ubuf, UNIT_LEN, (double) bytes_received, 'A');
|
||||
bandwidth = (double) bytes_received / (double) end_time;
|
||||
unit_snprintf(nbuf, UNIT_LEN, bandwidth, test->settings->unit_format);
|
||||
@ -1717,7 +1752,6 @@ iperf_print_results(struct iperf_test *test)
|
||||
printf(report_bw_format, sp->socket, start_time, end_time, ubuf, nbuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (test->num_streams > 1) {
|
||||
unit_snprintf(ubuf, UNIT_LEN, (double) total_sent, 'A');
|
||||
|
@ -176,6 +176,7 @@ void warning(char *);
|
||||
int iperf_sum_results(struct iperf_test *);
|
||||
int iperf_exchange_results(struct iperf_test *);
|
||||
int iperf_init_test(struct iperf_test *);
|
||||
int iperf_create_send_timers(struct iperf_test *);
|
||||
int iperf_parse_arguments(struct iperf_test *, int, char **);
|
||||
void iperf_reset_test(struct iperf_test *);
|
||||
void iperf_reset_stats(struct iperf_test * test);
|
||||
|
@ -143,44 +143,6 @@ create_client_omit_timer(struct iperf_test * test)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
send_timer_proc(TimerClientData client_data, struct timeval *nowP)
|
||||
{
|
||||
struct iperf_stream *sp = client_data.p;
|
||||
|
||||
/* All we do here is set or clear the flag saying that this stream may
|
||||
** be sent to. The actual sending gets done in the send proc, after
|
||||
** checking the flag.
|
||||
*/
|
||||
iperf_check_throttle(sp, nowP);
|
||||
}
|
||||
|
||||
static int
|
||||
create_send_timers(struct iperf_test * test)
|
||||
{
|
||||
struct timeval now;
|
||||
struct iperf_stream *sp;
|
||||
TimerClientData cd;
|
||||
|
||||
if (gettimeofday(&now, NULL) < 0) {
|
||||
i_errno = IEINITTEST;
|
||||
return -1;
|
||||
}
|
||||
SLIST_FOREACH(sp, &test->streams, streams) {
|
||||
sp->green_light = 1;
|
||||
if (test->settings->rate != 0) {
|
||||
cd.p = sp;
|
||||
sp->send_timer = tmr_create((struct timeval*) 0, send_timer_proc, cd, 100000L, 1);
|
||||
/* (Repeat every tenth second - arbitrary often value.) */
|
||||
if (sp->send_timer == NULL) {
|
||||
i_errno = IEINITTEST;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
iperf_handle_message_client(struct iperf_test *test)
|
||||
{
|
||||
@ -212,7 +174,8 @@ iperf_handle_message_client(struct iperf_test *test)
|
||||
return -1;
|
||||
if (create_client_omit_timer(test) < 0)
|
||||
return -1;
|
||||
if (create_send_timers(test) < 0)
|
||||
if (!test->reverse)
|
||||
if (iperf_create_send_timers(test) < 0)
|
||||
return -1;
|
||||
break;
|
||||
case TEST_RUNNING:
|
||||
|
@ -135,12 +135,10 @@ iperf_accept(struct iperf_test *test)
|
||||
|
||||
if (iperf_set_send_state(test, PARAM_EXCHANGE) != 0)
|
||||
return -1;
|
||||
if (iperf_exchange_parameters(test) < 0) {
|
||||
if (iperf_exchange_parameters(test) < 0)
|
||||
return -1;
|
||||
}
|
||||
if (test->on_connect) {
|
||||
if (test->on_connect)
|
||||
test->on_connect(test);
|
||||
}
|
||||
} else {
|
||||
/* XXX: Do we even need to receive cookie if we're just going to deny anyways? */
|
||||
if (Nread(s, cookie, COOKIE_SIZE, Ptcp) < 0) {
|
||||
@ -440,6 +438,11 @@ iperf_run_server(struct iperf_test *test)
|
||||
cleanup_server(test);
|
||||
return -1;
|
||||
}
|
||||
if (test->reverse)
|
||||
if (iperf_create_send_timers(test) < 0) {
|
||||
cleanup_server(test);
|
||||
return -1;
|
||||
}
|
||||
if (iperf_set_send_state(test, TEST_RUNNING) != 0) {
|
||||
cleanup_server(test);
|
||||
return -1;
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user