X-Git-Url: https://hackdaworld.org/gitweb/?p=physik%2Fnlsop.git;a=blobdiff_plain;f=nlsop_server.c;h=71eabf6520d07eeac6ca48d3301faf90339aa825;hp=847249106dc42bf923ded9f61be6fd1ee1a1e2ca;hb=e44beb74d37e473b68faa45d2d2406ca1d847080;hpb=cff0722b1d71b922fde2de222ece99e0b26a5524 diff --git a/nlsop_server.c b/nlsop_server.c index 8472491..71eabf6 100644 --- a/nlsop_server.c +++ b/nlsop_server.c @@ -56,6 +56,7 @@ int *gi; t_net *gnet; t_event *gevent; t_list *gc_list; +t_list *gg_list; int alert; /* @@ -111,6 +112,8 @@ int add_node(t_net *net,t_event *event,t_list *c_list,t_list *g_list) { /* if we have a new node - care for it! */ event_math(net->connection[channel].fd,event,READ,ADD); + printf("\n"); + return 1; } @@ -204,6 +207,9 @@ int add_job(t_net *net,int chan,t_list *jl) { job.step=0; list_add_element(jl,&job,sizeof(t_job)); + + printf("job added: b=%f | c=%f | s=%f ...\n", + job.info.b,job.info.c,job.info.s); return 1; } @@ -215,8 +221,11 @@ int send_status(t_net *net,int chan,t_list *jl) { int i; data=GUI_INFO; + count=list_count(jl); + printf("sending job info\n"); + network_send_chan(net,chan,&data,sizeof(unsigned char)); network_send_chan(net,chan,(unsigned char *)&count,sizeof(int)); @@ -261,12 +270,14 @@ int handle_node(t_net *net,t_event *event, c->status=IDLE; /* delete job entry */ list_del_current(job); + printf("job ended, saved and removed from list.\n"); } if(data==DC_OK) { save_job(net,i,j,DC_OK); /* inc progress state */ j->progress+=1; + printf("job at next level, saved.\n"); } if(data==DC_QUIT) { @@ -278,6 +289,7 @@ int handle_node(t_net *net,t_event *event, list_del_current(c_list); /* change job state */ j->status=IN_QUEUE; + printf("client terminating, job queued, client removed.\n"); } } @@ -307,6 +319,8 @@ int handle_node(t_net *net,t_event *event, } } } + + printf("\n"); return 1; } @@ -315,7 +329,7 @@ int distribute_jobs(t_event *event,void *allineed) { t_net *net; t_list *c_list,*g_list,*job; - int count_j,count_c; + int count_j,count_c,min; t_job *j; t_client *c; unsigned char data; @@ -329,12 +343,39 @@ int distribute_jobs(t_event *event,void *allineed) { g_list=(t_list *)addr[2]; job=(t_list *)addr[3]; - count_j=list_count(job); - count_c=list_count(c_list); + list_reset(job); + list_reset(c_list); + + count_j=0; + count_c=0; + + if((c_list->current==NULL)||(job->current==NULL)) return 2; + + j=(t_job *)job->current->data; + c=(t_client *)c_list->current->data; + if(j->status==IN_QUEUE) count_j++; + if(c->status==IDLE) count_c++; + + while(list_next(job)!=L_NO_NEXT_ELEMENT) { + j=(t_job *)job->current->data; + if(j->status==IN_QUEUE) count_j++; + } + while(list_next(c_list)!=L_NO_NEXT_ELEMENT) { + if(j->status==IN_QUEUE) count_j++; + if(c->status==IDLE) count_c++; + } + + min=(count_ccurrent->data; c=(t_client *)c_list->current->data; while(c->status!=IDLE) { @@ -368,8 +409,7 @@ int distribute_jobs(t_event *event,void *allineed) { j->size*sizeof(int)); } - --count_c; - --count_j; + --min; list_next(c_list); list_next(job); } @@ -410,7 +450,14 @@ void destroy_it(int signum) { printf("connection to client (ch %d) fucked up!\n",*gi); event_math(gnet->connection[*gi].fd,gevent,READ,REMOVE); network_close(gnet,*gi); - list_del_current(gc_list); + if(list_search_data(gc_list,gi,sizeof(int))==L_SUCCESS) { + list_del_current(gc_list); + printf("removed client from list\n"); + } + if(list_search_data(gg_list,gi,sizeof(int))==L_SUCCESS) { + list_del_current(gg_list); + printf("removed gui from list\n"); + } alert=1; alarm(0); @@ -436,6 +483,7 @@ int main(int argc,char **argv) gnet=&net; gevent=&event; gc_list=&c_list; + gg_list=&g_list; /* tzzz ... */ allyouneed=(void *)addr;