MCPcopy Create free account
hub / github.com/esnet/iperf / iperf_handle_message_server

Function iperf_handle_message_server

src/iperf_server_api.c:238–315  ·  view source on GitHub ↗

/

Source from the content-addressed store, hash-verified

236
237/**************************************************************************/
238int
239iperf_handle_message_server(struct iperf_test *test)
240{
241 int rval;
242 struct iperf_stream *sp;
243
244 if (test->debug_level >= DEBUG_LEVEL_INFO) {
245 iperf_printf(test, "Reading new State from the Client - current state is %d-%s\n", test->state, state_to_text(test->state));
246 }
247
248 // XXX: Need to rethink how this behaves to fit API
249 if ((rval = Nread(test->ctrl_sck, (char*) &test->state, sizeof(signed char), Ptcp)) <= 0) {
250 if (rval == 0) {
251 iperf_err(test, "the client has unexpectedly closed the connection");
252 i_errno = IECTRLCLOSE;
253 iperf_set_test_state(test, IPERF_DONE);
254 return 0;
255 } else {
256 i_errno = IERECVMESSAGE;
257 return -1;
258 }
259 }
260
261 if (test->debug_level >= DEBUG_LEVEL_INFO) {
262 iperf_printf(test, "State change: server received and changed State to %d-%s\n", test->state, state_to_text(test->state));
263 }
264
265 switch(test->state) {
266 case TEST_START:
267 break;
268 case TEST_END:
269 test->done = 1;
270 cpu_util(test->cpu_util);
271 test->stats_callback(test);
272 SLIST_FOREACH(sp, &test->streams, streams) {
273 FD_CLR(sp->socket, &test->read_set);
274 FD_CLR(sp->socket, &test->write_set);
275 close(sp->socket);
276 }
277 test->reporter_callback(test);
278 if (iperf_set_send_state(test, EXCHANGE_RESULTS) != 0)
279 return -1;
280 if (iperf_exchange_results(test) < 0)
281 return -1;
282 if (iperf_set_send_state(test, DISPLAY_RESULTS) != 0)
283 return -1;
284 if (test->on_test_finish)
285 test->on_test_finish(test);
286 break;
287 case IPERF_DONE:
288 break;
289 case CLIENT_TERMINATE:
290 i_errno = IECLIENTTERM;
291
292 // Temporarily be in DISPLAY_RESULTS phase so we can get
293 // ending summary statistics.
294 signed char oldstate = test->state;
295 cpu_util(test->cpu_util);

Callers 1

iperf_run_serverFunction · 0.85

Calls 8

iperf_printfFunction · 0.85
state_to_textFunction · 0.85
NreadFunction · 0.85
iperf_errFunction · 0.85
iperf_set_test_stateFunction · 0.85
cpu_utilFunction · 0.85
iperf_set_send_stateFunction · 0.85
iperf_exchange_resultsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…