- double bandwidth = updated_size / (clock_post_send - clock_prev_send);
- threshold = get_threshold_value(bandwidth, max_downtime);
- XBT_DEBUG("actual bandwidth %f, threshold %f", bandwidth / 1024 / 1024, threshold);
+ if (sent == updated_size) {
+ /* timeout did not happen */
+ double bandwidth = updated_size / (clock_post_send - clock_prev_send);
+ threshold = get_threshold_value(bandwidth, max_downtime);
+ XBT_DEBUG("actual bandwidth %f, threshold %f", bandwidth / 1024 / 1024, threshold);
+ remaining_size -= sent;
+ stage2_round += 1;
+ mig_timeout -= (clock_post_send - clock_prev_send);
+ xbt_assert(mig_timeout > 0);
+
+ } else if (sent < updated_size) {
+ /* When timeout happens, we move to stage 3. The size of memory pages
+ * updated before timeout must be added to the remaining size. */
+ XBT_INFO("mig-stage2.%d: timeout, force moving to stage 3. sent %llu / %llu, eta %lf",
+ stage2_round, sent, updated_size, (clock_post_send - clock_prev_send));
+ remaining_size -= sent;