| | 1696 | | work() | | | 1697 | | { | | | 1698 | | static int lastpinged = 0; | | | 1699 | | #ifdef FDSETNOTSTRUCT | | | 1700 | | fd_set rfds, wfds; | | | 1701 | | | | | 1702 | | #else | | | 1703 | | struct fd_set rfds, wfds; | | | 1704 | | | | | 1705 | | #endif | | | 1706 | | int nrdy; | | | | | ... | | | 1718 | | double tbpl; | | | 1719 | | double toutpl; | | | 1720 | | int timed_out; | | | 1721 | | extern double dclock(); | | | 1722 | | #endif | | | 1723 | | #endif | | | 1724 | | #ifdef SHMEM | | | 1725 | | int someclosed; | | | 1726 | | #endif | | | 1727 | | | | | 1728 | | gettimeofday(&tnow, (struct timezone*)0); | | | 1729 | | if (pvmdebmask || myhostpart) { | | | 1730 | | PVM_TIMET time_temp;
| | | 1731 | | pvmlogprintf("%s (%s) %s %s\n", | | | 1732 | | hosts->ht_hosts[hosts->ht_local]->hd_name, | | | 1733 | | inadport_decimal(&hosts->ht_hosts[hosts->ht_local]->hd_sad), | | | 1734 | | myarchname, | | | 1735 | | PVM_VER);
| | | 1736 | | pvmlogprintf("ready "); | | | 1737 | | time_temp = (PVM_TIMET) tnow.tv_sec;
| | | 1738 | | pvmlogprintf(ctime(&time_temp)); | | | 1739 | | } | | | 1740 | | | | | 1741 | | | | | 1742 | | | | | 1743 | | | | | 1744 | | | | | 1745 | | | | | 1746 | | if ( myhostpart ) { | | | 1747 | | char *av[5]; | | | 1748 | | char *buf; | | | 1749 | | char *cmd; | | | 1750 | | int ac; | | | 1751 | | int i; | | | 1752 | | | | | 1753 | | for ( i=0 ; modulenames[i] ; i++ ) { | | | 1754 | | cmd = getenv( modulenames[i] ); | | | 1755 | | if ( cmd != NULL )
| | | 1756 | | { | | | | | ... | | | 1765 | | } | | | 1766 | | if (buf) PVM_FREE( buf );
| | | 1767 | | } | | | 1768 | | } | | | 1769 | | } | | | 1770 | | | | | 1771 | | | | | 1772 | | | | | 1773 | | | | | 1774 | | | | | 1775 | | if (addmesg) { | | | 1776 | | struct pmsg *mp = addmesg; | | | 1777 | | | | | 1778 | | addmesg = 0; | | | 1779 | | sendmessage(mp); | | | 1780 | | } | | | 1781 | | | | | 1782 | | | | | 1783 | | | | | 1784 | | | | | 1785 | | | | | 1786 | | pvmgetclock(&tnow); | | | 1787 | | tout.tv_sec = DDBAILTIME;
| | | 1788 | | tout.tv_usec = 0; | | | 1789 | | TVXADDY(&tbail, &tnow, &tout);
| | | 1790 | | | | | 1791 | | tout.tv_sec = DDPINGTIME;
| | | 1792 | | tout.tv_usec = 0; | | | 1793 | | TVXADDY(&tping, &tnow, &tout);
| | | 1794 | | | | | 1795 | | | | | 1796 | | | | | 1797 | | wrk_fds_init(); | | | 1798 | | | | | 1799 | | if (loclsock >= 0) | | | 1800 | | wrk_fds_add(loclsock, 1); | | | 1801 | | wrk_fds_add(netsock, 1); | | | 1802 | | | | | 1803 | | for (; ; ) { | | | 1804 | | | | | 1805 | | | | | 1806 | | | | | 1807 | | | | | 1808 | | #ifdef IMA_BEOSCYLD | | | 1809 | | reap(SIGCLD); | | | 1810 | | #endif | | | 1811 | | while (rdead != wdead) { | | | 1812 | | if (deads[rdead].dd_pid == pprime) { | | | 1813 | | int cc; | | | 1814 | | #ifdef SOCKLENISUINT | | | 1815 | | #if defined(IMA_AIX4SP2) || defined(IMA_AIX5SP2) \ | | | 1816 | | || defined(IMA_AIX56K64) || defined(IMA_LINUXALPHA) | | | 1817 | | unsigned int oslen; | | | 1818 | | #else | | | 1819 | | size_t oslen; | | | 1820 | | #endif | | | 1821 | | #else | | | 1822 | | int oslen; | | | 1823 | | #endif | | | 1824 | | struct sockaddr_in osad; | | | 1825 | | struct timeval t; | | | 1826 | | char buf[DDFRAGHDR];
| | | 1827 | | | | | 1828 | | hostfailentry(hosts->ht_hosts[0]); |
| | 1830 | | pprime = 0; | | | 1831 | | | | | 1832 | | while (1) { | | | 1833 | | FD_ZERO(&rfds);
| | | 1834 | | FD_SET(ppnetsock, &rfds);
| | | 1835 | | t.tv_sec = 0; | | | 1836 | | t.tv_usec = 0; | | | 1837 | | cc = select(ppnetsock + 1, | | | 1838 | | #ifdef FDSETISINT | | | 1839 | | (int *)&rfds, (int *)0, (int *)0, | | | 1840 | | #else | | | 1841 | | (fd_set *)&rfds, (fd_set *)0, (fd_set *)0, | | | 1842 | | #endif | | | 1843 | | &t); | | | 1844 | | if (cc == 1) { | | | 1845 | | oslen = sizeof(osad); | | | 1846 | | recvfrom(ppnetsock, buf, sizeof(buf), | | | 1847 | | 0, (struct sockaddr*)&osad, &oslen); | | | 1848 | | | | | 1849 | | } else if (cc != -1 || errno != EINTR)
| | | 1850 | | break; | | | 1851 | | } | | | 1852 | | | | | 1853 | | } else { | | | 1854 | | if (tp = task_findpid(deads[rdead].dd_pid)) { | | | 1855 | | | | | 1856 | | | | | 1857 | | | | | 1858 | | | | | 1859 | | | | | 1860 | | tp->t_status = deads[rdead].dd_es; | | | 1861 | | tp->t_utime = deads[rdead].dd_ut; | | | 1862 | | tp->t_stime = deads[rdead].dd_st; | | | 1863 | | while (tp->t_out >= 0) { | | | 1864 | | | | | 1865 | | #ifdef FDSETNOTSTRUCT | | | 1866 | | fd_set rfds; | | | 1867 | | #else | | | 1868 | | struct fd_set rfds; | | | 1869 | | #endif | | | 1870 | | | | | 1871 | | FD_ZERO(&rfds);
| | | 1872 | | FD_SET(tp->t_out, &rfds);
| | | 1873 | | TVCLEAR(&tout);
| | | 1874 | | if (select(tp->t_out + 1, | | | 1875 | | #ifdef FDSETISINT | | | 1876 | | (int *)&rfds, (int *)0, (int *)0, | | | 1877 | | #else | | | 1878 | | (fd_set *)&rfds, (fd_set *)0, (fd_set *)0, | | | 1879 | | #endif | | | 1880 | | &tout) == 1) | | | 1881 | | loclstout(tp); | | | 1882 | | | | | 1883 | | else | | | 1884 | | break; | | | 1885 | | } | | | 1886 | | #if defined(IMA_PGON) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2) \ | | | 1887 | | || defined(IMA_AIX5SP2) || defined(IMA_BEOLIN) | | | 1888 | | mpp_free(tp); | | | 1889 | | #endif | | | 1890 | | task_cleanup(tp); | | | 1891 | | task_free(tp); | | | 1892 | | } | | | 1893 | | } | | | 1894 | | if (++rdead >= ndead) | | | 1895 | | rdead = 0; | | | 1896 | | } | | | 1897 | | | | | 1898 | | netoutput(); | | | 1899 | | | | | 1900 | | if (runstate == PVMDHALTING) {
| | | 1901 | | pvmlogerror("work() pvmd halting\n"); | | | 1902 | | pvmbailout(0); | | | 1903 | | } | | | 1904 | | | | | 1905 | | | | | 1906 | | pvmgetclock(&tnow); | | | 1907 | | if (runstate == PVMDSTARTUP && TVXLTY(&tbail, &tnow)) {
| | | 1908 | | pvmlogerror("work() run = STARTUP, timed out waiting for master\n"); | | | 1909 | | pvmbailout(0); | | | 1910 | | } | | | 1911 | | | | | 1912 | | | | | 1913 | | | | | 1914 | | | | | 1915 | | if (TVXLTY(&tping, &tnow)) {
| | | 1916 | | if (pvmdebmask & (PDMPACKET|PDMSELECT))
| | | 1917 | | pvmlogerror("work() ping timer\n"); | | | 1918 | | if (runstate == PVMDNORMAL || runstate == PVMDHTUPD) {
| | | 1919 | | do { | | | 1920 | | if (++lastpinged > hosts->ht_last) | | | 1921 | | lastpinged = 1; | | | 1922 | | } while (!(hp = hosts->ht_hosts[lastpinged])); | | | 1923 | | | | | 1924 | | if (hp->hd_hostpart != myhostpart | | | 1925 | | && hp->hd_txq->pk_link == hp->hd_txq) { | | | 1926 | | mp = mesg_new(0); | | | 1927 | | mp->m_tag = DM_NULL;
| | | 1928 | | mp->m_dst = hp->hd_hostpart | TIDPVMD;
| | | 1929 | | sendmessage(mp); | | | 1930 | | } | | | 1931 | | } | | | 1932 | | tout.tv_sec = DDPINGTIME;
| | | 1933 | | tout.tv_usec = 0; | | | 1934 | | TVXADDY(&tping, &tnow, &tout);
| | | 1935 | | } | | | 1936 | | | | | 1937 | | | | | 1938 | | | | | 1939 | | | | | 1940 | | | | | 1941 | | if (opq->pk_tlink == opq) | | | 1942 | | tout = tping; | | | 1943 | | else | | | 1944 | | tout = opq->pk_tlink->pk_rtv; | | | 1945 | | | | | 1946 | | if (TVXLTY(&tout, &tnow)) {
| | | 1947 | | TVCLEAR(&tout);
| | | 1948 | | | | | 1949 | | } else { | | | 1950 | | TVXSUBY(&tout, &tout, &tnow);
| | | 1951 | | } | | | 1952 | | | | | 1953 | | if (pvmdebmask & PDMSELECT) {
| | | 1954 | | pvmlogprintf("work() select tout is %d.%06d\n", | | | 1955 | | tout.tv_sec, tout.tv_usec); | | | 1956 | | } | | | 1957 | | | | | 1958 | | | | | 1959 | | #ifdef SHMEM | | | 1960 | | if ((nodemsg = mpp_probe()) == 1) { | | | 1961 | | mpp_input(); | | | 1962 | | TVCLEAR(&tout); | | | 1963 | | } | | | 1964 | | #endif | | | 1965 | | | | | 1966 | | rfds = wrk_rfds; | | | 1967 | | wfds = wrk_wfds; | | | 1968 | | | | | 1969 | | | | | 1970 | | | | | 1971 | | if (pvmdebmask & PDMSELECT) {
| | | 1972 | | pvmlogprintf("work() wrk_nfds=%d\n", wrk_nfds); | | | 1973 | | print_fdset("work() rfds=", wrk_nfds, &rfds); | | | 1974 | | print_fdset("work() wfds=", wrk_nfds, &wfds); | | | 1975 | | } | | | 1976 | | | | | 1977 | | #if !defined(IMA_PGON) && !defined(IMA_I860) | | | 1978 | | | | | 1979 | | if ((nrdy = select(wrk_nfds, | | | 1980 | | #ifdef FDSETISINT | | | 1981 | | (int *)&rfds, (int *)&wfds, (int *)0, | | | 1982 | | #else | | | 1983 | | (fd_set *)&rfds, (fd_set *)&wfds, (fd_set *)0, | | | 1984 | | #endif | | | 1985 | | &tout)) == -1) { | | | 1986 | | if (errno != EINTR) {
| | | 1987 | | pvmlogperror("work() select"); | | | 1988 | | pvmlogprintf(" wrk_nfds=%d\n", wrk_nfds); | | | 1989 | | print_fdset(" rfds=", wrk_nfds, &wrk_rfds); | | | 1990 | | print_fdset(" wfds=", wrk_nfds, &wrk_wfds); | | | 1991 | | pvmlogprintf(" netsock=%d, ppnetsock=%d, loclsock=%d\n", | | | 1992 | | netsock, ppnetsock, loclsock); | | | 1993 | | task_dump(); | | | 1994 | | pvmbailout(0); | | | 1995 | | } | | | | | ... | | | 2054 | | } | | | 2055 | | | | | 2056 | | | | | 2057 | | mpp_output( (struct task *) NULL, (struct pkt *) NULL); | | | 2058 | | | | | 2059 | | } while(!(nrdy || nodemsg || timed_out)); | | | 2060 | | | | | 2061 | | #endif | | | 2062 | | | | | 2063 | | #ifdef STATISTICS | | | 2064 | | switch (nrdy) { | | | 2065 | | case -1: | | | 2066 | | stats.selneg++; | | | 2067 | | break; | | | 2068 | | case 0: | | | 2069 | | stats.selzer++; | | | 2070 | | break; | | | 2071 | | default: | | | 2072 | | stats.selrdy++; | | | 2073 | | break; | | | 2074 | | } | | | 2075 | | #endif | | | 2076 | | if (pvmdebmask & PDMSELECT) {
| | | 2077 | | pvmlogprintf("work() SELECT returns %d\n", nrdy); | | | 2078 | | } | | | 2079 | | | | | 2080 | | | | | 2081 | | | | | 2082 | | | | | 2083 | | | | | 2084 | | if (nrdy > 0) { | | | 2085 | | if (FD_ISSET(netsock, &rfds)) {
| | | 2086 | | nrdy--; |
| | 2408 | | | | netinput() | | | 2409 | | | | { | | | 2410 | | | | struct sockaddr_in osad; | | | 2411 | | | | #ifdef SOCKLENISUINT | | | 2412 | | | | #if defined(IMA_AIX4SP2) || defined(IMA_AIX5SP2) \ | | | 2413 | | | | || defined(IMA_AIX56K64) || defined(IMA_LINUXALPHA) | | | 2414 | | | | unsigned int oslen; | | | 2415 | | | | #else | | | 2416 | | | | size_t oslen; | | | 2417 | | | | #endif | | | 2418 | | | | #else | | | | | | | ... | | | 2429 | | | | int src; | | | 2430 | | | | int hh; | | | 2431 | | | | int already; | | | 2432 | | | | struct timeval tdiff; | | | 2433 | | | | int rttusec; | | | 2434 | | | | | | | 2435 | | | | | | | 2436 | | | | | | | 2437 | | | | | | | 2438 | | | | | | | 2439 | | | | pp = pk_new(pvmudpmtu); | | | 2440 | | | | if (TDFRAGHDR > DDFRAGHDR)
| | | 2441 | | | | pp->pk_dat += TDFRAGHDR - DDFRAGHDR;
| | | 2442 | | | | | | | 2443 | | | | oslen = sizeof(osad); | | | 2444 | | | | if ((pp->pk_len = recvfrom(netsock, pp->pk_dat, | | | 2445 | | | | pp->pk_max - (pp->pk_dat - pp->pk_buf), | | | 2446 | | | | 0, (struct sockaddr*)&osad, &oslen)) == -1) { | | | 2447 | | | | if (errno != EINTR)
| | | 2448 | | | | pvmlogperror("netinput() recvfrom(netsock)"); | | | 2449 | | | | goto scrap; | | | 2450 | | | | } | | | 2451 | | | | | | | 2452 | | | | #if 0 | | | 2453 | | | | | | | 2454 | | | | if (!(random() & 3)) { | | | 2455 | | | | pvmlogerror("netinput() oops, dropped one\n"); | | | 2456 | | | | goto scrap; | | | 2457 | | | | } | | | 2458 | | | | #endif | | | 2459 | | | | | | | 2460 | | | | #ifdef STATISTICS | | | 2461 | | | | stats.rfok++; | | | 2462 | | | | #endif | | | 2463 | | | | | | | 2464 | | | | cp = pp->pk_dat; | | | 2465 | | | | pp->pk_len -= DDFRAGHDR;
| | | 2466 | | | | pp->pk_dat += DDFRAGHDR;
| | | 2467 | | | | dst = pp->pk_dst = pvmget32(cp); | | | 2468 | | | | src = pp->pk_src = pvmget32(cp + 4); | | | 2469 | | | | sqn = pp->pk_seq = pvmget16(cp + 8); | | | 2470 | | | | aqn = pvmget16(cp + 10); | | | 2471 | | | | ff = pp->pk_flag = pvmget8(cp + 12); | | | 2472 | | | | if (ff & FFSOM) {
| | | 2473 | | | | if (pp->pk_len < MSGHDRLEN) {
| | | 2474 | | | | pvmlogprintf("netinput() SOM pkt src t%x dst t%x too short\n", | | | 2475 | | | | src, dst); | | | 2476 | | | | goto scrap; | | | 2477 | | | | } | | | 2478 | | | | cp += DDFRAGHDR;
| | | 2479 | | | | pp->pk_enc = pvmget32(cp); | | | 2480 | | | | pp->pk_tag = pvmget32(cp + 4); | | | 2481 | | | | pp->pk_ctx = pvmget32(cp + 8); | | | 2482 | | | | pp->pk_wid = pvmget32(cp + 16); | | | 2483 | | | | pp->pk_crc = pvmget32(cp + 20); | | | 2484 | | | | pp->pk_len -= MSGHDRLEN;
| | | 2485 | | | | pp->pk_dat += MSGHDRLEN;
| | | 2486 | | | | } | | | 2487 | | | | | | | 2488 | | | | | | | 2489 | | | | | | | 2490 | | | | | | | 2491 | | | | | | | 2492 | | | | hh = (src & tidhmask) >> (ffs(tidhmask) - 1); | | | 2493 | | | | if (hh < 0 || hh > hosts->ht_last || !(hp = hosts->ht_hosts[hh]) | | | 2494 | | | | | | | 2495 | | | | | | | 2496 | | | | | | | 2497 | | | | | | | 2498 | | | | | | | 2499 | | | | | | | 2500 | | | | || (osad.sin_addr.s_addr != hp->hd_sad.sin_addr.s_addr) | | | 2501 | | | | || (osad.sin_port != hp->hd_sad.sin_port) | | | 2502 | | | | | | | 2503 | | | | ) { | | | 2504 | | | | pvmlogprintf("netinput() bogus pkt from %s\n", | | | 2505 | | | | inadport_decimal(&osad)); | | | 2506 | | | | goto scrap; | | | 2507 | | | | } | | | 2508 | | | | | | | 2509 | | | | if (pvmdebmask & PDMPACKET) {
| | | 2510 | | | | pvmlogprintf( | | | 2511 | | | | "netinput() pkt from %s src t%x dst t%x f %s len %d seq %d ack %d\n", | | | 2512 | | | | hp->hd_name, src, dst, pkt_flags(ff), pp->pk_len, sqn, aqn); | | | 2513 | | | | } | | | 2514 | | | | | | | 2515 | | | | if ((ff & (FFFIN|FFACK)) == (FFFIN|FFACK)) {
| | | 2516 | | | | if (hh == hosts->ht_master) { | | | 2517 | | | | | | | 2518 | | | | | | | 2519 | | | | | | | 2520 | | | | if (runstate == PVMDPRIME) {
| | | 2521 | | | | if (pvmdebmask & PDMSTARTUP)
| | | 2522 | | | | pvmlogerror("work() PVMDPRIME halting\n"); | | | 2523 | | | | exit(0); | | | 2524 | | | | } | | | 2525 | | | | pvmlogprintf("netinput() FIN|ACK from master (%s)\n", | | | | | | | ... | | | 2541 | | | | ht_delete(newhosts, hp); | | | 2542 | | | | } | | | 2543 | | | | } | | | 2544 | | | | goto scrap; | | | 2545 | | | | } | | | 2546 | | | | | | | 2547 | | | | | | | 2548 | | | | | | | 2549 | | | | | | | 2550 | | | | | | | 2551 | | | | if (ff & FFACK) {
| | | 2552 | | | | for (pp2 = hp->hd_opq->pk_link; pp2 != hp->hd_opq; pp2 = pp2->pk_link) | | | 2553 | | | | if (pp2->pk_seq == aqn) { | | | 2554 | | | | if (pp2->pk_flag & FFDAT) {
| | | 2555 | | | | if (pp2->pk_nrt == 1) { | | | 2556 | | | | pvmgetclock(&tnow); | | | 2557 | | | | | | | 2558 | | | | TVXSUBY(&tdiff, &tnow, &pp2->pk_at);
| | | 2559 | | | | rttusec = tdiff.tv_sec * 1000000 + tdiff.tv_usec; | | | 2560 | | | | if (rttusec < 1) | | | 2561 | | | | rttusec = 1000; | | | | | | | ... | | | 2578 | | | | } | | | 2579 | | | | } | | | 2580 | | | | | | | 2581 | | | | | | | 2582 | | | | | | | 2583 | | | | | | | 2584 | | | | | | | 2585 | | | | | | | 2586 | | | | | | | 2587 | | | | | | | 2588 | | | | if (hp->hd_nop < nopax | | | 2589 | | | | && (hp->hd_txq->pk_link != hp->hd_txq)) { | | | 2590 | | | | if (pvmdebmask & PDMPACKET) {
| | | 2591 | | | | pvmlogprintf("netinput() pkt to opq\n"); | | | 2592 | | | | } | | | 2593 | | | | pp2 = hp->hd_txq->pk_link; | | | 2594 | | | | LISTDELETE(pp2, pk_link, pk_rlink);
| | | 2595 | | | | TVCLEAR(&pp2->pk_rtv);
| | | 2596 | | | | TVXADDY(&pp2->pk_rta, &hp->hd_rtt, &hp->hd_rtt);
| | | 2597 | | | | TVCLEAR(&pp2->pk_rto);
| | | 2598 | | | | TVCLEAR(&pp2->pk_at);
| | | 2599 | | | | pp2->pk_nrt = 0; | | | 2600 | | | | pp2->pk_hostd = hp; | | | 2601 | | | | pp2->pk_seq = hp->hd_txseq; | | | 2602 | | | | hp->hd_txseq = NEXTSEQNUM(hp->hd_txseq);
| | | 2603 | | | | LISTPUTBEFORE(hp->hd_opq, pp2, pk_link, pk_rlink);
| | | 2604 | | | | hp->hd_nop++; | | | 2605 | | | | LISTPUTBEFORE(opq, pp2, pk_tlink, pk_trlink);
| | | 2606 | | | | } | | | 2607 | | | | | | | 2608 | | | | if (!(ff & (FFDAT|FFFIN)))
| | | 2609 | | | | goto scrap; | | | 2610 | | | | | | | 2611 | | | | | | | 2612 | | | | | | | 2613 | | | | | | | 2614 | | | | | | | 2615 | | | | pp2 = pk_new(DDFRAGHDR);
| | | 2616 | | | | pp2->pk_dat += DDFRAGHDR;
| | | 2617 | | | | pp2->pk_dst = hp->hd_hostpart | TIDPVMD;
| | | 2618 | | | | pp2->pk_src = pvmmytid; | | | 2619 | | | | pp2->pk_flag = FFACK;
| | | 2620 | | | | TVCLEAR(&pp2->pk_rtv);
| | | 2621 | | | | TVCLEAR(&pp2->pk_rta);
| | | 2622 | | | | TVCLEAR(&pp2->pk_rto);
| | | 2623 | | | | TVCLEAR(&pp2->pk_at);
| | | 2624 | | | | pp2->pk_nrt = 0; | | | 2625 | | | | pp2->pk_hostd = hp; | | | 2626 | | | | pp2->pk_seq = 0; | | | 2627 | | | | pp2->pk_ack = sqn; | | | 2628 | | | | | | | 2629 | | | | | | | 2630 | | | | | | | 2631 | | | | | | | 2632 | | | | | | | 2633 | | | | | | | 2634 | | | | | | | 2635 | | | | { | | | 2636 | | | | struct pkt *pp3; | | opq->pk_tlink->pk_trlink <= 4095 | 2637 | | | | for (pp3 = opq->pk_tlink; pp3 != opq; pp3 = pp3->pk_tlink) | Problem | | opq->pk_tlink->pk_trlink <= 4095 |
| | | 2638 | | | | if (TVXLTY(&pp2->pk_rtv, &pp3->pk_rtv))
| | | 2639 | | | | break; | | pp3->pk_trlink <= 4095 | 2640 | | | | LISTPUTBEFORE(pp3, pp2, pk_tlink, pk_trlink);
|
|