int send_done_and_pr_msgs(double total_time, double t_page) { int exit_code1 =0; int exit_code2 =0; int exit_code3 =0; send_all_done_cmd(); /* exit_code1 !=0 if there are files that were not delivered due to change or skipped */ exit_code1 = pr_missing_pages(); fprintf(stderr, "Total time spent = %6.2f (min) ~ %6.2f (min/GB)\n\n", total_time, total_time / ((double)real_total_bytes/1.0e9)); fprintf(stderr, "Send pages time = %6.2f (min) ~ %6.2f (min/GB)\n\n", t_page, t_page / ((double)real_total_bytes/1.0e9)); exit_code2 = choose_print_machines(bad_machines, BAD_MACHINE, "Not synced for bad machines:[ "); if (quitWithOneBad && nBadMachines() >=1) { fprintf(stderr, "We choose to exit when at least one target is bad\n"); fprintf(stderr, "All files following the current one did not get delivered\n"); fprintf(stderr, "If resend cmd(CLOSE_FILE), then the current file may have been delivered to non-bad targets\n\n"); } if (current_entry() < total_entries()) { /* if we exit prematurely */ exit_code3 = choose_print_machines(machine_status, NOT_READY, "\nNot-ready machines:[ "); } if (verbose>=1) pr_rtt_hist(); return (exit_code1+exit_code3); /* 200807 removed exit_code2 because bad machines case has been dealt with by -q. If no -q, then the bad machines are considered 'harmless' */ }
DictionaryValue* DictionaryValue::DeepCopy() const { DictionaryValue* result = new DictionaryValue; for(ValueMap::const_iterator current_entry(dictionary_.begin()); current_entry!=dictionary_.end(); ++current_entry) { result->SetWithoutPathExpansion(current_entry->first, current_entry->second->DeepCopy()); } return result; }
int read_handle_complaint(int cmd) { /* cmd = cmd_code -- each cmd expects different 'response' (complaints) return 1 for complaint handled return 0 for irrelevant complaint return -1 for time-out */ int mid_v, code_v, file_v, npage_v, bytes_read; if (readable(complaint_fd)) { /* There is a complaint */ bytes_read = recvfrom(complaint_fd, flow_buff, FLOW_BUFFSIZE, 0, NULL, NULL); /* 20060323 deal with big- vs little-endian issue convert incoming integers into host representation */ mid_v = ntohl(*mid_ptr); if ((bytes_read < FLOW_HEAD_SIZE) || (mid_v < 0 ) || (mid_v >= (unsigned int) nMachines) || /* boundary check for mid_v for safety */ (bad_machines[mid_v] == BAD_MACHINE)) { /* ignore complaint from a bad machine*/ return 0; } code_v = ntohl(*code_ptr); file_v = ntohl(*file_ptr); npage_v = ntohl(*npage_ptr); /* check if the complaint is for the current file */ if (code_v != MONITOR_OK && file_v != current_entry()) return 0; /* out of seq will be ignored */ if (code_v != MISSING_PAGE && code_v != MISSING_TOTAL) { /********* MISSING_TOTAL ? *************/ if (npage_v <= last_seq[mid_v]) return 0; else last_seq[mid_v] = npage_v; } switch (code_v) { case PAGE_RECV: /******** check if machineID is the one we have set. */ /*if (verbose>=2) fprintf(stderr, "mid_ptr-> %d, monitorid = %d\n", mid_v, monitorID);*/ if (cmd == SENDING_DATA && mid_v == monitorID) return 1; else return 0; case MONITOR_OK: /********* check if machineID is the one we have set. */ if (verbose>=2) fprintf(stderr, "mid_ptr-> %d, monitorid = %d\n", mid_v, monitorID); if (cmd == SELECT_MONITOR_CMD && mid_v == monitorID) return 1; else return 0; case OPEN_OK : if (cmd == OPEN_FILE_CMD) { machine_status[mid_v] = MACHINE_OK; return 1; } else { return 0; } case CLOSE_OK : if (cmd == CLOSE_FILE_CMD || cmd == CLOSE_ABORT_CMD) { machine_status[mid_v] = MACHINE_OK; return 1; } else { return 0; } case EOF_OK : if (cmd == EOF_CMD && file_received[mid_v]==NOT_RECV) { machine_status[mid_v] = MACHINE_OK; file_received[mid_v] = FILE_RECV; return 1; } else { return 0; } case MISSING_PAGE : if (cmd != EOF_CMD || file_received[mid_v]==FILE_RECV) return 0; if (npage_v > nPages) return 0; { int i, *pi, page_v; pi = pArray_ptr; for (i = 0; i<npage_v; ++i) { page_v = ntohl(pi[i]); if (page_v<1 || page_v > nPages) continue; /*** make sure page_v starts with 1*/ missing_page_flag[page_v-1] = MISSING; } } missing_pages[mid_v] += npage_v; set_has_missing(); return 1; case MISSING_TOTAL: if (cmd != EOF_CMD || file_received[mid_v]==FILE_RECV || machine_status[mid_v] == MACHINE_OK) return 0; /* Consider to add: if npage_v >missing_pages[mid_v], ask to resend [ likely no big gain ] */ total_missing_page[mid_v] += npage_v; set_has_missing(); /* store the info about missing info */ machine_status[mid_v] = MACHINE_OK; /* machine_status serves as ack only */ return 1; case SIT_OUT : if (cmd != EOF_CMD || file_received[mid_v]==FILE_RECV) return 0; fprintf(stderr, "*** %s sits-out-receiving %s\n", id2name(mid_v), getFilename()); machine_status[mid_v] = MACHINE_OK; if (!has_sick) ++skip_count; set_has_sick(); return 1; default : if (verbose>=2) fprintf(stderr, "Unknown complaint: code = %d\n", code_v); return 0; } /* end of switch */ } /* end of if(readable) */ /* time out of readable() */ return -1; }