move the parameter exchange into iperf_run_client() where it belongs; propogate return status
Этот коммит содержится в:
родитель
a067fb27c2
Коммит
e088d2d305
@ -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
|
int
|
||||||
exchange_parameters(struct iperf_test * test)
|
iperf_exchange_parameters(struct iperf_test * test)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
struct iperf_stream *sp;
|
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));
|
//printf(" sending exchange params: size = %d \n", (int) sizeof(struct param_exchange));
|
||||||
result = sp->snd(sp);
|
result = sp->snd(sp);
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
|
{
|
||||||
perror("Error sending exchange params to server");
|
perror("Error sending exchange params to server");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
result = Nread(sp->socket, sp->buffer, sizeof(struct param_exchange), Ptcp);
|
result = Nread(sp->socket, sp->buffer, sizeof(struct param_exchange), Ptcp);
|
||||||
|
|
||||||
if (result < 0)
|
if (result < 0)
|
||||||
|
{
|
||||||
perror("Error getting exchange params ack from server");
|
perror("Error getting exchange params ack from server");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (result > 0 && sp->buffer[0] == ACCESS_DENIED)
|
if (result > 0 && sp->buffer[0] == ACCESS_DENIED)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Busy server Detected. Try again later. Exiting.\n");
|
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)
|
iperf_run_client(struct iperf_test * test)
|
||||||
{
|
{
|
||||||
int i, result = 0;
|
int i, result = 0;
|
||||||
@ -826,6 +835,13 @@ iperf_run_client(struct iperf_test * test)
|
|||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
struct sigaction sact;
|
struct sigaction sact;
|
||||||
|
|
||||||
|
if (iperf_exchange_parameters(test) < 0)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
test->streams->settings->state = STREAM_BEGIN;
|
||||||
|
|
||||||
//printf("in iperf_run_client \n");
|
//printf("in iperf_run_client \n");
|
||||||
tv.tv_sec = 15; /* timeout interval in seconds */
|
tv.tv_sec = 15; /* timeout interval in seconds */
|
||||||
tv.tv_usec = 0;
|
tv.tv_usec = 0;
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* exchange_parameters - handles the param_Exchange part for client
|
* 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
|
* 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
|
* 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
|
* iperf_new_test -- return a new iperf_test with default values
|
||||||
|
10
src/main.c
10
src/main.c
@ -237,13 +237,8 @@ main(int argc, char **argv)
|
|||||||
//printf("in main: calling iperf_init_test \n");
|
//printf("in main: calling iperf_init_test \n");
|
||||||
if (test->role == 'c')
|
if (test->role == 'c')
|
||||||
printf("Connecting to port %d on host %s \n", test->server_port, test->server_hostname);
|
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 */
|
iperf_init_test(test);
|
||||||
{
|
|
||||||
exchange_parameters(test);
|
|
||||||
test->streams->settings->state = STREAM_BEGIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
//printf("in main: calling iperf_run \n");
|
//printf("in main: calling iperf_run \n");
|
||||||
iperf_run(test);
|
iperf_run(test);
|
||||||
@ -271,8 +266,7 @@ iperf_run(struct iperf_test * test)
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
case 'c':
|
case 'c':
|
||||||
iperf_run_client(test);
|
return iperf_run_client(test);
|
||||||
return 0;
|
|
||||||
default:
|
default:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Загрузка…
Ссылка в новой задаче
Block a user