| | 1789 | | mxfer(txup, tmout) |
| | 1790 | | struct pmsg *txup; |
| | 1791 | | struct timeval *tmout; |
| | 1792 | | { |
| | 1793 | | struct ttpcb *txpcbp = 0; |
| | 1794 | | struct frag *txfp = 0; |
| | 1795 | | struct timeval tin; |
| | 1796 | | struct timeval tnow; |
| | 1797 | | struct timeval *tvp; |
| | 1798 | | #ifdef FDSETNOTSTRUCT |
| | 1799 | | fd_set rfds, wfds; |
| | 1800 | | #else |
| | 1801 | | struct fd_set rfds, wfds; |
| | 1802 | | #endif |
| | 1803 | | int wantmore = 1; |
| | 1804 | | int gotem = 0; |
| | 1805 | | int ff; |
| | 1806 | | int n; |
| | 1807 | | #ifdef SOCKLENISUINT |
| | 1808 | | #if defined(IMA_AIX4SP2) || defined(IMA_AIX5SP2) |
| | 1809 | | unsigned int oslen; |
| | 1810 | | #else |
| | 1811 | | size_t oslen; |
| | 1812 | | #endif |
| | 1813 | | #else |
| | 1814 | | int oslen; |
| | 1815 | | #endif |
| | 1816 | | char *txcp = 0; |
| | 1817 | | int txtogo = 0; |
| | 1818 | | struct sockaddr_in sad; |
| | 1819 | | int s; |
| | 1820 | | struct ttpcb *pcbp; |
| | 1821 | | char * = (char *) NULL;
|
| | 1822 | | int inPlaceBodyLen = 0; |
| | 1823 | | int bypassRead = FALSE;
|
| | 1824 | | int waitForOgmToComplete = FALSE;
|
| | 1825 | | int probedForIncomingPkts = FALSE;
|
| | 1826 | | struct msgid *sendmsg = (struct msgid *) NULL;
|
| | 1827 | | char errtxt[64]; |
| | 1828 | | |
| | 1829 | | int nfr = 0, totfr = 0; |
| | 1830 | | int probe = 0; |
| | 1831 | | |
| | 1832 | | if (tmout) |
| | 1833 | | { |
| | 1834 | | pvmgetclock(&tin); |
| | 1835 | | probe = ( tmout -> tv_sec == 0 && tmout -> tv_usec == 0); |
| | 1836 | | } |
| | 1837 | | |
| | 1838 | | if (txup) { |
| | 1839 | | txfp = txup->m_frag->fr_link; |
| | 1840 | | if (!txfp->fr_buf) { |
| | 1841 | | if (!(txfp = fr_new(MAXHDR)))
|
| | 1842 | | return PvmNoMem;
|
| | 1843 | | txfp->fr_dat += MAXHDR;
|
| | 1844 | | LISTPUTBEFORE(txup->m_frag, txfp, fr_link, fr_rlink);
|
| | 1845 | | } |
| | 1846 | | |
| | 1847 | | if (!(txpcbp = ttpcb_find(txup->m_dst)) || txpcbp->tt_state != TTOPEN)
|
| | 1848 | | txpcbp = topvmd; |
| | 1849 | | txup->m_ref++; |
| | 1850 | | bypassRead = TRUE;
|
| | 1851 | | } |
| | 1852 | | |
| | 1853 | | if (pvmdebmask & PDMMESSAGE) {
|
| | 1854 | | pvmlogprintf("mxfer() mid %d", (txup ? txup->m_mid : 0)); |
| | 1855 | | if (txup) |
| | 1856 | | pvmlogprintf(" ctx %d tag %s dst t%x route t%x", |
| | 1857 | | txup->m_ctx, |
| | 1858 | | pvmnametag(txup->m_tag, (int *)0), |
| | 1859 | | txup->m_dst, txpcbp->tt_tid); |
| | 1860 | | if (tmout) |
| | 1861 | | pvmlogprintf(" tmout %d.%06d\n", |
| | 1862 | | tmout->tv_sec, tmout->tv_usec); |
| | 1863 | | else |
| | | | ... |
| | 1872 | | |
| | 1873 | | |
| | 1874 | | |
| | 1875 | | |
| | 1876 | | |
| | 1877 | | |
| | 1878 | | |
| | 1879 | | |
| | 1880 | | |
| | 1881 | | |
| | 1882 | | while (txfp || topvmd->tt_rxf || wantmore || waitForOgmToComplete |
| | 1883 | | || !probedForIncomingPkts |
| | 1884 | | ) |
| | 1885 | | { |
| | 1886 | | |
| | 1887 | | totfr = 0; |
| | 1888 | | |
| | 1889 | | |
| | 1890 | | if (txfp || topvmd->tt_rxf) |
| | 1891 | | { |
| | 1892 | | |
| | 1893 | | tvp = (struct timeval *) NULL;
|
| | 1894 | | |
| | 1895 | | } |
| | 1896 | | else |
| | 1897 | | { |
| | 1898 | | if (wantmore) |
| | 1899 | | { |
| | 1900 | | |
| | 1901 | | |
| | 1902 | | |
| | 1903 | | |
| | 1904 | | |
| | 1905 | | |
| | 1906 | | if (tmout) |
| | 1907 | | { |
| | 1908 | | pvmgetclock(&tnow); |
| | 1909 | | TVXSUBY(&tnow, &tnow, &tin);
|
| | 1910 | | if (TVXLTY(tmout, &tnow))
|
| | 1911 | | { |
| | 1912 | | TVCLEAR(&tnow);
|
| | 1913 | | wantmore = 0; |
| | 1914 | | } |
| | 1915 | | else |
| | 1916 | | { |
| | 1917 | | TVXSUBY(&tnow, tmout, &tnow);
|
| | 1918 | | } |
| | 1919 | | tvp = &tnow; |
| | 1920 | | } |
| | 1921 | | else |
| | 1922 | | { |
| | 1923 | | tvp = (struct timeval *) NULL;
|
| | 1924 | | } |
| | 1925 | | |
| | 1926 | | } |
| | 1927 | | else |
| | 1928 | | { |
| | 1929 | | TVCLEAR(&tnow);
|
| | 1930 | | tvp = &tnow; |
| | 1931 | | } |
| | 1932 | | } |
| | 1933 | | |
| | 1934 | | |
| | 1935 | | |
| | 1936 | | |
| | 1937 | | |
| | 1938 | | |
| | 1939 | | #if !defined(IMA_MPP) |
| | 1940 | | rfds = pvmrfds; |
| | 1941 | | FD_ZERO(&wfds);
|
| | 1942 | | if (txfp) |
| | 1943 | | FD_SET(txpcbp->tt_fd, &wfds);
|
| | 1944 | | #endif |
| | 1945 | | |
| | 1946 | | if (pvmdebmask & PDMSELECT) {
|
| | 1947 | | if (tvp) |
| | 1948 | | pvmlogprintf("mxfer() select timeout %d.%06d\n", |
| | 1949 | | tvp->tv_sec, tvp->tv_usec); |
| | 1950 | | else |
| | 1951 | | pvmlogprintf("mxfer() select timeout inf\n"); |
| | 1952 | | #if !defined(IMA_MPP) |
| | 1953 | | print_fdset("mxfer() rfds=", pvmnfds, &rfds); |
| | 1954 | | print_fdset("mxfer() wfds=", pvmnfds, &wfds); |
| | 1955 | | #endif |
| | 1956 | | } |
| | 1957 | | |
| | 1958 | | #if !defined(IMA_MPP) |
| | 1959 | | probedForIncomingPkts = TRUE;
|
| | 1960 | | if ((n = select(pvmnfds, |
| | 1961 | | #ifdef FDSETISINT |
| | 1962 | | (int *)&rfds, (int *)&wfds, (int *)0, |
| | 1963 | | #else |
| | 1964 | | (fd_set *)&rfds, (fd_set *)&wfds, (fd_set*)0, |
| | 1965 | | #endif |
| | 1966 | | tvp)) == -1 |
| | 1967 | | && errno != EINTR
|
| | 1968 | | #ifdef IMA_LINUX |
| | 1969 | | && errno != EAGAIN
|
| | 1970 | | #endif |
| | 1971 | | ) { |
| | 1972 | | pvmlogperror("mxfer() select"); |
| | 1973 | | return PvmSysErr;
|
| | 1974 | | } |
| | 1975 | | if (pvmdebmask & PDMSELECT) {
|
| | 1976 | | pvmlogprintf("mxfer() select returns %d\n", n); |
| | 1977 | | } |
| | 1978 | | if (n == -1) |
| | 1979 | | continue; |
| | 1980 | | |
| | 1981 | | |
| | 1982 | | |
| | 1983 | | |
| | 1984 | | if (FD_ISSET(topvmd->tt_fd, &rfds)
|
| | 1985 | | && !(mxfersingle && gotem)) |
| | 1986 | | { |
| | 1987 | | if ((n = mxinput(topvmd, &nfr)) < 0) { |
| | 1988 | | if (n != -1) |
| | 1989 | | pvmlogerror("mxfer() mxinput bad return on pvmd sock\n"); |
| | 1990 | | else if (pvmdebmask & (PDMSELECT|PDMMESSAGE|PDMPACKET))
|
| | 1991 | | pvmlogerror("mxfer() EOF on pvmd sock\n"); |
| | 1992 | | return PvmSysErr;
|
| | 1993 | | } |
| | 1994 | | |
| | 1995 | | totfr += nfr; |
| | 1996 | | if (gotem += n) |
| | 1997 | | wantmore = 0; |
| | 1998 | | } |
| | 1999 | | |
| | 2000 | | |
| | 2001 | | |
| | 2002 | | |
| | 2003 | | |
| | 2004 | | |
| | 2005 | | |
| | 2006 | | |
| | 2007 | | |
| | 2008 | | |
| | 2009 | | for (pcbp = ttlist->tt_link; pcbp != ttlist; pcbp = pcbp->tt_link) { |
| | 2010 | | if (pcbp->tt_state == TTOPEN && FD_ISSET(pcbp->tt_fd, &rfds)) {
|
| | 2011 | | if ((n = mxinput(pcbp, &nfr)) < 0) |
| | 2012 | | ttpcb_dead(pcbp); |
| | 2013 | | |
| | 2014 | | else { |
| | 2015 | | totfr += nfr; |
| | 2016 | | if (gotem += n) |
| | 2017 | | wantmore = 0; |
| | 2018 | | } |
| | 2019 | | |
| | 2020 | | } else |
| | 2021 | | if (pcbp->tt_state == TTGRNWAIT
|
| | 2022 | | && FD_ISSET(pcbp->tt_fd, &rfds)) {
|
| | 2023 | | oslen = sizeof(sad); |
| | 2024 | | s = accept(pcbp->tt_fd, (struct sockaddr*)&sad, &oslen); |
| | 2025 | | if (s == -1) { |
| | 2026 | | pvmlogperror("mxfer() accept"); |
| | 2027 | | ttpcb_dead(pcbp); |
| | 2028 | | |
| | 2029 | | } else { |
| | 2030 | | #ifndef NOSOCKOPT |
| | 2031 | | #ifndef NOUNIXDOM |
| | 2032 | | if (!pcbp->tt_spath) { |
| | 2033 | | #endif |
| | 2034 | | n = 1; |
| | 2035 | | if (setsockopt(s, IPPROTO_TCP, TCP_NODELAY,
|
| | 2036 | | (char*)&n, sizeof(int)) == -1) |
| | 2037 | | pvmlogperror("mxfer() setsockopt"); |
| | 2038 | | #if (!defined(IMA_RS6K)) \ |
| | 2039 | | && (!defined(IMA_AIX46K)) && (!defined(IMA_AIX46K64)) \ |
| | 2040 | | && (!defined(IMA_AIX56K)) && (!defined(IMA_AIX56K64)) |
| | 2041 | | n = TTSOCKBUF;
|
| | 2042 | | if (setsockopt(s, SOL_SOCKET, SO_SNDBUF,
|
| | 2043 | | (char*)&n, sizeof(int)) == -1 |
| | 2044 | | || setsockopt(s, SOL_SOCKET, SO_RCVBUF,
|
| | 2045 | | (char*)&n, sizeof(n)) == -1) |
| | 2046 | | pvmlogperror( |
| | 2047 | | "mxfer() setsockopt SO_SNDBUF"); |
| | 2048 | | #endif |
| | 2049 | | #ifndef NOUNIXDOM |
| | 2050 | | } |
| | 2051 | | #endif |
| | 2052 | | #endif |
| | 2053 | | if (pvmdebmask & PDMROUTE) {
|
| | 2054 | | pvmlogprintf("mxfer() accept from t%x = %d\n", |
| | 2055 | | pcbp->tt_tid, s); |
| | 2056 | | } |
| | 2057 | | (void)close(pcbp->tt_fd); |
| | 2058 | | |
| | 2059 | | |
| | 2060 | | |
| | 2061 | | |
| | 2062 | | pvm_fd_delete(pcbp->tt_fd, 1); |
| | 2063 | | |
| | 2064 | | |
| | 2065 | | |