@@ -408,7 +408,7 @@ bool performNetPerfMeterStart(MessageReader* messageReader,
408408 }
409409
410410 // ====== Start flows ====================================================
411- const bool success = FlowManager::getFlowManager ()->startMeasurement (
411+ const bool success = FlowManager::getFlowManager ()->beginMeasurement (
412412 controlSocket, measurementID, getMicroTime (),
413413 vectorNamePattern, vectorFileFormat,
414414 scalarNamePattern, scalarFileFormat);
@@ -434,7 +434,7 @@ bool performNetPerfMeterStart(MessageReader* messageReader,
434434 }
435435
436436 LOG_INFO
437- stdlog << format (" Starting Measurement $%llx on socket %d ..." ,
437+ stdlog << format (" Starting measurement $%llx on socket %d ..." ,
438438 (unsigned long long )measurementID, controlSocket) << " \n " ;
439439 LOG_END
440440 if (ext_send (controlSocket, &startMsg, sizeof (startMsg), 0 ) < 0 ) {
@@ -493,7 +493,12 @@ bool performNetPerfMeterStop(MessageReader* messageReader,
493493{
494494 // ====== Stop flows =====================================================
495495 FlowManager::getFlowManager ()->lock ();
496- FlowManager::getFlowManager ()->stopMeasurement (controlSocket, measurementID);
496+ std::vector<Flow*>::iterator iterator = FlowManager::getFlowManager ()->getFlowSet ().begin ();
497+ while (iterator != FlowManager::getFlowManager ()->getFlowSet ().end ()) {
498+ Flow* flow = *iterator;
499+ flow->deactivate (true );
500+ iterator++;
501+ }
497502 Measurement* measurement = FlowManager::getFlowManager ()->findMeasurement (controlSocket,
498503 measurementID);
499504 assure (measurement != nullptr );
@@ -560,8 +565,10 @@ bool performNetPerfMeterStop(MessageReader* messageReader,
560565
561566 // ====== Download flow results and remove the flows =====================
562567 FlowManager::getFlowManager ()->lock ();
563- std::vector<Flow*>::iterator iterator = FlowManager::getFlowManager ()->getFlowSet ().begin ();
564- while (iterator != FlowManager::getFlowManager ()->getFlowSet ().end ()) {
568+
569+ for (std::vector<Flow*>::iterator iterator = FlowManager::getFlowManager ()->getFlowSet ().begin ();
570+ iterator != FlowManager::getFlowManager ()->getFlowSet ().end ();
571+ iterator++) {
565572 Flow* flow = *iterator;
566573 if (flow->getMeasurementID () == measurementID) {
567574 if (sendNetPerfMeterRemoveFlow (messageReader, controlSocket,
@@ -572,13 +579,23 @@ bool performNetPerfMeterStop(MessageReader* messageReader,
572579 LOG_INFO
573580 flow->print (stdlog, true );
574581 LOG_END
582+ }
583+ }
584+
585+ iterator = FlowManager::getFlowManager ()->getFlowSet ().begin ();
586+ while (iterator != FlowManager::getFlowManager ()->getFlowSet ().end ()) {
587+ Flow* flow = *iterator;
588+ if (flow->getMeasurementID () == measurementID) {
589+ flow->deactivate (false );
575590 delete flow;
576- // Invalidated iterator. Is there a better solution?
577591 iterator = FlowManager::getFlowManager ()->getFlowSet ().begin ();
578592 continue ;
579593 }
580594 iterator++;
581595 }
596+
597+ FlowManager::getFlowManager ()->finishMeasurement (controlSocket, measurementID);
598+
582599 FlowManager::getFlowManager ()->unlock ();
583600
584601 // ====== Remove the Measurement object =================================
@@ -850,7 +867,7 @@ static bool handleNetPerfMeterRemoveFlow(MessageReader* me
850867 Flow* flow = FlowManager::getFlowManager ()->findFlow (measurementID, flowID, streamID);
851868 if (flow == nullptr ) {
852869 LOG_WARNING
853- stdlog << format (" NETPERFMETER_ADD_REMOVE tried to remove not-existing flow on socket %d!" ,
870+ stdlog << format (" NETPERFMETER_REMOVE_FLOW tried to remove not-existing flow on socket %d!" ,
854871 controlSocket) << " \n " ;
855872 LOG_END
856873 return (sendNetPerfMeterAcknowledge (controlSocket,
@@ -888,7 +905,7 @@ static bool handleNetPerfMeterStart(MessageReader* messageReade
888905 }
889906 const uint64_t measurementID = ntoh64 (startMsg->MeasurementID );
890907 LOG_INFO
891- stdlog << format (" Starting Measurement $%llx on socket %d ..." ,
908+ stdlog << format (" Starting measurement $%llx on socket %d ..." ,
892909 (unsigned long long )measurementID, controlSocket) << " \n " ;
893910 LOG_END
894911
@@ -908,7 +925,7 @@ static bool handleNetPerfMeterStart(MessageReader* messageReade
908925 }
909926
910927 const unsigned long long now = getMicroTime ();
911- bool success = FlowManager::getFlowManager ()->startMeasurement (
928+ bool success = FlowManager::getFlowManager ()->beginMeasurement (
912929 controlSocket, measurementID, now,
913930 nullptr , vectorFileFormat,
914931 nullptr , scalarFileFormat);
@@ -936,13 +953,13 @@ static bool handleNetPerfMeterStop(MessageReader* messageReader,
936953 }
937954 const uint64_t measurementID = ntoh64 (stopMsg->MeasurementID );
938955 LOG_INFO
939- stdlog << format (" Stopping Measurement $%llx on socket %d ..." ,
956+ stdlog << format (" Stopping measurement $%llx on socket %d ..." ,
940957 (unsigned long long )measurementID, controlSocket) << " \n " ;
941958 LOG_END
942959
943960 // ====== Stop flows =====================================================
944961 FlowManager::getFlowManager ()->lock ();
945- FlowManager::getFlowManager ()-> stopMeasurement (controlSocket, measurementID);
962+
946963 bool success = false ;
947964 Measurement* measurement =
948965 FlowManager::getFlowManager ()->findMeasurement (controlSocket, measurementID);
@@ -960,8 +977,10 @@ static bool handleNetPerfMeterStop(MessageReader* messageReader,
960977 Flow* flow = *iterator;
961978 if (flow->getMeasurement () == measurement) {
962979 flow->setMeasurement (nullptr );
980+ flow->deactivate (true );
963981 }
964982 }
983+ FlowManager::getFlowManager ()->finishMeasurement (controlSocket, measurementID);
965984 FlowManager::getFlowManager ()->unlock ();
966985
967986 // ====== Acknowledge result =============================================
0 commit comments