int modifypacket(struct packet *pakt,struct reroutetab *rrt,struct kludges *kl) { struct msglist *walkmsg; struct fidaddr chg; printmsg(3,"ModifyPacket\n"); /* Change the packet header origin address */ chg.Zone=unsplit(pakt->pkh.origZone); chg.Net=unsplit(pakt->pkh.origNet); chg.Node=unsplit(pakt->pkh.origNode); chg.Point=0; dochange(&chg,rrt->orgroot); split(pakt->pkh.origZone,chg.Zone); split(pakt->pkh.origNet,chg.Net); split(pakt->pkh.origNode,chg.Node); /* Change the packet header destination address */ chg.Zone=unsplit(pakt->pkh.destZone); chg.Net=unsplit(pakt->pkh.destNet); chg.Node=unsplit(pakt->pkh.destNode); chg.Point=0; dochange(&chg,rrt->dstroot); split(pakt->pkh.destZone,chg.Zone); split(pakt->pkh.destNet,chg.Net); split(pakt->pkh.destNode,chg.Node); /* Change all packed messages */ walkmsg=pakt->root; while(walkmsg!=NULL) { /* Change message origin */ chg.Zone=0; chg.Net=unsplit(walkmsg->pmsg.origNet); chg.Node=unsplit(walkmsg->pmsg.origNode); chg.Point=0; dochange(&chg,rrt->orgroot); split(walkmsg->pmsg.origNet,chg.Net); split(walkmsg->pmsg.origNode,chg.Node); /* Change message destination */ chg.Zone=0; chg.Net=unsplit(walkmsg->pmsg.destNet); chg.Node=unsplit(walkmsg->pmsg.destNode); chg.Point=0; dochange(&chg,rrt->dstroot); split(walkmsg->pmsg.destNet,chg.Net); split(walkmsg->pmsg.destNode,chg.Node); /* Change seenby line, path kludge and origin line */ changeseenby(&(walkmsg->Text),rrt->dstroot); changekludge(&(walkmsg->Text),kl->root,rrt); changeorigin(&(walkmsg->Text),rrt->orgroot); changetearline(&(walkmsg->Text)); walkmsg=walkmsg->next; } return(0); }
/** search_maintenance(): In every node during a search, do some checks for SMP events, timeout, etc. If the search needs to exit, we store the return value in return_value and return TRUE, otherwise we return FALSE. Created 031609; last modified 031609 **/ BOOL search_maintenance(SEARCH_BLOCK **sb, VALUE *return_value) { #ifdef SMP int r; /* Handle any asynchronous messages we have. */ if (smp_block[board.id].message_count) handle_smp_messages(sb); /* Check for synchronous messages, and exit if necessary. */ if (smp_block[board.id].input) { if (handle_smp_input(*sb)) { *return_value = 0; return TRUE; } } /* If another processor has backed up to the root, they set a flag because only the main processor can return to search_root(). */ if (board.id == 0 && smp_data->return_flag) { ASSERT(board.split_point == board.split_point_stack); ASSERT(smp_data->split_count == 0); /* Back up the game board. */ while (board.game_entry > root_entry + 1) unmake_move(); /* This is kind of hacky... */ if (board.game_entry == root_entry) make_move((zct->next_root_move - 1)->move); SMP_DEBUG(print("cpu 0 returning...\n%B",&board)); smp_data->return_flag = FALSE; set_active(); /* Return the score and PV. */ copy_pv(board.pv_stack[1], smp_data->return_pv); *return_value = smp_data->return_value; return TRUE; } #endif /* Do the standard periodic check for time or input. */ if (search_check()) { #ifdef SMP /* Flag the other processors down. */ for (r = 1; r < zct->process_count; r++) smp_tell(r, SMP_PARK, 0); /* Unsplit all of our split points, after waiting for the child processors to detach. */ while (*board.split_point != NULL) { while ((*board.split_point)->child_count > 1) ; unsplit(*sb, (*board.split_point)->id); } #endif /* We're good to go. Stop the search. */ while (board.game_entry > root_entry + 1) unmake_move(); /* This is kind of hacky... */ if (board.game_entry == root_entry) make_move((zct->next_root_move - 1)->move); /* Return a really good score, so the root move appears to be a mated-in-0. This just invalidates the score. */ *return_value = MATE; return TRUE; } return FALSE; }