added proper error handling. daemon will shut down on critical errors. additionally use the lockfile to mark errors requiring manuel intervention and keep the daemon from restarting.
syslog(LOG_CRIT,"Error getting file stats for lock file: %m");
return-1;
}
if(sb.st_size){
syslog(LOG_CRIT,"Non-empty lock file '%s' detected, refusing to start. Examine its contents to learn about the cause, and then delete it to clear the error",MEDIATOR_LOCK_FILE);
return-1;
}
return0;
}
@ -206,15 +216,12 @@ int main(int argc, char **argv)
last_count=mediator_count;
if(medmysql_fetch_callids(&callids,&id_count)!=0)
{
/* TODO: error processing? */
sleep(config_interval);
continue;
break;
}
if(id_count>0)
{
medmysql_batch_start(&batches);
if(medmysql_batch_start(&batches))
break;
/*syslog(LOG_DEBUG, "Processing %"PRIu64" accounting record group(s).", id_count);*/
for(i=0;i<id_count&&!mediator_shutdown;++i)
@ -224,15 +231,10 @@ int main(int argc, char **argv)