]> hackdaworld.org Git - physik/nlsop.git/commitdiff
fixes
authorhackbard <hackbard>
Mon, 8 Nov 2004 12:26:56 +0000 (12:26 +0000)
committerhackbard <hackbard>
Mon, 8 Nov 2004 12:26:56 +0000 (12:26 +0000)
nlsop_server.c

index ea4579164d0de297e6b3f790aca0746399fb819c..71eabf6520d07eeac6ca48d3301faf90339aa825 100644 (file)
@@ -221,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));
 
@@ -326,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;
@@ -340,14 +343,39 @@ int distribute_jobs(t_event *event,void *allineed) {
   g_list=(t_list *)addr[2];
   job=(t_list *)addr[3];
 
-  printf("d: distributing jobs ...\n");
+  list_reset(job);
+  list_reset(c_list);
 
-  count_j=list_count(job);
-  count_c=list_count(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_c<count_j)?count_c:count_j;
+
+  if(min!=0) {
+    printf("d: distributing jobs ...\n");
+    printf("%d queued jobs, %d idle clients\n",count_j,count_c);
+  }
 
   list_reset(job);
   list_reset(c_list);
-  while((count_c!=0)&&(count_j!=0)) {
+
+  while(min) {
     j=(t_job *)job->current->data;
     c=(t_client *)c_list->current->data;
     while(c->status!=IDLE) {
@@ -381,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);
   }