return 1;
}
-int save_job(unsigned char dc) {
+int save_job(unsigned char dc,unsigned char *ack) {
char filename[128];
int fd;
network_receive_chan(&(priv.net),gi,(unsigned char *)j->cc,
j->size*sizeof(int));
network_receive_chan(&(priv.net),gi,(unsigned char *)&(j->step),sizeof(int));
+ network_receive_chan(&(priv.net),gi,ack,sizeof(unsigned char));
if(dc!=DC_QUIT) {
- snprintf(filename,128,"./data/nlsop_b%f_c%f_s%f_ds%d_dr%f_-_%d_of_%d.save",
- j->info.b,j->info.c,j->info.s,
- j->info.diff_rate,j->info.dr_ac,
- j->step,j->info.steps);
+ if(*ack==DATA_OK)
+ snprintf(filename,128,
+ "./data/nlsop_b%f_c%f_s%f_ds%d_dr%f_-_%d_of_%d.save",
+ j->info.b,j->info.c,j->info.s,
+ j->info.diff_rate,j->info.dr_ac,
+ j->step,j->info.steps);
+ else
+ snprintf(filename,128,
+ "./data/nlsop_b%f_c%f_s%f_ds%d_dr%f_-_%d_of_%d.corrupt",
+ j->info.b,j->info.c,j->info.s,
+ j->info.diff_rate,j->info.dr_ac,
+ j->step,j->info.steps);
if((fd=open(filename,O_WRONLY|O_CREAT))<0) {
printf("FATAL: unable to open file %s\n",filename);
return -1;
unsigned char data;
t_client *c;
t_job *j;
+ unsigned char ack;
for(gi=0;gi<MAX_CONNECTIONS;gi++) {
if(FD_ISSET(priv.net.connection[gi].fd,&(priv.event.rfds))) {
c=(t_client *)priv.client.current->data;
if(data==DC_END) {
- save_job(DC_END);
+ save_job(DC_END,&ack);
/* reset client */
c->status=IDLE;
/* free job memory */
}
if(data==DC_OK) {
- save_job(DC_OK);
+ save_job(DC_OK,&ack);
/* inc progress state */
j->progress+=1;
printf("job at next level, saved.\n");
}
if(data==DC_QUIT) {
- save_job(DC_QUIT);
+ ack=0;
+ save_job(DC_QUIT,&ack);
/* network disconnect */
event_math(priv.net.connection[gi].fd,&(priv.event),READ,REMOVE);
network_close(&(priv.net),gi);
/* del from client list */
list_del_current(&(priv.client));
- /* change job state */
- j->status=IN_QUEUE;
- printf("client terminating, job queued, client removed.\n");
+ /* change job state (or reset it if corrupted) */
+ if(ack==DATA_OK) {
+ j->status=IN_QUEUE;
+ printf("client terminating, job queued, client removed.\n");
+ }
+ else {
+ j->channel=-1;
+ j->status=IN_QUEUE;
+ j->progress=0;
+ j->step=0;
+ printf("client terminating, corr. job cleared , client removed.\n");
+ }
}
}
j->channel=-1;
j->status=IN_QUEUE;
j->progress=0;
+ j->step=0;
}
if(list_search_data(&(priv.gui),&gi,sizeof(int))==L_SUCCESS) {
list_del_current(&(priv.gui));