IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 37548


Ignore:
Timestamp:
Nov 2, 2014, 3:38:46 PM (12 years ago)
Author:
eugene
Message:

handle some I/O failures

Location:
branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/dvo_catalog.c

    r37521 r37548  
    573573
    574574  if (catalog[0].f == (FILE *) NULL) return (2);
    575   fflush (catalog[0].f);
     575
     576  if (fflush (catalog[0].f)) {
     577    fprintf (stderr, "failed to flush file\n");
     578    return FALSE;
     579  }
     580
    576581  // fprintf (stderr, "unlocking: %s\n", catalog[0].filename);
    577582
     
    585590
    586591  // closes f but does not set back to NULL
    587   fclearlockfile (catalog[0].filename, catalog[0].f, catalog[0].lockmode, &dbstate);
     592  if (!fclearlockfile (catalog[0].filename, catalog[0].f, catalog[0].lockmode, &dbstate)) {
     593    fprintf (stderr, "failed to unlock or close file\n");
     594    return (0);
     595  }
    588596
    589597  if (catalog[0].catmode == DVO_MODE_SPLIT) {
    590     if (catalog[0].measure_catalog) dvo_catalog_unlock (catalog[0].measure_catalog);
    591     if (catalog[0].missing_catalog) dvo_catalog_unlock (catalog[0].missing_catalog);
    592     if (catalog[0].secfilt_catalog) dvo_catalog_unlock (catalog[0].secfilt_catalog);
    593     if (catalog[0].lensing_catalog) dvo_catalog_unlock (catalog[0].lensing_catalog);
    594     if (catalog[0].lensobj_catalog) dvo_catalog_unlock (catalog[0].lensobj_catalog);
    595     if (catalog[0].starpar_catalog) dvo_catalog_unlock (catalog[0].starpar_catalog);
     598    if (catalog[0].measure_catalog) { if (!dvo_catalog_unlock (catalog[0].measure_catalog)) { fprintf (stderr, "failed to unlock measures\n"); return (0); }}
     599    if (catalog[0].missing_catalog) { if (!dvo_catalog_unlock (catalog[0].missing_catalog)) { fprintf (stderr, "failed to unlock missing\n"); return (0); }}
     600    if (catalog[0].secfilt_catalog) { if (!dvo_catalog_unlock (catalog[0].secfilt_catalog)) { fprintf (stderr, "failed to unlock secfilt\n"); return (0); }}
     601    if (catalog[0].lensing_catalog) { if (!dvo_catalog_unlock (catalog[0].lensing_catalog)) { fprintf (stderr, "failed to unlock lensing\n"); return (0); }}
     602    if (catalog[0].lensobj_catalog) { if (!dvo_catalog_unlock (catalog[0].lensobj_catalog)) { fprintf (stderr, "failed to unlock lensobj\n"); return (0); }}
     603    if (catalog[0].starpar_catalog) { if (!dvo_catalog_unlock (catalog[0].starpar_catalog)) { fprintf (stderr, "failed to unlock starpar\n"); return (0); }}
    596604  }
    597605  return (1);
  • branches/eam_branches/ipp-20140904/Ohana/src/libdvo/src/dvo_catalog_split.c

    r37390 r37548  
    7575  Matrix matrix;
    7676
     77  // ohana_memcheck_func (TRUE);
     78
     79  if (0) {
     80    // XXX a TEST : is the data corrupted or the file?
     81    char name[1024];
     82    snprintf (name, 1024, "%s.phu.v2", catalog->filename);
     83    FILE *f = fopen (name, "w");
     84    fwrite (catalog->header.buffer, sizeof(char), catalog->header.datasize, f);
     85    // fprintf (stderr, "save %d bytes in %s (%zx)\n", (int) catalog->header.datasize, name, (size_t) catalog->header.buffer);
     86    // fprintf (stderr, "first bytes are %c%c%c%c%c%c%c%c\n",
     87    //       catalog->header.buffer[0], catalog->header.buffer[1], catalog->header.buffer[2], catalog->header.buffer[3],
     88    //       catalog->header.buffer[4], catalog->header.buffer[5], catalog->header.buffer[6], catalog->header.buffer[7]);
     89    fclose (f);
     90  }
     91  if (0) {
     92    // XXX a TEST : is the data corrupted or the file?
     93    char name[1024];
     94    snprintf (name, 1024, "%s.phu", catalog->filename);
     95    FILE *f = fopen (name, "w");
     96    fwrite (catalog->header.buffer, sizeof(char), catalog->header.datasize, f);
     97    // fprintf (stderr, "save %d bytes in %s (%zx)\n", (int) catalog->header.datasize, name, (size_t) catalog->header.buffer);
     98    // fprintf (stderr, "first bytes are %c%c%c%c%c%c%c%c\n",
     99    //       catalog->header.buffer[0], catalog->header.buffer[1], catalog->header.buffer[2], catalog->header.buffer[3],
     100    //       catalog->header.buffer[4], catalog->header.buffer[5], catalog->header.buffer[6], catalog->header.buffer[7]);
     101    fclose (f);
     102  }
     103# if (0)
     104  {
     105    // XXX a TEST : is the data corrupted or the file?
     106    char name[1024];
     107    snprintf (name, 1024, "%s.phu.v2", catalog->filename);
     108    FILE *f = fopen (name, "w");
     109    fwrite (catalog->header.buffer, sizeof(char), catalog->header.datasize, f);
     110    fprintf (stderr, "save %d bytes in %s (%zx)\n", (int) catalog->header.datasize, name, (size_t) catalog->header.buffer);
     111    fprintf (stderr, "first bytes are %c%c%c%c%c%c%c%c\n",
     112             catalog->header.buffer[0], catalog->header.buffer[1], catalog->header.buffer[2], catalog->header.buffer[3],
     113             catalog->header.buffer[4], catalog->header.buffer[5], catalog->header.buffer[6], catalog->header.buffer[7]);
     114    fclose (f);
     115  }
     116  {
     117    // XXX a TEST : is the data corrupted or the file?
     118    char name[1024];
     119    snprintf (name, 1024, "%s.phu.v3", catalog->filename);
     120    FILE *f = fopen (name, "w");
     121    fwrite (catalog->header.buffer, sizeof(char), catalog->header.datasize, f);
     122    fprintf (stderr, "save %d bytes in %s (%zx)\n", (int) catalog->header.datasize, name, (size_t) catalog->header.buffer);
     123    fprintf (stderr, "first bytes are %c%c%c%c%c%c%c%c\n",
     124             catalog->header.buffer[0], catalog->header.buffer[1], catalog->header.buffer[2], catalog->header.buffer[3],
     125             catalog->header.buffer[4], catalog->header.buffer[5], catalog->header.buffer[6], catalog->header.buffer[7]);
     126    fclose (f);
     127  }
     128# endif
    77129  /* rewind file pointers and truncate (file is still open) */
    78   fseeko (catalog->f, 0LL, SEEK_SET);
     130  if (fseeko (catalog->f, 0LL, SEEK_SET)) {
     131    perror ("dvo_catalog_save_subset: ");
     132    fprintf (stderr, "failed to seek to beginning\n");
     133  }
    79134
    80135  // write PHU header
     
    353408  /*** Secfilt Table ***/
    354409  status = dvo_catalog_open_subcat (catalog, &catalog[0].secfilt_catalog, ftable.header, "SECFILT", VERBOSE);
     410  // fprintf (stderr, "secfilt header %s : %zx\n", catalog[0].secfilt_catalog[0].filename, (size_t) catalog[0].secfilt_catalog[0].header.buffer);
    355411  if (status == DVO_CAT_OPEN_FAIL) {
    356412    return (FALSE);
Note: See TracChangeset for help on using the changeset viewer.