IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36994


Ignore:
Timestamp:
Jul 10, 2014, 1:46:47 PM (12 years ago)
Author:
eugene
Message:

use a long wait time for launching kapa: up to 20 seconds since some connections are very slow; better handling if mana fails to start

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140610/Ohana/src/libkapa/src/KapaOpen.c

    r36944 r36994  
    11# include "kapa_internal.h"
     2
     3// kapa connection timeout is N_RETRY * 10000 usec
     4# define N_RETRY 2000
    25
    36# define MY_PORT 2500
     
    282285  }
    283286
    284 # define NTRY 1000
     287  INITTIME;
     288
    285289  Ntry = 0;
    286   while (Ntry < NTRY) {
     290  while (Ntry < N_RETRY) {
    287291    sock = KapaClientSocket ("localhost");
    288292    if (sock != -1) break;
     
    307311  }
    308312
    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
    310332  return (sock);
    311333}
     
    349371  fcntl (InitSocket, F_SETFL, O_NONBLOCK);
    350372
    351 # define NTRY 1000
     373  INITTIME;
     374
    352375  Ntry = 0;
    353   while (Ntry < NTRY) {
     376  while (Ntry < N_RETRY) {
    354377    fd = accept (InitSocket, (struct sockaddr *)&Address, &AddressLength);
    355378    if (fd != -1) break;
     
    371394  }
    372395
    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  }
    374402
    375403  // the client uses a BLOCKing socket by default
Note: See TracChangeset for help on using the changeset viewer.