~ubuntu-branches/ubuntu/feisty/pvm/feisty

« back to all changes in this revision

Viewing changes to src/pvmd.c

  • Committer: Bazaar Package Importer
  • Author(s): Steinar H. Gunderson
  • Date: 2006-08-09 00:00:40 UTC
  • mfrom: (2.1.5 dapper)
  • Revision ID: james.westby@ubuntu.com-20060809000040-16kh33tmxx2em716
Tags: 3.4.5-7
Build with SHELL=/bin/bash in debian/rules; fixes FTBFS when /bin/sh
isn't bash. (Closes: #379543)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
2
2
static char rcsid[] =
3
 
        "$Id: pvmd.c,v 1.53 1999/07/08 19:00:07 kohl Exp $";
 
3
        "$Id: pvmd.c,v 1.81 2004/09/08 19:35:36 pvmsrc Exp $";
4
4
 
5
5
/*
6
6
 *         PVM version 3.4:  Parallel Virtual Machine System
36
36
 *      Mr. pvm daemon.
37
37
 *
38
38
 * $Log: pvmd.c,v $
 
39
 * Revision 1.81  2004/09/08 19:35:36  pvmsrc
 
40
 * Added #ifdef IMA_AIX56K64 to unsigned int oslen fiasco...
 
41
 * (Spanker=kohl)
 
42
 *
 
43
 * Revision 1.80  2004/02/06 20:05:38  pvmsrc
 
44
 * Yanked out all the AMD64 test crap.
 
45
 *      - it was just the time.h header all along...!  ;-/~
 
46
 * (Spanker=kohl)
 
47
 *
 
48
 * Revision 1.79  2004/02/06 16:50:36  pvmsrc
 
49
 * Yet more ctime() test crap for AMD64...
 
50
 * (Spanker=kohl)
 
51
 *
 
52
 * Revision 1.78  2004/02/04 23:30:14  pvmsrc
 
53
 * Yet more temp AMD64 hacks...
 
54
 * (Spanker=kohl)
 
55
 *
 
56
 * Revision 1.77  2004/02/04 21:46:23  pvmsrc
 
57
 * Temp hack for AMD64 seg fault...
 
58
 * (Spanker=kohl)
 
59
 *
 
60
 * Revision 1.76  2004/01/14 18:51:02  pvmsrc
 
61
 * Added new AIX5* arches.
 
62
 * (Spanker=kohl)
 
63
 *
 
64
 * Revision 1.75  2002/10/14 19:23:12  pvmsrc
 
65
 * Oops!  Need to htons() to convert the host byte to network byte order!
 
66
 *      - for PVMNETSOCKPORT cruft...
 
67
 * (Spanker=kohl)
 
68
 *
 
69
 * Revision 1.74  2002/10/07 14:30:32  pvmsrc
 
70
 * Added new PVMNETSOCKPORT env var for mksocs().
 
71
 *      - allow starting port address for netsock binding, in the hopes
 
72
 *              that PVM will get a port that is allowed access through a
 
73
 *              firewall...!
 
74
 *      (it's about time!)
 
75
 * (Spanker=kohl)
 
76
 *
 
77
 * Revision 1.73  2002/07/03 16:57:54  pvmsrc
 
78
 * Fixes for compilation on Linux Alpha.
 
79
 *      - submitted by "David Mathog" <mathog@mendel.bio.caltech.edu>.
 
80
 * (Spanker=kohl)
 
81
 *
 
82
 * Revision 1.72  2002/04/16 15:06:02  pvmsrc
 
83
 * WIN32 Fixes for Multiple Domains.
 
84
 *      - submitted by Jigen Zhou <jigen@icemcfd.com>.
 
85
 * (Spanker=kohl)
 
86
 *
 
87
 * Revision 1.71  2002/02/21 23:17:40  pvmsrc
 
88
 * Added new (not to be documented!) PVM_MAX_TASKS env var support.
 
89
 *      - for Mahir Lokvancic <mahir@math.ufl.edu>.
 
90
 *      - forcefully limits the number of tasks that can attach to a
 
91
 *              pvmd, required on Solaris in rare circumstances when hard
 
92
 *              FD_SETSIZE limit is reached, and all hell breaks loose...
 
93
 *      - set new pvm_max_ntasks global depending on env var (0 = no limit)
 
94
 *      - check return for task_new() call, can now produce NULL ptr,
 
95
 *              indicating PvmOutOfRes...
 
96
 * (Spanker=kohl)
 
97
 *
 
98
 * Revision 1.70  2001/12/07 16:06:11  pvmsrc
 
99
 * Oops!  Some new Unix fixes & features break Windows (of course!).
 
100
 *      - #ifdef-ed away fcntl() calls for non-blocking sockets / stdin.
 
101
 *      (one for bug fix in lpvm.c, one for check_ext_input() in pvmd.c)
 
102
 * (Spanker=kohl)
 
103
 *
 
104
 * Revision 1.69  2001/11/26 17:45:12  pvmsrc
 
105
 * Added #define for MAXPATHLEN for goofy arches...  :-)
 
106
 * (Spanker=kohl)
 
107
 *
 
108
 * Revision 1.68  2001/09/28 12:43:18  pvmsrc
 
109
 * D-Oh!  Stupid Solaris doesn't recognize FNDELAY, only O_NDELAY...  :-Q
 
110
 * (Spanker=kohl)
 
111
 *
 
112
 * Revision 1.67  2001/09/27 21:25:11  pvmsrc
 
113
 * BEOSCYLD port.
 
114
 *      - submitted by Joe Vitale <vitale@scyld.com>.
 
115
 *      (we renamed it from BEOWULF to BEOSCYLD, but it's his port... :-)
 
116
 * (Spanker=kohl)
 
117
 *
 
118
 * Revision 1.66  2001/09/26 21:23:21  pvmsrc
 
119
 * Added Handling for Optional Virtual Machine ID.
 
120
 *      - added new check_ext_input() routine to check for extension
 
121
 *              options on stdin before anything else happens...  currently
 
122
 *              only expects env string a la "PVM_VMID=xxxx", but more options
 
123
 *              could be added on same input line, white-space-separated...
 
124
 *      - extra vmid comes through with SM_STHOST message (after wincmd)
 
125
 *              to hoster.
 
126
 *      - user instructed to type VMID (or other options) to pvmd stdin
 
127
 *              during manual startup.
 
128
 * (Spanker=kohl)
 
129
 *
 
130
 * Revision 1.65  2001/09/25 21:20:19  pvmsrc
 
131
 * Minor TMPNAMFUN()/tmpnam() cleanup.
 
132
 *      - moved macro def to pvm3.h, renamed PVMTNPMAN().
 
133
 *      - same for LEN_OF_TMP_NAM -> PVMTMPNAMLEN.
 
134
 *      - mostly a huge waste of time, since *both* tmpnam() & mktemp()
 
135
 *              produce the same "dangerous" warning message in Linux/gcc...
 
136
 *      - damn.
 
137
 * (Spanker=kohl)
 
138
 *
 
139
 * Revision 1.64  2001/04/04 15:13:58  pvmsrc
 
140
 * Fixed pesky bug buried in pvmd opq...
 
141
 *      - ack packets were being stuck at the end of the output queue,
 
142
 *              where they could get delayed (not lost) long enough to trigger
 
143
 *              a cascade of packet retries from remote pvmds.
 
144
 *      - solution is to stick ack packets after new (zero-rtv) packets,
 
145
 *              but before and locally queued retry packets (which can block
 
146
 *              processing of the opq at a specified time...).
 
147
 * Yanked Bogus chdir() from WIN32 forkexec().
 
148
 *      - patch submitted by Peter J. Puchyr, SpaceTime Software
 
149
 * (Spanker=kohl)
 
150
 *
 
151
 * Revision 1.63  2001/02/07 23:15:51  pvmsrc
 
152
 * 2nd Half of CYGWIN Check-ins...
 
153
 * (Spanker=kohl)
 
154
 *
 
155
 * Revision 1.62  2001/02/02 14:50:26  pvmsrc
 
156
 * Win32 fixes & additions.
 
157
 * (Spanker=kohl)
 
158
 *
 
159
 * Revision 1.61  2000/10/11 20:50:24  pvmsrc
 
160
 * Yikes...
 
161
 *      - fixed '//' comments in WIN32 forkexec() implementation to
 
162
 *              '/ * * /'.
 
163
 *      - apparently intereferes with SUN4SOL2 preprocessor?  HOW BOGUS.
 
164
 * (Spanker=kohl)
 
165
 *
 
166
 * Revision 1.60  2000/02/18 15:48:43  pvmsrc
 
167
 * Commented out ECONNREFUSED check for sendto() in LINUX.
 
168
 *      - apparently results from local networking problems...
 
169
 *      - leave in code as a sign post for future occurrences.
 
170
 * (Spanker=kohl)
 
171
 *
 
172
 * Revision 1.59  2000/02/17 23:12:16  pvmsrc
 
173
 * *** Changes for new BEOLIN port ***
 
174
 *      - MPP-like, similar to SP2, etc.
 
175
 *      - submitted by Paul Springer <pls@smokeymt.jpl.nasa.gov>.
 
176
 *      - format-checked & cleaned up by Jeembo...  :-)
 
177
 * (Spanker=kohl)
 
178
 *
 
179
 * Revision 1.58  2000/02/17 16:42:56  pvmsrc
 
180
 * Added hack to ignore errno=ECONNREFUSED from sendto() for Linux.
 
181
 *      - apparently occurs intermittently on some setups...
 
182
 *      - patch submitted by Russell Mora <rd.mora@auckland.ac.nz>.
 
183
 * (Spanker=kohl)
 
184
 *
 
185
 * Revision 1.57  2000/02/16 22:01:25  pvmsrc
 
186
 * Fixed up #include <sys/types.h> stuff...
 
187
 *      - use <bsd/sys/types.h> for IMA_TITN...
 
188
 *      - #include before any NEEDMENDIAN #includes...
 
189
 * Added #ifndef NO_NETINET_TCP_H around <netinet/tcp.h> for
 
190
 *      archs that can't handle it...  :-)
 
191
 * (Spanker=kohl)
 
192
 *
 
193
 * Revision 1.56  2000/02/11 21:04:03  pvmsrc
 
194
 * Added new PVMHOSTFILE env var.
 
195
 *      - submitted by Anders Mundt Due <amd@pd-house.dk>.
 
196
 * (Spanker=kohl)
 
197
 *
 
198
 * Revision 1.55  2000/02/10 20:46:12  pvmsrc
 
199
 * Yanked char *pvmtmpspec for WIN32.
 
200
 *      - not necessary, fixed string manip in log file name gen.
 
201
 * (Spanker=kohl)
 
202
 *
 
203
 * Revision 1.54  2000/02/07 22:22:10  pvmsrc
 
204
 * Hack to help with select()/fd_sets in WIN32:
 
205
 *      - fd_set is *NOT* a bit field in WIN32, is a circular buffer.
 
206
 *      - must check for !FD_ISSET() before FD_SET() else duplicate
 
207
 *              entries possible, and fd_set buffer overflow/overwrite.
 
208
 *      - similary, FD_ISSET() check before FD_CLR().
 
209
 *      - patch submitted by "Bruce W. Church" <bwc1@cornell.edu>.
 
210
 * (Spanker=kohl)
 
211
 *
39
212
 * Revision 1.53  1999/07/08 19:00:07  kohl
40
213
 * Fixed "Log" keyword placement.
41
214
 *      - indent with " * " for new CVS.
464
637
 *
465
638
 */
466
639
 
 
640
#include <stdio.h>
 
641
 
467
642
#ifndef WIN32
468
643
#include <sys/param.h>
469
644
#endif
 
645
 
 
646
#ifdef IMA_TITN
 
647
#include <bsd/sys/types.h>
 
648
#else
 
649
#include <sys/types.h>
 
650
#endif
 
651
 
470
652
#ifdef NEEDMENDIAN
471
653
#include <machine/endian.h>
472
654
#endif
478
660
#endif
479
661
 
480
662
#include <pvm3.h>
481
 
#ifdef WIN32
482
 
#include "pvmwin.h"
483
 
#ifndef _XDR_HEADERS
484
 
#define _XDR_HEADERS
 
663
 
 
664
#if defined(WIN32) || defined(CYGWIN)
485
665
#include "..\xdr\types.h"
486
666
#include "..\xdr\xdr.h"
487
 
#endif
488
667
#else
489
668
#include <rpc/types.h>
490
669
#include <rpc/xdr.h>
 
670
#endif
 
671
 
 
672
#ifdef WIN32
 
673
#include "pvmwin.h"
 
674
#include <time.h>
 
675
#else
 
676
#include <time.h>
491
677
#include <sys/time.h>
492
 
#include <time.h>
493
678
#include <sys/wait.h>
494
679
#include <sys/socket.h>
495
680
#include <sys/signal.h>
496
681
#include <netinet/in.h>
 
682
#ifndef NO_NETINET_TCP_H
497
683
#include <netinet/tcp.h>
 
684
#endif
498
685
#include <netdb.h>
499
686
#include <pwd.h>
500
687
#endif
501
688
 
502
 
#ifdef IMA_TITN
503
 
#include <bsd/sys/types.h>
504
 
#else
505
 
#include <sys/types.h>
 
689
#ifdef IMA_BEOSCYLD
 
690
#include <sys/bproc.h>
 
691
#endif
 
692
 
 
693
#ifndef IMA_TITN
506
694
#ifndef WIN32
507
695
#include <sys/ioctl.h>
508
696
#endif
509
697
#endif
 
698
 
510
699
#ifndef NOWAIT3
511
700
#include <sys/resource.h>
512
701
#endif
517
706
#ifndef NOUNIXDOM
518
707
#include <sys/un.h>
519
708
#endif
 
709
#ifdef IMA_LINUXALPHA
 
710
#include <unistd.h>
 
711
#endif
520
712
#include <fcntl.h>
521
713
#include <errno.h>
522
 
#include <stdio.h>
523
714
#include <signal.h>
524
715
#include <ctype.h>
525
716
/* Must come before local CINDEX macro definition */
548
739
#include "waitc.h"
549
740
#include "listmac.h"
550
741
#include "tvdefs.h"
551
 
#if defined(IMA_PGON) || defined(IMA_I860) || defined(IMA_CM5) || defined(SHMEM) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2)
 
742
#if defined(IMA_PGON) || defined(IMA_I860) || defined(IMA_CM5) \
 
743
        || defined(SHMEM) || defined(IMA_SP2MPI) \
 
744
        || defined(IMA_AIX4SP2) || defined(IMA_AIX5SP2) \
 
745
        || defined(IMA_BEOLIN)
552
746
#include "pvmdmp.h"
553
747
#endif
554
748
#include "bfunc.h"
559
753
#define MAXPATHLEN PATH_MAX+1
560
754
#endif
561
755
 
 
756
#if defined(IMA_CRAY) || defined(IMA_CRAY2) || defined(IMA_I860) || defined(IMA_E88K) || defined(IMA_SCO)
 
757
#ifndef MAXPATHLEN
 
758
#define MAXPATHLEN      CANBSIZ
 
759
#endif
 
760
#endif
 
761
 
562
762
#ifndef max
563
763
#define max(a,b)        ((a)>(b)?(a):(b))
564
764
#endif
575
775
#define SOMAXCONN       5
576
776
#endif
577
777
 
578
 
#ifdef  NOTMPNAM
579
 
#define TMPNAMFUN(x)    pvmtmpnam(x)
580
 
#define LEN_OF_TMP_NAM  64
581
 
char *pvmtmpnam();
582
 
 
583
 
#else   /*NOTMPNAM*/
584
 
#define TMPNAMFUN(x)    tmpnam(x)
585
 
#ifdef  L_tmpnam
586
 
#define LEN_OF_TMP_NAM  L_tmpnam
587
 
#else
588
 
#define LEN_OF_TMP_NAM  64
589
 
#endif
590
 
#endif  /*NOTMPNAM*/
591
 
 
592
778
#ifdef  STATISTICS
593
779
struct statistics {
594
780
        int selneg, selzer, selrdy;             /* neg, zero, ready selects */
630
816
/* void make_valid(char *n); sls */
631
817
void make_valid();
632
818
 
 
819
#ifndef WIN32
 
820
void check_ext_input();
 
821
#endif
 
822
 
633
823
#ifdef CTIMEISTIMET
634
824
#define PVM_TIMET time_t
635
825
#else
640
830
#define IMA_MPP
641
831
#endif
642
832
 
 
833
#ifdef WIN32
 
834
char *read_pvmregistry __ProtoGlarp__(( const char * ));
 
835
#endif
 
836
 
643
837
/***************
644
838
 **  Globals  **
645
839
 **           **
689
883
#ifdef WIN32
690
884
/* the userid is not available in WIN 32! */
691
885
/* some useless binary sid struct */
692
 
char *pvmtmpspec=0;
693
886
int system_loser_win=FALSE;
694
887
int nAlert=SO_SYNCHRONOUS_NONALERT;
695
888
int nFileHandle;
724
917
#endif
725
918
static int wrk_nfds = 0;                /* 1 + highest bit set in fds */
726
919
 
 
920
int pvm_max_ntasks = 0;                 /* bound on total number of tasks */
 
921
                                                                /* allowed to attach to pvmd... */
 
922
                                                                        /* == 0 for no bound... */
 
923
 
727
924
static char *modulenames[] = {
728
925
        "PVM_TASKER",
729
926
        "PVM_TRACER",
744
941
        char buf[128];
745
942
 
746
943
#ifndef WIN32
 
944
        /* check for extension config options */
 
945
        check_ext_input();
 
946
 
747
947
        /* make sure 0, 1, 2 are in use */
748
 
 
749
948
        (void)open("/dev/null", O_RDONLY, 0);
750
949
        (void)open("/dev/null", O_RDONLY, 0);
751
950
        (void)open("/dev/null", O_RDONLY, 0);
809
1008
 
810
1009
        pvmmydsig = pvmgetdsig();
811
1010
 
812
 
        ppi_config(&argc, argv);
 
1011
        ppi_config(argc, argv);
813
1012
 
814
 
#if defined(IMA_PGON) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2)
 
1013
#if defined(IMA_PGON) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2) \
 
1014
                || defined(IMA_AIX5SP2) || defined(IMA_BEOLIN)
815
1015
        mpp_init(&argc, argv);
816
1016
#endif
817
1017
 
893
1093
                exit(0);
894
1094
        }
895
1095
 
 
1096
        {
 
1097
                char *p;
 
1098
                if (p = getenv("PVM_MAX_TASKS")) {
 
1099
                        pvm_max_ntasks = atoi(p);
 
1100
                        if (pvm_max_ntasks < 0)
 
1101
                                pvm_max_ntasks = 0;
 
1102
                }
 
1103
        }
 
1104
 
896
1105
        if (slavemode)                                  /* slave pvmd */
897
1106
                slave_config(name, argc, argv);
898
1107
 
930
1139
 
931
1140
#ifndef IMA_I860 /* this signal interferes with getcube() on I860 */
932
1141
#ifdef  SYSVSIGNAL
 
1142
#ifndef IMA_BEOSCYLD
933
1143
        (void)signal(SIGCLD, reap);
 
1144
#endif
934
1145
#ifdef IMA_SUNMP
935
 
        sigset(SIGCLD, reap);   /* yep we go really want to catch our kids */
 
1146
        sigset(SIGCLD, reap); /* yep we go really want to catch our kids */
936
1147
#endif
937
1148
#else
938
1149
        (void)signal(SIGCHLD, reap);
1032
1243
}
1033
1244
 
1034
1245
 
 
1246
#ifndef WIN32
 
1247
void
 
1248
check_ext_input()
 
1249
{
 
1250
        char input[256];
 
1251
 
 
1252
        char *ptr, *ptr2;
 
1253
 
 
1254
        char c;
 
1255
 
 
1256
        int flags;
 
1257
        int i;
 
1258
 
 
1259
        /* Set stdin Non-Blocking */
 
1260
 
 
1261
        flags = fcntl( 0, F_GETFL, 0 );
 
1262
 
 
1263
        fcntl( 0, F_SETFL, flags | O_NDELAY );
 
1264
 
 
1265
        /* Test for Input */
 
1266
 
 
1267
        i = 0;
 
1268
 
 
1269
        while ( (int)(input[i] = getc( stdin )) != (char) EOF
 
1270
                        && input[i] != '\n' && i < 255 )
 
1271
                i++;
 
1272
 
 
1273
        input[i] = '\0';
 
1274
 
 
1275
        /* Parse Extension Options Here */
 
1276
 
 
1277
        if ( i ) {
 
1278
                ptr = input;
 
1279
                while ( *ptr != '\0' )
 
1280
                {
 
1281
                        /* Virtual Machine ID */
 
1282
                        if ( !strncmp( "PVM_VMID=", ptr, 9 ) ) {
 
1283
                                ptr2 = ptr + 9;
 
1284
                                while ( *ptr2 != ' ' && *ptr2 != '\t' && *ptr2 != '\0' )
 
1285
                                        ptr2++;
 
1286
                                c = *ptr2;
 
1287
                                *ptr2 = '\0';
 
1288
                                pvmputenv(STRALLOC(ptr));
 
1289
                                *ptr2 = c;
 
1290
                                ptr = ptr2;
 
1291
                        }
 
1292
 
 
1293
                        /* Move Past Unknown Options */
 
1294
                        else
 
1295
                                while ( *ptr != ' ' && *ptr != '\t' && *ptr != '\0' )
 
1296
                                        ptr++;
 
1297
 
 
1298
                        /* Advance to Next Option */
 
1299
                        while ( *ptr == ' ' || *ptr == '\t' )
 
1300
                                ptr++;
 
1301
                }
 
1302
        }
 
1303
 
 
1304
        /* Reset stdin to Blocking */
 
1305
 
 
1306
        fcntl( 0, F_SETFL, flags );
 
1307
}
 
1308
#endif
 
1309
 
 
1310
 
1035
1311
static char *ffnames[] = {
1036
1312
        "SOM", "EOM", "DAT", "FIN", "ACK"
1037
1313
};
1149
1425
#ifdef  NOWAITPID
1150
1426
        if ((pid = wait(&es)) > 0)
1151
1427
#else
 
1428
#ifdef IMA_BEOSCYLD
 
1429
        if ((pid = waitpid(-1, &es, WNOHANG)) > 0)
 
1430
#else
1152
1431
        while ((pid = waitpid(-1, &es, WNOHANG)) > 0)
1153
1432
#endif
 
1433
#endif
1154
1434
#else   /*NOWAIT3*/
1155
1435
        while ((pid = wait3(&es, WNOHANG, &rus)) > 0)
1156
1436
#endif  /*NOWAIT3*/
1172
1452
        }
1173
1453
 
1174
1454
#ifdef  SYSVSIGNAL
 
1455
#ifndef IMA_BEOSCYLD
1175
1456
        (void)signal(SIGCLD, reap);
1176
1457
#endif
 
1458
#endif
1177
1459
 
1178
1460
#endif
1179
1461
 
1269
1551
        int sets;                       /* which sets */
1270
1552
{
1271
1553
#ifdef  SANITY
 
1554
#ifndef WIN32
1272
1555
        if (fd < 0 || fd >= FD_SETSIZE) {
1273
1556
                pvmlogprintf("wrk_fds_add() bad fd %d\n", fd);
1274
1557
                return 1;
1275
1558
        }
1276
1559
#endif
 
1560
#endif
1277
1561
        if (sets & 1)
1278
 
                FD_SET(fd, &wrk_rfds);
 
1562
                if ( !FD_ISSET(fd, &wrk_rfds) ) {
 
1563
                        FD_SET(fd, &wrk_rfds);
 
1564
#ifdef WIN32
 
1565
                        wrk_nfds++;
 
1566
#endif
 
1567
                }
1279
1568
        if (sets & 2)
1280
 
                FD_SET(fd, &wrk_wfds);
 
1569
                if ( !FD_ISSET(fd, &wrk_wfds) ) {
 
1570
                        FD_SET(fd, &wrk_wfds);
 
1571
#ifdef WIN32
 
1572
                        if ( !(sets & 1) ) wrk_nfds++;
 
1573
#endif
 
1574
                }
1281
1575
/*
1282
1576
        if (sets & 4)
1283
 
                FD_SET(fd, &wrk_efds);
 
1577
                if ( !FD_ISSET(fd, &wrk_efds) ) {
 
1578
                        FD_SET(fd, &wrk_efds);
 
1579
#ifdef WIN32
 
1580
                        wrk_nefds++;
 
1581
#endif
 
1582
                }
1284
1583
*/
1285
1584
 
 
1585
#ifndef WIN32
1286
1586
        /* if this is new highest, adjust nfds */
1287
 
 
1288
1587
        if (fd >= wrk_nfds)
1289
1588
                wrk_nfds = fd + 1;
 
1589
#endif
 
1590
 
1290
1591
        return 0;
1291
1592
}
1292
1593
 
1296
1597
        int sets;                       /* which sets */
1297
1598
{
1298
1599
#ifdef  SANITY
 
1600
#ifndef WIN32
1299
1601
        if (fd < 0 || fd >= FD_SETSIZE) {
1300
1602
                pvmlogprintf("wrk_fds_delete() bad fd %d\n", fd);
1301
1603
                return 1;
1302
1604
        }
1303
1605
#endif
 
1606
#endif
1304
1607
        if (sets & 1)
1305
 
                FD_CLR(fd, &wrk_rfds);
 
1608
                if ( FD_ISSET(fd, &wrk_rfds) ) {
 
1609
                        FD_CLR(fd, &wrk_rfds);
 
1610
#ifdef WIN32
 
1611
                        wrk_nfds--;
 
1612
#endif
 
1613
                }
1306
1614
        if (sets & 2)
1307
 
                FD_CLR(fd, &wrk_wfds);
 
1615
                if ( FD_ISSET(fd, &wrk_wfds) ) {
 
1616
                        FD_CLR(fd, &wrk_wfds);
 
1617
#ifdef WIN32
 
1618
                        if ( !(sets & 1) ) wrk_nfds--;
 
1619
#endif
 
1620
                }
1308
1621
/*
1309
1622
        if (sets & 4)
1310
 
                FD_CLR(fd, &wrk_efds);
 
1623
                if ( FD_ISSET(fd, &wrk_efds) ) {
 
1624
                        FD_CLR(fd, &wrk_efds);
 
1625
#ifdef WIN32
 
1626
                        wrk_nefds--;
 
1627
#endif
 
1628
                }
1311
1629
*/
1312
1630
 
 
1631
#ifndef WIN32
1313
1632
        /* if this was highest, may have to adjust nfds to new highest */
1314
 
 
1315
1633
        if (fd + 1 == wrk_nfds)
1316
1634
                while (wrk_nfds > 0) {
1317
1635
                        wrk_nfds--;
1325
1643
                                break;
1326
1644
                        }
1327
1645
                }
 
1646
#endif
 
1647
 
1328
1648
        return 0;
1329
1649
}
1330
1650
 
1393
1713
        if (pvmdebmask || myhostpart) {
1394
1714
                PVM_TIMET time_temp;
1395
1715
                char retbuf[32];
1396
 
                unsigned char buf[26];
1397
1716
                pvmlogprintf("%s (%s) %s %s\n",
1398
1717
                                hosts->ht_hosts[hosts->ht_local]->hd_name,
1399
1718
                                inadport_decimal(&hosts->ht_hosts[hosts->ht_local]->hd_sad),
1472
1791
                /*
1473
1792
                *       clean up after any tasks that we got SIGCHLDs for
1474
1793
                */
 
1794
#ifdef IMA_BEOSCYLD
 
1795
                reap(SIGCLD);
 
1796
#endif
1475
1797
                while (rdead != wdead) {
1476
1798
                        if (deads[rdead].dd_pid == pprime) {
1477
1799
                                int cc;
1478
1800
#ifdef SOCKLENISUINT
1479
 
#ifdef IMA_AIX4SP2
 
1801
#if defined(IMA_AIX4SP2) || defined(IMA_AIX5SP2) \
 
1802
                || defined(IMA_AIX56K64) || defined(IMA_LINUXALPHA)
1480
1803
                                unsigned int oslen;
1481
1804
#else
1482
1805
                                size_t oslen;
1546
1869
                                                else
1547
1870
                                                        break;
1548
1871
                                        }
1549
 
#if defined(IMA_PGON) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2)
 
1872
#if defined(IMA_PGON) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2) \
 
1873
        || defined(IMA_AIX5SP2) || defined(IMA_BEOLIN)
1550
1874
                                        mpp_free(tp);
1551
1875
#endif
1552
1876
                                        task_cleanup(tp);
1816
2140
                                }
1817
2141
                        }
1818
2142
                }
1819
 
#if defined(IMA_CM5) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2)
 
2143
#if defined(IMA_CM5) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2) \
 
2144
        || defined(IMA_AIX5SP2) || defined(IMA_BEOLIN)
1820
2145
                mpp_output((struct task *)0, (struct pkt *)0);
1821
2146
#endif
1822
2147
#ifdef  SHMEM
1982
2307
#ifndef WIN32
1983
2308
                        && errno != ENOBUFS
1984
2309
#endif
 
2310
#ifdef IMA_LINUX
 
2311
                        /* some Linux systems report this intermittent error */
 
2312
                        /* && errno != ECONNREFUSED */
 
2313
#endif
1985
2314
                        /* hope this works for all archs, not just linux */
1986
2315
                        && errno != ENOMEM
1987
2316
                        ) {
2066
2395
{
2067
2396
        struct sockaddr_in osad;                /* sender's ip addr */
2068
2397
#ifdef SOCKLENISUINT
2069
 
#ifdef IMA_AIX4SP2
 
2398
#if defined(IMA_AIX4SP2) || defined(IMA_AIX5SP2) \
 
2399
                || defined(IMA_AIX56K64) || defined(IMA_LINUXALPHA)
2070
2400
        unsigned int oslen;
2071
2401
#else
2072
2402
        size_t oslen;
2281
2611
        pp2->pk_hostd = hp;
2282
2612
        pp2->pk_seq = 0;
2283
2613
        pp2->pk_ack = sqn;
2284
 
        LISTPUTAFTER(opq, pp2, pk_tlink, pk_trlink);
 
2614
        /*
 
2615
         * Bogus!  Acks can't be put at end of opq, as could be
 
2616
         * stuck behind packet retries with non-zero pk_rtv's...
 
2617
         * Better place Acks, in order, after other zero-rtv-ed (new)
 
2618
         * packets, but *before* any retry packets...
 
2619
         */
 
2620
        /* LISTPUTAFTER(opq, pp2, pk_tlink, pk_trlink); */
 
2621
        {
 
2622
                struct pkt *pp3;
 
2623
                for (pp3 = opq->pk_tlink; pp3 != opq; pp3 = pp3->pk_tlink)
 
2624
                        if (TVXLTY(&pp2->pk_rtv, &pp3->pk_rtv))
 
2625
                                break;
 
2626
                LISTPUTBEFORE(pp3, pp2, pk_tlink, pk_trlink);
 
2627
        }
2285
2628
 
2286
2629
        if (!(ff & FFDAT))
2287
2630
                goto scrap;
2533
2876
{
2534
2877
        struct task *tp;                        /* new task context */
2535
2878
#ifdef SOCKLENISUINT
2536
 
#ifdef IMA_AIX4SP2
 
2879
#if defined(IMA_AIX4SP2) || defined(IMA_AIX5SP2) \
 
2880
                || defined(IMA_AIX56K64) || defined(IMA_LINUXALPHA)
2537
2881
        unsigned int oslen;
2538
2882
#else
2539
2883
        size_t oslen;
2553
2897
#endif
2554
2898
*/
2555
2899
 
2556
 
        tp = task_new(0);
 
2900
        if ((tp = task_new(0)) == NULL) {
 
2901
                pvmlogprintf("loclconn() too many tasks?\n" );
 
2902
                return PvmOutOfRes;
 
2903
        }
2557
2904
 
2558
2905
#ifdef NOUNIXDOM
2559
2906
        tp->t_salen = sizeof(tp->t_sad);
2685
3032
        * send as much as possible; skip to next packet when all sent
2686
3033
        */
2687
3034
 
2688
 
#if defined(IMA_RS6K) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2)
 
3035
#if defined(IMA_RS6K) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2) \
 
3036
                || defined(IMA_AIX5SP2)
2689
3037
                n = write(tp->t_sock, cp, min(len, 4096));
2690
3038
#else
2691
3039
#ifndef WIN32
2739
3087
                                pp->pk_cpos += n;
2740
3088
 
2741
3089
                        } else {
2742
 
#if defined(IMA_CM5) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2)
 
3090
#if defined(IMA_CM5) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2) \
 
3091
        || defined(IMA_AIX5SP2) || defined(IMA_BEOLIN)
2743
3092
                                int dst = pp->pk_dst;
2744
3093
#endif
2745
3094
                                LISTDELETE(pp, pk_link, pk_rlink);
2746
3095
                                pk_free(pp);
2747
 
#if defined(IMA_CM5) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2)
 
3096
#if defined(IMA_CM5) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2) \
 
3097
        || defined(IMA_AIX5SP2)
 
3098
                                /* Not done for BEOLIN, since tp2 is tp, */
 
3099
                                /* the task on which we are working (PLS) */
2748
3100
                                if (TIDISNODE(dst)) {
2749
3101
                                        struct task *tp2;
2750
3102
 
2872
3224
        if (pp->pk_len == m) {
2873
3225
                tp->t_rxp = 0;
2874
3226
                pp->pk_dst = pvmget32(pp->pk_dat);
2875
 
#if defined(IMA_PGON) || defined(IMA_I860) || defined(IMA_CM5) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2)
 
3227
#if defined(IMA_PGON) || defined(IMA_I860) || defined(IMA_CM5) \
 
3228
                || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2) \
 
3229
                || defined(IMA_AIX5SP2)
2876
3230
                pp->pk_src = pvmget32(pp->pk_dat + 4);
2877
3231
#else
2878
3232
                pp->pk_src = tp->t_tid;
2952
3306
        struct pmsg *mp;
2953
3307
        struct hostd *hp;
2954
3308
        struct task *tp2;
2955
 
#if defined(IMA_CM5) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2)
 
3309
#if defined(IMA_CM5) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2) \
 
3310
                || defined(IMA_AIX5SP2)
2956
3311
        struct task *socktp = tp;       /* owner of the socket */
2957
3312
#endif
2958
3313
 
2964
3319
                                pp->pk_src, dst, pkt_flags(ff), pp->pk_len);
2965
3320
        }
2966
3321
 
2967
 
#if defined(IMA_SP2MPI) || defined(IMA_AIX4SP2)
 
3322
#if defined(IMA_SP2MPI) || defined(IMA_AIX4SP2) || defined(IMA_AIX5SP2)
2968
3323
        if (pp->pk_src > 0 && !tp->t_tid && (tp2 = task_findpid(pp->pk_src))) {
2969
3324
                /* connect request from pvmhost */
2970
3325
                mpp_conn(tp, tp2);
2972
3327
                return -1;
2973
3328
        }
2974
3329
#endif
2975
 
#if defined(IMA_PGON) || defined(IMA_I860) || defined(IMA_CM5) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2)
 
3330
#if defined(IMA_PGON) || defined(IMA_I860) || defined(IMA_CM5) \
 
3331
                || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2) \
 
3332
                || defined(IMA_AIX5SP2)
2976
3333
        if (TIDISNODE(pp->pk_src))              /* from a node */
2977
3334
                if (!(tp = task_find(pp->pk_src))) {
2978
3335
                        pvmlogprintf("loclinpkt() from unknown task t%x\n", pp->pk_src);
3107
3464
        * if sock is -1, tm_conn2() wants us to throw out this context
3108
3465
        * because it's been merged into another.
3109
3466
        */
3110
 
#if defined(IMA_CM5) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2)
 
3467
#if defined(IMA_CM5) || defined(IMA_SP2MPI) || defined(IMA_AIX4SP2) \
 
3468
                || defined(IMA_AIX5SP2)
3111
3469
                        /* node procs have no socket; they use pvmhost's */
3112
3470
                        if (socktp->t_sock == -1)
3113
3471
#else
3487
3845
        int ac;
3488
3846
        int realrunstate;
3489
3847
        char buf[32];
 
3848
#ifdef IMA_BEOSCYLD
 
3849
        int node;
 
3850
#endif
3490
3851
 
3491
3852
        static char *nullep[] = { "", 0 };
3492
3853
#ifndef IMA_OS2
3497
3858
                pvmlogerror("forkexec() out of tids?\n");
3498
3859
                return PvmOutOfRes;
3499
3860
        }
3500
 
        tp = task_new(tid);
 
3861
        if ((tp = task_new(tid)) == NULL) {
 
3862
                pvmlogerror("forkexec() too many tasks?\n");
 
3863
                return PvmOutOfRes;
 
3864
        }
3501
3865
 
3502
3866
        /* search for file */
3503
3867
 
3511
3875
#ifdef IMA_OS2
3512
3876
                (void)strcat(path,".exe");      /* no *.cmd !!! */
3513
3877
#endif
 
3878
#ifdef IMA_BEOSCYLD
 
3879
                /* what node are we on? */
 
3880
                node = bproc_currnode();
 
3881
                /* only perform the stat check when we're
 
3882
                 * running on the master; since the slave
 
3883
                 * nodes typically don't contain binaries,
 
3884
                 * the stat call is more than likely to fail
 
3885
                 * anyway; down below we perform some bproc
 
3886
                 * magic to "find" the binary back on the
 
3887
                 * master when we're running on a slave
 
3888
                 */
 
3889
                if(node == BPROC_NODE_MASTER)
 
3890
#endif
3514
3891
                if (stat(path, &sb) == -1
3515
3892
                                || ((sb.st_mode & S_IFMT) != S_IFREG)
3516
3893
                                || !(sb.st_mode & S_IEXEC)) {
3626
4003
                                        execv(argv[0], argv);
3627
4004
 
3628
4005
                                } else {
 
4006
#ifdef IMA_BEOSCYLD
 
4007
                                  /* if we're running on the master */
 
4008
                                  if(node == BPROC_NODE_MASTER) {
 
4009
                                    /* simply call execv */
 
4010
                                    execv(path,argv);
 
4011
                                  }
 
4012
                                  /* if we're running on a slave node */
 
4013
                                  else {
 
4014
                                    /* migrate process back to the master */
 
4015
                                    if(bproc_move(BPROC_NODE_MASTER) != -1) {
 
4016
                                      /* locate the executable */
 
4017
                                      for(ep = eplist; *ep; ep++) {
 
4018
                                        strcpy(path,*ep);
 
4019
                                        if(path[0]) strcat(path,"/");
 
4020
                                        strncat(path,name,sizeof(path)-strlen(path)-1);
 
4021
                                        if((stat(path,&sb) == -1) ||
 
4022
                                           ((sb.st_mode & S_IFMT) != S_IFREG) ||
 
4023
                                           !(sb.st_mode & S_IEXEC)) {
 
4024
                                          /* try the next path */
 
4025
                                          continue;
 
4026
                                        }
 
4027
                                        else {
 
4028
                                          /* execmove back to the slave */
 
4029
                                          bproc_execmove(node,path,argv,env);
 
4030
                                          /* if we get this far, the call to execmove
 
4031
                                           * failed and we now have a ghost job back
 
4032
                                           * on the slave and this whacked job on the
 
4033
                                           * master; if we exit, both jobs are cleaned
 
4034
                                           * up through the magic of bproc
 
4035
                                           */
 
4036
                                          exit(1);
 
4037
                                        }
 
4038
                                      }
 
4039
                                      /* if we fell through the loop, we didn't
 
4040
                                       * find the executable file; in this case
 
4041
                                       * we move back to the slave and return
 
4042
                                       */
 
4043
                                      if(bproc_move(node) == -1) {
 
4044
                                        /* if the move back to the slave fails,
 
4045
                                         * we have a ghost job back on the slave
 
4046
                                         * and this whacked job on the master;
 
4047
                                         * if we exit, both jobs are cleaned up
 
4048
                                         * through the magic of bproc
 
4049
                                         */
 
4050
                                        exit(1);
 
4051
                                      }
 
4052
                                      else {
 
4053
                                        /* since the move back to the slave was
 
4054
                                         * successfully and we were unable to find
 
4055
                                         * the executable back on the master, we
 
4056
                                         * mimic forkexec's normal functionality
 
4057
                                         * of ending the for-loop
 
4058
                                         */
 
4059
                                        break;
 
4060
                                      }
 
4061
                                    }
 
4062
                                    else if (pvmdebmask & PDMTASK) {
 
4063
                                      pvmlogprintf(
 
4064
                                                        "forkexec() bproc move to master failed\n");
 
4065
                                    }
 
4066
                                    /* end-if moving to master */
 
4067
                                  }
 
4068
                                  /* end-if running on a slave */
 
4069
#else
3629
4070
                                        execv(path, argv);
 
4071
#endif
3630
4072
                                }
3631
4073
                                exit(1);
3632
4074
                        }
3720
4162
                pvmlogerror("forkexec() out of tids?\n");
3721
4163
                return PvmOutOfRes;
3722
4164
        }
3723
 
        tp = task_new(tid);
3724
 
        // PIPE SECURITY STUFF
 
4165
        if ((tp = task_new(tid)) == NULL) {
 
4166
                pvmlogerror("forkexec() too many tasks?\n");
 
4167
                return PvmOutOfRes;
 
4168
        }
 
4169
        /* PIPE SECURITY STUFF */
3725
4170
  
3726
4171
           InitializeSecurityDescriptor(&SecDescript,SECURITY_DESCRIPTOR_REVISION);
3727
4172
           SetSecurityDescriptorDacl(&SecDescript,TRUE,NULL,FALSE);
3728
4173
  
3729
 
          // Set the bInheritHandle flag so pipe handles are inherited. 
 
4174
          /* Set the bInheritHandle flag so pipe handles are inherited.  */
3730
4175
   
3731
4176
           saAttr.nLength = sizeof(SECURITY_ATTRIBUTES); 
3732
4177
           saAttr.bInheritHandle = TRUE; 
3733
4178
           saAttr.lpSecurityDescriptor = &SecDescript; 
3734
4179
   
3735
 
          // The steps for redirecting child process's STDOUT: 
3736
 
          //     1. Save current STDOUT, to be restored later. 
3737
 
          //     2. Create anonymous pipe to be STDOUT for child process. 
3738
 
          //     3. Set STDOUT of the parent process to be write handle of 
3739
 
          //        the pipe, so it is inherited by the child process. 
3740
 
          //     4. Create a noninheritable duplicate of the read handle and
3741
 
          //        close the inheritable read handle. 
 
4180
          /*
 
4181
          The steps for redirecting child process's STDOUT: 
 
4182
               1. Save current STDOUT, to be restored later. 
 
4183
               2. Create anonymous pipe to be STDOUT for child process. 
 
4184
               3. Set STDOUT of the parent process to be write handle of 
 
4185
                  the pipe, so it is inherited by the child process. 
 
4186
               4. Create a noninheritable duplicate of the read handle and
 
4187
                  close the inheritable read handle. 
 
4188
          */
3742
4189
   
3743
 
          // Save the handle to the current STDOUT. 
 
4190
          /* Save the handle to the current STDOUT.  */
3744
4191
   
3745
4192
          hSaveStdout = GetStdHandle(STD_OUTPUT_HANDLE); 
3746
4193
          if (! CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 0)) 
3747
4194
                        pvmlogprintf("Stdout pipe creation failed\n"); 
3748
4195
   
3749
 
        // Set a write handle to the pipe to be STDOUT. 
 
4196
        /* Set a write handle to the pipe to be STDOUT.  */
3750
4197
   
3751
4198
           if (! SetStdHandle(STD_OUTPUT_HANDLE, hChildStdoutWr)) 
3752
4199
                        pvmlogprintf("Redirecting STDOUT failed"); 
3753
4200
   
3754
 
        // Create noninheritable read handle and close the inheritable read 
3755
 
        // handle. 
 
4201
        /* Create noninheritable read handle and close the inheritable */
 
4202
        /* read handle.  */
3756
4203
  
3757
4204
            fSuccess = DuplicateHandle(GetCurrentProcess(), hChildStdoutRd,
3758
4205
                GetCurrentProcess(), &hChildStdoutRdDup , 0,
3762
4209
                pvmlogprintf("DuplicateHandle failed");
3763
4210
            CloseHandle(hChildStdoutRd);
3764
4211
  
3765
 
        // The steps for redirecting child process's STDIN: 
3766
 
        //     1.  Save current STDIN, to be restored later. 
3767
 
        //     2.  Create anonymous pipe to be STDIN for child process. 
3768
 
        //     3.  Set STDIN of the parent to be the read handle of the 
3769
 
        //         pipe, so it is inherited by the child process. 
3770
 
        //     4.  Create a noninheritable duplicate of the write handle, 
3771
 
        //         and close the inheritable write handle. 
 
4212
        /*
 
4213
        The steps for redirecting child process's STDIN: 
 
4214
             1.  Save current STDIN, to be restored later. 
 
4215
             2.  Create anonymous pipe to be STDIN for child process. 
 
4216
             3.  Set STDIN of the parent to be the read handle of the 
 
4217
                 pipe, so it is inherited by the child process. 
 
4218
             4.  Create a noninheritable duplicate of the write handle, 
 
4219
                 and close the inheritable write handle. 
 
4220
        */
3772
4221
   
3773
 
        // Save the handle to the current STDIN. 
 
4222
        /* Save the handle to the current STDIN.  */
3774
4223
   
3775
4224
           hSaveStdin = GetStdHandle(STD_INPUT_HANDLE); 
3776
4225
   
3777
 
        // Create a pipe for the child process's STDIN. 
 
4226
        /* Create a pipe for the child process's STDIN.  */
3778
4227
   
3779
4228
           if (! CreatePipe(&hChildStdinRd, &hChildStdinWr, &saAttr, 0)) 
3780
4229
                        pvmlogprintf("Stdin pipe creation failed\n"); 
3781
4230
   
3782
 
        // Set a read handle to the pipe to be STDIN. 
 
4231
        /* Set a read handle to the pipe to be STDIN.  */
3783
4232
   
3784
4233
           if (! SetStdHandle(STD_INPUT_HANDLE, hChildStdinRd)) 
3785
4234
                        pvmlogprintf("Redirecting Stdin failed"); 
3786
4235
   
3787
 
        // Duplicate the write handle to the pipe so it is not inherited. 
 
4236
        /* Duplicate the write handle to the pipe so it is not inherited. */
3788
4237
   
3789
4238
           fSuccess = DuplicateHandle(GetCurrentProcess(), hChildStdinWr, 
3790
4239
                        GetCurrentProcess(), &hChildStdinWrDup, 0, 
3791
 
                FALSE,                  // not inherited 
 
4240
                FALSE,                  /* not inherited */
3792
4241
                        DUPLICATE_SAME_ACCESS); 
3793
4242
           if (! fSuccess) 
3794
4243
                        pvmlogprintf("DuplicateHandle failed"); 
3798
4247
  
3799
4248
        /* search for file */
3800
4249
 
3801
 
        chdir(pvmgetroot());
3802
4250
        strcpy(filename,name);          /* store the filename */
3803
4251
 
3804
4252
        eplist = CINDEX(filename, '/') ? nullep : epaths;
4388
4836
#endif
4389
4837
        char *p;
4390
4838
#ifdef SOCKLENISUINT
4391
 
#ifdef IMA_AIX4SP2
 
4839
#if defined(IMA_AIX4SP2) || defined(IMA_AIX5SP2) \
 
4840
                || defined(IMA_AIX56K64) || defined(IMA_LINUXALPHA)
4392
4841
        unsigned int oslen;
4393
4842
#else
4394
4843
        size_t oslen;
4398
4847
#endif
4399
4848
        int cc;
4400
4849
#ifndef NOUNIXDOM
4401
 
        char spath[LEN_OF_TMP_NAM];     /* local socket path */
 
4850
        char spath[PVMTMPNAMLEN];       /* local socket path */
4402
4851
        struct sockaddr_un uns;
4403
4852
#endif
 
4853
#ifdef IMA_BEOLIN
 
4854
        struct hostent *hostaddr;
 
4855
#endif
 
4856
        short tmpp;
4404
4857
 
4405
4858
        /*
4406
4859
        * make pvmd-pvmd socket
4411
4864
                return 1;
4412
4865
        }
4413
4866
 
4414
 
        hp->hd_sad.sin_port = 0;
4415
 
        oslen = sizeof(hp->hd_sad);
4416
 
        if (bind(netsock, (struct sockaddr*)&hp->hd_sad, oslen) == -1)
 
4867
        p = getenv("PVMNETSOCKPORT");
 
4868
 
 
4869
        tmpp = (p) ? atoi(p) : 0;
 
4870
 
 
4871
        hp->hd_sad.sin_port = htons(tmpp);
 
4872
 
 
4873
        do
4417
4874
        {
 
4875
                oslen = sizeof(hp->hd_sad);
 
4876
                if ((cc=bind(netsock, (struct sockaddr*)&hp->hd_sad, oslen))
 
4877
                                == -1)
 
4878
                {
 
4879
                        if (p) {
 
4880
                                tmpp++;
 
4881
                                hp->hd_sad.sin_port = htons(tmpp);
 
4882
                        } else {
 
4883
                                pvmlogperror("mksocs() bind netsock");
 
4884
                                return 1;
 
4885
                        }
 
4886
                }
 
4887
        }
 
4888
        while ( cc == -1 && p && hp->hd_sad.sin_port < 65535 );
 
4889
 
 
4890
        if ( cc == -1 ) {
4418
4891
                pvmlogperror("mksocs() bind netsock");
4419
4892
                return 1;
4420
4893
        }
 
4894
 
4421
4895
        oslen = sizeof(hp->hd_sad);
4422
4896
        if (getsockname(netsock, (struct sockaddr*)&hp->hd_sad, &oslen) == -1) {
4423
4897
                pvmlogperror("mksocs() getsockname netsock");
4461
4935
        */
4462
4936
 
4463
4937
        BZERO((char*)&sin, sizeof(sin));
4464
 
#if defined(IMA_SP2MPI) || defined(IMA_AIX4SP2)
 
4938
#if defined(IMA_SP2MPI) || defined(IMA_AIX4SP2) || defined(IMA_AIX5SP2)
4465
4939
        sin = hp->hd_sad;               /* allow task to connect from a node */
4466
4940
#else
 
4941
 
 
4942
#ifdef IMA_BEOLIN
 
4943
        /* allow connection from another node */
 
4944
        sin.sin_family = AF_INET;
 
4945
        if (gethostname(buf, sizeof(buf)-1) == -1) {
 
4946
                pvmlogerror("mksocs() can't gethostname()\n");
 
4947
                return 1;
 
4948
        } else {
 
4949
                /* got name, now get addr */
 
4950
                if (!(hostaddr = gethostbyname( buf ))) {
 
4951
                        pvmlogprintf( "mksocs() can't gethostbyname() for %s\n", buf );
 
4952
                        return 1;
 
4953
                } else {
 
4954
                        /* got addr, now save it */
 
4955
                        BCOPY( hostaddr->h_addr_list[0], (char*)&sin.sin_addr,
 
4956
                                        sizeof(struct in_addr));
 
4957
                }
 
4958
        }
 
4959
        sin.sin_port = 0;
 
4960
#else
4467
4961
        sin.sin_family = AF_INET;
4468
4962
        sin.sin_addr.s_addr = htonl(0x7f000001);
4469
4963
        sin.sin_port = 0;
4470
4964
#endif
4471
4965
 
 
4966
#endif
 
4967
 
4472
4968
        oslen = sizeof(sin);
4473
4969
        if (bind(loclsock, (struct sockaddr*)&sin, oslen) == -1) {
4474
4970
                sin = hp->hd_sad;
4515
5011
        BZERO((char*)&uns, sizeof(uns));
4516
5012
        uns.sun_family = AF_UNIX;
4517
5013
        spath[0] = 0;
4518
 
        (void)TMPNAMFUN(spath);
 
5014
        (void)PVMTMPNAMFUN(spath);
4519
5015
        strcpy(uns.sun_path, spath);
4520
5016
/*
4521
5017
XXX len?
4715
5211
 
4716
5212
                        vv = getenv(vn);
4717
5213
 
 
5214
#ifdef WIN32
 
5215
                        if (!vv)
 
5216
                                vv = (char *) read_pvmregistry(vn);
 
5217
#endif
 
5218
 
4718
5219
                        *p = c;
4719
5220
                        if (*p == '}')
4720
5221
                                p++;
4805
5306
        if (argc == 2) {
4806
5307
                filehosts = readhostfile(argv[1]);
4807
5308
        }
 
5309
        else if (s = getenv("PVMHOSTFILE")) {
 
5310
                filehosts = readhostfile(s);
 
5311
        }
4808
5312
        if (pvmdebmask & PDMSTARTUP) {
4809
5313
                if (filehosts) {
4810
5314
                        pvmlogerror("master_config() host file:\n");
4897
5401
                        (void)close(i);
4898
5402
 
4899
5403
        /* reopen 0, 1, 2*/
4900
 
 
4901
5404
        (void)open("/dev/null", O_RDONLY, 0);
4902
5405
        (void)open("/dev/null", O_WRONLY, 0);
4903
5406
        (void)dup2(1, 2);
5016
5519
        fflush(stdout);
5017
5520
 
5018
5521
#ifndef WIN32
5019
 
#ifndef IMA_OS2
 
5522
 
 
5523
#if !defined(IMA_OS2) && !defined(CYGWIN)
5020
5524
        if (!ms)
5021
5525
                (void)read(0, (char*)&i, 1);
5022
5526
#endif