1
1

move the parameter exchange into iperf_run_client() where it belongs; propogate return status

Этот коммит содержится в:
Jon Dugan 2010-02-09 07:29:13 +00:00
родитель a067fb27c2
Коммит e088d2d305
3 изменённых файлов: 26 добавлений и 16 удалений

Просмотреть файл

@ -82,12 +82,12 @@ all_data_sent(struct iperf_test * test)
/*********************************************************/
/**
* exchange_parameters - handles the param_Exchange part for client
* iperf_exchange_parameters - handles the param_Exchange part for client
*
*/
void
exchange_parameters(struct iperf_test * test)
int
iperf_exchange_parameters(struct iperf_test * test)
{
int result;
struct iperf_stream *sp;
@ -112,17 +112,26 @@ exchange_parameters(struct iperf_test * test)
//printf(" sending exchange params: size = %d \n", (int) sizeof(struct param_exchange));
result = sp->snd(sp);
if (result < 0)
{
perror("Error sending exchange params to server");
return -1;
}
result = Nread(sp->socket, sp->buffer, sizeof(struct param_exchange), Ptcp);
if (result < 0)
{
perror("Error getting exchange params ack from server");
return -1;
}
if (result > 0 && sp->buffer[0] == ACCESS_DENIED)
{
fprintf(stderr, "Busy server Detected. Try again later. Exiting.\n");
exit(-1);
return -1;
}
return;
return 0;
}
/*************************************************************/
@ -814,7 +823,7 @@ catcher(int sig)
}
/**************************************************************************/
void
int
iperf_run_client(struct iperf_test * test)
{
int i, result = 0;
@ -826,6 +835,13 @@ iperf_run_client(struct iperf_test * test)
struct timeval tv;
struct sigaction sact;
if (iperf_exchange_parameters(test) < 0)
{
return -1;
}
test->streams->settings->state = STREAM_BEGIN;
//printf("in iperf_run_client \n");
tv.tv_sec = 15; /* timeout interval in seconds */
tv.tv_usec = 0;

Просмотреть файл

@ -14,7 +14,7 @@
* exchange_parameters - handles the param_Exchange part for client
*
*/
void exchange_parameters(struct iperf_test * test);
int iperf_exchange_parameters(struct iperf_test * test);
/**
* add_to_interval_list -- adds new interval to the interval_list
@ -80,7 +80,7 @@ char *iperf_reporter_callback(struct iperf_test * test);
* iperf_run_client -- Runs the client portion of a test
*
*/
void iperf_run_client(struct iperf_test * test);
int iperf_run_client(struct iperf_test * test);
/**
* iperf_new_test -- return a new iperf_test with default values

Просмотреть файл

@ -237,13 +237,8 @@ main(int argc, char **argv)
//printf("in main: calling iperf_init_test \n");
if (test->role == 'c')
printf("Connecting to port %d on host %s \n", test->server_port, test->server_hostname);
iperf_init_test(test);
if (test->role == 'c') /* if client, send params to server */
{
exchange_parameters(test);
test->streams->settings->state = STREAM_BEGIN;
}
iperf_init_test(test);
//printf("in main: calling iperf_run \n");
iperf_run(test);
@ -271,8 +266,7 @@ iperf_run(struct iperf_test * test)
}
return 0;
case 'c':
iperf_run_client(test);
return 0;
return iperf_run_client(test);
default:
return -1;
}