IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 24, 2012, 2:28:07 PM (14 years ago)
Author:
eugene
Message:

handle failures more gracefully

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20111122/Ohana/src/photdbc/src/CopyToHostLocation.c

    r33368 r33369  
    9292    valid:
    9393      // read srcname, write to tgtname, get MD5 sum for srcname as we go:
     94      // XXX files that fail here should be skipped (but don't give up)
    9495      if (!get_md5_with_copy (srcname, tgtname, srcDigest)) {
    9596        fprintf (stderr, "error reading %s, getting md5, or writing %s\n", srcname, tgtname);
     
    99100       
    100101      // need to re-open and re-read tgtname to check md5sum
     102      // XXX files that fail here need to be checked
    101103      char *absname = abspath (tgtname, 1024);
    102104      if (!get_md5_from_pclient (host, absname, tgtDigest)) {
     
    233235  // fprintf (stderr, "command: %s\n", line);
    234236
    235   // start the md5sum command
    236237  InitIOBuffer (&buffer, 100);
    237   PclientCommand (host, line, &buffer);
    238   PclientResponse (host, PCLIENT_PROMPT, &buffer);
    239   // XXX for the moment, abort if anything goes wrong
    240 
    241   // wait for result
    242238  InitIOBuffer (&stdout_buf, 100);
    243239  InitIOBuffer (&stderr_buf, 100);
     240
     241  // need to reset pclient for next command...
     242  if (!PclientCommand (host, "reset", &buffer)) goto escape;
     243  if (!PclientResponse (host, PCLIENT_PROMPT, &buffer)) goto escape;
     244  FlushIOBuffer (&buffer);
     245
     246  // start the md5sum command
     247  if (!PclientCommand (host, line, &buffer)) goto escape;
     248  if (!PclientResponse (host, PCLIENT_PROMPT, &buffer)) goto escape;
     249  // XXX for the moment, abort if anything goes wrong
     250
     251  // wait for result
    244252  while (!CheckBusyJob (host, &stdout_buf, &stderr_buf)) {
     253    FlushIOBuffer (&stdout_buf);
     254    FlushIOBuffer (&stdout_buf);
    245255    usleep (10000);
    246256  }
    247257  if (stderr_buf.Nbuffer) {
    248258    fprintf (stderr, "error in md5sum: %s\n", stderr_buf.buffer);
    249     exit (1);
     259    goto escape;
    250260  }
    251261
     
    267277 
    268278  // need to reset pclient for next command...
    269   PclientCommand (host, "reset", &buffer);
    270   PclientResponse (host, PCLIENT_PROMPT, &buffer);
     279  if (!PclientCommand (host, "reset", &buffer)) goto escape;
     280  if (!PclientResponse (host, PCLIENT_PROMPT, &buffer)) goto escape;
    271281
    272282  return TRUE;
     283
     284escape:
     285  FreeIOBuffer (&buffer);
     286  FreeIOBuffer (&stdout_buf);
     287  FreeIOBuffer (&stderr_buf);
     288  return FALSE;
    273289}
    274290
Note: See TracChangeset for help on using the changeset viewer.