508 |
dp->th_opcode = htons ((u_short) DATA); |
dp->th_opcode = htons ((u_short) DATA); |
509 |
dp->th_block = htons ((u_short) block); |
dp->th_block = htons ((u_short) block); |
510 |
timeout = 0; |
timeout = 0; |
511 |
(void) setjmp (timeoutbuf); |
setjmp (timeoutbuf); |
512 |
|
|
513 |
send_data: |
send_data: |
514 |
if (send (peer, (const char *) dp, size + 4, 0) != size + 4) |
if (send (peer, (const char *) dp, size + 4, 0) != size + 4) |
538 |
if ((u_short) ap->th_block == (u_short) block) |
if ((u_short) ap->th_block == (u_short) block) |
539 |
break; |
break; |
540 |
/* Re-synchronize with the other side */ |
/* Re-synchronize with the other side */ |
541 |
(void) synchnet (peer); |
synchnet (peer); |
542 |
if ((u_short) ap->th_block == (u_short) (block - 1)) |
if ((u_short) ap->th_block == (u_short) (block - 1)) |
543 |
goto send_data; |
goto send_data; |
544 |
} |
} |
548 |
} |
} |
549 |
while (size == SEGSIZE); |
while (size == SEGSIZE); |
550 |
abort: |
abort: |
551 |
(void) fclose (file); |
fclose (file); |
552 |
} |
} |
553 |
|
|
554 |
void |
void |
579 |
ap->th_opcode = htons ((u_short) ACK); |
ap->th_opcode = htons ((u_short) ACK); |
580 |
ap->th_block = htons ((u_short) block); |
ap->th_block = htons ((u_short) block); |
581 |
block++; |
block++; |
582 |
(void) setjmp (timeoutbuf); |
setjmp (timeoutbuf); |
583 |
send_ack: |
send_ack: |
584 |
if (send (peer, ackbuf, 4, 0) != 4) |
if (send (peer, ackbuf, 4, 0) != 4) |
585 |
{ |
{ |
608 |
break; /* normal */ |
break; /* normal */ |
609 |
} |
} |
610 |
/* Re-synchronize with the other side */ |
/* Re-synchronize with the other side */ |
611 |
(void) synchnet (peer); |
synchnet (peer); |
612 |
if (dp->th_block == (block - 1)) |
if (dp->th_block == (block - 1)) |
613 |
goto send_ack; /* rexmit */ |
goto send_ack; /* rexmit */ |
614 |
} |
} |
626 |
} |
} |
627 |
while (size == SEGSIZE); |
while (size == SEGSIZE); |
628 |
write_behind (file, pf->f_convert); |
write_behind (file, pf->f_convert); |
629 |
(void) fclose (file); /* close data file */ |
fclose (file); /* close data file */ |
630 |
|
|
631 |
ap->th_opcode = htons ((u_short) ACK); /* send the "final" ack */ |
ap->th_opcode = htons ((u_short) ACK); /* send the "final" ack */ |
632 |
ap->th_block = htons ((u_short) (block)); |
ap->th_block = htons ((u_short) (block)); |
633 |
(void) send (peer, ackbuf, 4, 0); |
send (peer, ackbuf, 4, 0); |
634 |
|
|
635 |
signal (SIGALRM, justquit); /* just quit on timeout */ |
signal (SIGALRM, justquit); /* just quit on timeout */ |
636 |
alarm (rexmtval); |
alarm (rexmtval); |
640 |
dp->th_opcode == DATA && /* and got a data block */ |
dp->th_opcode == DATA && /* and got a data block */ |
641 |
block == dp->th_block) |
block == dp->th_block) |
642 |
{ /* then my last ack was lost */ |
{ /* then my last ack was lost */ |
643 |
(void) send (peer, ackbuf, 4, 0); /* resend final ack */ |
send (peer, ackbuf, 4, 0); /* resend final ack */ |
644 |
} |
} |
645 |
abort: |
abort: |
646 |
return; |
return; |