IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 41162


Ignore:
Timestamp:
Nov 27, 2019, 11:09:40 AM (7 years ago)
Author:
eugene
Message:

do not block on slow kapa quit; handle edge cases for splines without segfaults; add polygon and polyfill plotting styles

Location:
trunk/Ohana/src/opihi/lib.data
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/lib.data/MedImageOps.c

    r36679 r41162  
    3232  free (medimage[0].name);
    3333  for (i = 0; i < medimage[0].Ninput; i++) {
    34     free (medimage[0].buffers[i]);
     34    free (medimage[0].flx[i]);
     35    FREE (medimage[0].var[i]);
    3536  }
    36   free (medimage[0].buffers);
     37  free (medimage[0].flx);
     38  free (medimage[0].var);
    3739  free (medimage);
    3840}
     
    7577  medimage->Nx = Nx;
    7678  medimage->Ny = Ny;
    77   ALLOCATE (medimage->buffers, float *, 1);
     79  ALLOCATE (medimage->flx, float *, 1);
     80  ALLOCATE (medimage->var, float *, 1);
    7881
    7982  medimages[N] = medimage;
  • trunk/Ohana/src/opihi/lib.data/SplineOps.c

    r38441 r41162  
    4141    ALLOCATE (spline[0].y2, opihi_flt, spline[0].Nknots);
    4242  }
    43   memset (spline[0].xk, 0, spline[0].Nknots * sizeof(opihi_flt));
    44   memset (spline[0].yk, 0, spline[0].Nknots * sizeof(opihi_flt));
    45   memset (spline[0].y2, 0, spline[0].Nknots * sizeof(opihi_flt));
     43  if (spline[0].Nknots) {
     44    memset (spline[0].xk, 0, spline[0].Nknots * sizeof(opihi_flt));
     45    memset (spline[0].yk, 0, spline[0].Nknots * sizeof(opihi_flt));
     46    memset (spline[0].y2, 0, spline[0].Nknots * sizeof(opihi_flt));
     47  }
    4648}
    4749
  • trunk/Ohana/src/opihi/lib.data/open_kapa.c

    r31635 r41162  
    266266int close_kapa (char *name) {
    267267
     268  struct timespec request, remain;
    268269  int N;
    269270
     
    274275  }
    275276  DelKapaDevice (name);
     277
     278  // avoid blocking on waitpid, test every 1 msec, up to 500 msec
     279  request.tv_sec = 0;
     280  request.tv_nsec = 1000000;
     281
     282  // try to harvest the child PID
     283  int waitstatus = 0;
     284  int result = waitpid (-1, &waitstatus, WNOHANG);
     285  for (int i = 0; (i < 500) && (result == 0); i++) {
     286    nanosleep (&request, &remain);
     287    result = waitpid (-1, &waitstatus, WNOHANG);
     288  }
     289
     290  if ((result == -1) && (errno != ECHILD)) {
     291    fprintf (stderr, "unexpected error from waitpid (%d): programming error\n", errno);
     292  }
     293  if (result == 0) {
     294    fprintf (stderr, "child did not exit (close_kapa), timeout");
     295  }
     296
    276297  return (TRUE);
    277298}
  • trunk/Ohana/src/opihi/lib.data/spline.c

    r39231 r41162  
    77  float dy, dx, *tmp;
    88 
     9  // spline is not valid with < 3 points
     10  if (N < 3) return;
     11
    912  ALLOCATE (tmp, float, N);
    1013
     
    6972  opihi_flt dy, dx, *tmp;
    7073 
     74  // spline is not valid with < 3 points
     75  if (N < 3) return;
     76
    7177  ALLOCATE (tmp, opihi_flt, N);
    7278
  • trunk/Ohana/src/opihi/lib.data/starfuncs.c

    r40398 r41162  
    7575  FWHMx = 2.355*sqrt (fabs(x2 / I - x*x));
    7676  FWHMy = 2.355*sqrt (fabs(y2 / I - y*y));
     77
     78  fprintf (stderr, "Mxx, Myy: %f, %f\n", x2/I - x*x, y2/I - y*y);
    7779  Sxy   = xy / I - x*y;
    7880  mag = -2.5*log10(I);
  • trunk/Ohana/src/opihi/lib.data/style_args.c

    r40570 r41162  
    7272  }
    7373
     74  if ((graphmode[0].style == KAPA_PLOT_POLYGON) || (graphmode[0].style == KAPA_PLOT_POLYFILL)) {
     75    if ((N = get_argument (*argc, argv, "-npoint"))) {
     76      remove_argument (N, argc, argv);
     77      graphmode[0].ptype = atoi (argv[N]);
     78      remove_argument (N, argc, argv);
     79    } else {
     80      gprint (GP_ERR, "polygon & polyfill styles require number of points argument: -npoint N\n");
     81      return FALSE;
     82    }
     83  }
    7484  return (TRUE);
    7585}
Note: See TracChangeset for help on using the changeset viewer.