IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35370


Ignore:
Timestamp:
Apr 5, 2013, 6:35:38 AM (13 years ago)
Author:
eugene
Message:

add error handing to insert detections (localhost case)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130307/Ohana/src/dvopsps/src/insert_detections_dvopsps.c

    r35351 r35370  
    199199
    200200    for (i = 0; i < table->Nhosts; i++) {
    201       while ((detections = DetectionsLoad (table->hosts[i].results, &Ndetections)) == NULL) {
     201      if ((detections = DetectionsLoad (table->hosts[i].results, &Ndetections)) == NULL) {
    202202        // failed to get the data from this host.  This can happen for various reasons.  Give the user a chance to try again...
     203        // fprintf (stderr, "you may run the command manually\n");
    203204        fprintf (stderr, "failed to read data from %s\n", table->hosts[i].hostname);
    204         fprintf (stderr, "you may run the command manually\n");
     205        return FALSE;
    205206      }
    206207      free (table->hosts[i].results);
    207208      table->hosts[i].results = NULL;
    208209   
    209       insert_detections_mysql_array (mysql, detections, Ndetections);
     210      if (!insert_detections_mysql_array (mysql, detections, Ndetections)) {
     211        fprintf (stderr, "failed to insert data for %s\n", table->hosts[i].hostname);
     212        return FALSE;
     213      }
    210214
    211215      free (detections);
     
    228232  insert_detections_mysql_init (&buffer);
    229233
     234  int status = TRUE;
     235
    230236  gettimeofday (&start, (void *) NULL);
    231237  for (i = 0; i < Ndetections; i++) {
     
    234240    insert_detections_mysql_detvalue (&buffer, &detections[i]);
    235241    if (buffer.Nbuffer > MAX_BUFFER) {
    236       insert_detections_mysql_commit (&buffer, mysql);
     242      if (!insert_detections_mysql_commit (&buffer, mysql)) {
     243        fprintf (stderr, "failure to insert detections in mysql (commit)\n");
     244        status = FALSE;
     245      }
    237246      buffer.Nbuffer = 0;
    238247      bzero (buffer.buffer, buffer.Nalloc);
     
    240249    }
    241250  }
    242   insert_detections_mysql_commit (&buffer, mysql);
     251  if (!insert_detections_mysql_commit (&buffer, mysql)) {
     252    fprintf (stderr, "failure to insert detections in mysql (commit 2)\n");
     253    status = FALSE;
     254  }
    243255  FreeIOBuffer (&buffer);
    244256
     257  if (!status) {
     258    MARKTIME("-- failed to insert %d rows in %f sec\n", Ndetections, dtime);
     259    return FALSE;
     260  }
     261
    245262  MARKTIME("-- inserted %d rows in %f sec\n", Ndetections, dtime);
    246   return (TRUE);
     263  return TRUE;
    247264}
    248265
Note: See TracChangeset for help on using the changeset viewer.