Changeset 35370
- Timestamp:
- Apr 5, 2013, 6:35:38 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130307/Ohana/src/dvopsps/src/insert_detections_dvopsps.c
r35351 r35370 199 199 200 200 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) { 202 202 // 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"); 203 204 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; 205 206 } 206 207 free (table->hosts[i].results); 207 208 table->hosts[i].results = NULL; 208 209 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 } 210 214 211 215 free (detections); … … 228 232 insert_detections_mysql_init (&buffer); 229 233 234 int status = TRUE; 235 230 236 gettimeofday (&start, (void *) NULL); 231 237 for (i = 0; i < Ndetections; i++) { … … 234 240 insert_detections_mysql_detvalue (&buffer, &detections[i]); 235 241 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 } 237 246 buffer.Nbuffer = 0; 238 247 bzero (buffer.buffer, buffer.Nalloc); … … 240 249 } 241 250 } 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 } 243 255 FreeIOBuffer (&buffer); 244 256 257 if (!status) { 258 MARKTIME("-- failed to insert %d rows in %f sec\n", Ndetections, dtime); 259 return FALSE; 260 } 261 245 262 MARKTIME("-- inserted %d rows in %f sec\n", Ndetections, dtime); 246 return (TRUE);263 return TRUE; 247 264 } 248 265
Note:
See TracChangeset
for help on using the changeset viewer.
