- Timestamp:
- Feb 6, 2012, 6:50:18 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/HostTableLoad.c
r33203 r33204 1 1 # include "photdbc.h" 2 # define DEBUG 1 2 3 3 4 typedef struct { … … 48 49 InitHosts (hosts, Nhosts, NHOSTS); 49 50 51 int maxID = 0; 52 50 53 int Nline; 51 54 for (Nline = 0; TRUE; Nline ++) { … … 69 72 } 70 73 74 // check the validity of ID (0 < ID < MAX_SHORT) 75 76 if (ID < 1) { 77 fprint (stderr, "invalid host ID %d\n", ID); 78 exit (1); 79 } 80 if (ID > 65535) { 81 fprint (stderr, "invalid host ID %d\n", ID); 82 exit (1); 83 } 84 maxID = MAX(maxID, ID); 85 71 86 hosts[Nhosts].hostID = ID; 72 87 hosts[Nhosts].hostname = strcreate(tmphost); … … 85 100 table->hosts = hosts; 86 101 102 ALLOCATE (table->index, unsigned short, maxID + 1); 103 for (i = 0; i <= maxID; i++) table->index[i] = -1; 104 105 for (i = 0; i < table->Nhosts; i++) { 106 if (table->index[table->hosts[i].hostID] == -1) { 107 fprintf (stderr, "error: duplicate hostID %d\n", table->hosts[i].hostID); 108 exit (1); 109 } 110 table->index[table->hosts[i].hostID] = i; 111 } 112 87 113 return table; 88 114 } … … 90 116 int CheckHostsAndPaths (HostTable *table) { 91 117 118 int i; 119 int stdio[3]; 92 120 char command[64]; 93 121 char shell[64]; 94 122 95 123 strcpy (command, "ssh"); 96 strcpy (shell, " pclient");124 strcpy (shell, "csh"); 97 125 98 126 for (i = 0; i < table->Nhosts; i++) { … … 101 129 if (DEBUG) fprintf (stderr, "starting host within thread\n"); 102 130 103 pid = rconnect (command, host[0].hostname, shell, stdio);131 pid = rconnect (command, table->hosts[i].hostname, shell, stdio); 104 132 if (!pid) { 105 133 /** failure to start: extend retry period **/ 106 134 if (DEBUG) fprintf (stderr, "failure to start %s\n", table->hosts[i].hostname); 135 exit (1); 107 136 } 137 138 // XXX check anything else? 139 140 // close the connection 141 close(stdio[0]); 142 close(stdio[1]); 143 close(stdio[2]); 144 145 status = check_dir_access (table->hosts[i].pathname, DEBUG); 146 if (!status) { 147 fprintf (stderr, "failed to find / create target path\n"); 148 exit (2); 149 } 150 151 fprintf (stderr, "success : %s, %s\n", table->hosts[i].hostname, table->hosts[i].pathname); 108 152 } 109 153 return (TRUE); 110 154 }
Note:
See TracChangeset
for help on using the changeset viewer.
