Changeset 36994
- Timestamp:
- Jul 10, 2014, 1:46:47 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140610/Ohana/src/libkapa/src/KapaOpen.c
r36944 r36994 1 1 # include "kapa_internal.h" 2 3 // kapa connection timeout is N_RETRY * 10000 usec 4 # define N_RETRY 2000 2 5 3 6 # define MY_PORT 2500 … … 282 285 } 283 286 284 # define NTRY 1000 287 INITTIME; 288 285 289 Ntry = 0; 286 while (Ntry < N TRY) {290 while (Ntry < N_RETRY) { 287 291 sock = KapaClientSocket ("localhost"); 288 292 if (sock != -1) break; … … 307 311 } 308 312 309 if (sock < 0) return (-1); 313 if (sock < 0) { 314 MARKTIME ("failed to connect to kapa after %f seconds\n", dtime); 315 int killStatus = kill (pid, SIGKILL); 316 if (killStatus) { 317 perror ("failed to kill process"); 318 } 319 int waitStatus = waitpid (pid, NULL, 0); 320 if (waitStatus == pid) { 321 fprintf (stderr, "harvested process %d\n", pid); 322 } else if (waitStatus < 0) { 323 fprintf (stderr, "failed to harvest process %d\n", pid); 324 } else if (waitStatus == 0) { 325 fprintf (stderr, "process not exited: %d\n", pid); 326 } else { 327 fprintf (stderr, "odd exit status: %d vs pid %d\n", waitStatus, pid); 328 } 329 return (-1); 330 } 331 310 332 return (sock); 311 333 } … … 349 371 fcntl (InitSocket, F_SETFL, O_NONBLOCK); 350 372 351 # define NTRY 1000 373 INITTIME; 374 352 375 Ntry = 0; 353 while (Ntry < N TRY) {376 while (Ntry < N_RETRY) { 354 377 fd = accept (InitSocket, (struct sockaddr *)&Address, &AddressLength); 355 378 if (fd != -1) break; … … 371 394 } 372 395 373 if (fd < 0) return (-1); 396 if (fd < 0) { 397 MARKTIME ("failed to connect to kapa after %f seconds\n", dtime); 398 kill (pid, SIGKILL); 399 waitpid (pid, NULL, WNOHANG); 400 return (-1); 401 } 374 402 375 403 // the client uses a BLOCKing socket by default
Note:
See TracChangeset
for help on using the changeset viewer.
