| | 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]); |
| | 1829 | | clear_opq_of((int)(TIDPVMD | hosts->ht_hosts[0]->hd_hostpart));
|
| | 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) { |