| | 1545 | | mxinput(pcbp, nfr) |
| | 1546 | | struct ttpcb *pcbp; |
| | 1547 | | int *nfr; |
| | 1548 | | { |
| | 1549 | | int gotem = 0; |
| | 1550 | | struct frag *fp; |
| | 1551 | | struct frag *fp2; |
| | 1552 | | int n; |
| | 1553 | | int m; |
| | 1554 | | struct pmsg *rxup; |
| | 1555 | | struct pmsg *hdfrgpile; |
| | 1556 | | char *cp; |
| | 1557 | | int src; |
| | 1558 | | int dst; |
| | 1559 | | int ff; |
| | 1560 | | static int fairprobe = 0; |
| | 1561 | | |
| | 1562 | | *nfr = 0; |
| | 1563 | | |
| | 1564 | | |
| | 1565 | | #if defined(IMA_MPP) |
| | 1566 | | |
| | 1567 | | |
| | 1568 | | |
| | 1569 | | |
| | 1570 | | |
| | 1571 | | |
| | 1572 | | switch (fairprobe) |
| | | | ... |
| | 1584 | | if ((fp = pvm_readfrompvmd()) == (struct frag *) NULL) |
| | 1585 | | fp = pvm_readfrompeer(); |
| | 1586 | | break; |
| | 1587 | | |
| | 1588 | | } |
| | 1589 | | |
| | 1590 | | if (!fp) |
| | 1591 | | return gotem; |
| | 1592 | | |
| | 1593 | | #else |
| | 1594 | | if (!pcbp->tt_rxf) |
| | 1595 | | if (!(pcbp->tt_rxf = fr_new(pvmfrgsiz))) |
| | 1596 | | return PvmNoMem;
|
| | 1597 | | fp = pcbp->tt_rxf; |
| | 1598 | | |
| | 1599 | | |
| | 1600 | | |
| | 1601 | | n = (fp->fr_len < TDFRAGHDR) ? 0 : pvmget32(fp->fr_dat + 8);
|
| | 1602 | | n += TDFRAGHDR - fp->fr_len;
|
| | 1603 | | if (pvmdebmask & PDMPACKET) {
|
| | 1604 | | pvmlogprintf("mxinput() pcb t%x fr_len=%d fr_dat=+%d n=%d\n", |
| | 1605 | | pcbp->tt_tid, fp->fr_len, fp->fr_dat - fp->fr_buf, n); |
| | 1606 | | } |
| | 1607 | | #ifndef WIN32 |
| | 1608 | | n = read(pcbp->tt_fd, fp->fr_dat + fp->fr_len, n); |
| | 1609 | | #else |
| | 1610 | | n = win32_read_socket( pcbp->tt_fd,fp->fr_dat+fp->fr_len,n); |
| | 1611 | | #endif |
| | 1612 | | if (pvmdebmask & PDMPACKET) {
|
| | 1613 | | pvmlogprintf("mxinput() read=%d\n", n); |
| | 1614 | | } |
| | 1615 | | |
| | 1616 | | |
| | 1617 | | |
| | 1618 | | if (n == -1 && |
| | 1619 | | #ifndef WIN32 |
| | 1620 | | errno != EWOULDBLOCK &&
|
| | 1621 | | #endif |
| | 1622 | | errno != EINTR)
|
| | 1623 | | { |
| | 1624 | | if (pvmdebmask & PDMPACKET) {
|
| | 1625 | | pvmlogperror("mxinput() read"); |
| | 1626 | | pvmlogprintf("mxinput() t%x\n", pcbp->tt_tid); |
| | 1627 | | } |
| | 1628 | | return PvmSysErr;
|
| | 1629 | | } |
| | 1630 | | if (!n) { |
| | 1631 | | if (pvmdebmask & PDMPACKET) {
|
| | 1632 | | pvmlogprintf("mxinput() t%x read EOF\n", pcbp->tt_tid); |
| | 1633 | | } |
| | 1634 | | return -1; |
| | 1635 | | } |
| | 1636 | | |
| | 1637 | | if (n < 1) |
| | 1638 | | return gotem; |
| | 1639 | | if ((fp->fr_len += n) < TDFRAGHDR)
|
| | 1640 | | return gotem; |
| | 1641 | | |
| | 1642 | | |
| | 1643 | | |
| | 1644 | | m = TDFRAGHDR + pvmget32(fp->fr_dat + 8);
|
| | 1645 | | if (fp->fr_len == TDFRAGHDR) {
|
| | 1646 | | if (m > fp->fr_max - (fp->fr_dat - fp->fr_buf)) { |