X-Git-Url: http://sjero.net/git/?p=iperf;a=blobdiff_plain;f=src%2FReporter.c;h=e34763ec99915ffdd145f02f26afa7e4febe2d23;hp=73143b33b7e268df04b89baaa1a9f0640e2270eb;hb=160c6a5bab3ab731f5b1ad8bc174e7d087ca7acb;hpb=13e2957cedb002750f49045e221375ffff3d5ee3 diff --git a/src/Reporter.c b/src/Reporter.c index 73143b3..e34763e 100644 --- a/src/Reporter.c +++ b/src/Reporter.c @@ -111,6 +111,7 @@ report_statistics multiple_reports[kReport_MAXIMUM] = { char buffer[64]; // Buffer for printing ReportHeader *ReportRoot = NULL; extern Condition ReportCond; +extern Condition ReportDoneCond; int reporter_process_report ( ReportHeader *report ); void process_report ( ReportHeader *report ); int reporter_handle_packet( ReportHeader *report ); @@ -338,7 +339,7 @@ void ReportPacket( ReportHeader* agent, ReportStruct *packet ) { // item while ( index == 0 ) { Condition_Signal( &ReportCond ); - thread_rest(); + Condition_Wait( &ReportDoneCond ); index = agent->reporterindex; } agent->agentindex = 0; @@ -346,7 +347,7 @@ void ReportPacket( ReportHeader* agent, ReportStruct *packet ) { // Need to make sure that reporter is not about to be "lapped" while ( index - 1 == agent->agentindex ) { Condition_Signal( &ReportCond ); - thread_rest(); + Condition_Wait( &ReportDoneCond ); index = agent->reporterindex; } @@ -553,6 +554,7 @@ void reporter_spawn( thread_Settings *thread ) { } Condition_Unlock ( ReportCond ); +again: if ( ReportRoot != NULL ) { ReportHeader *temp = ReportRoot; //Condition_Unlock ( ReportCond ); @@ -575,9 +577,12 @@ void reporter_spawn( thread_Settings *thread ) { // finished with report so free it free( temp ); Condition_Unlock ( ReportCond ); + Condition_Signal( &ReportDoneCond ); + if (ReportRoot) + goto again; } - // yield control of CPU is another thread is waiting - thread_rest(); + Condition_Signal( &ReportDoneCond ); + usleep(10000); } else { //Condition_Unlock ( ReportCond ); }