- list_reset(job);
- list_reset(c_list);
- while((count_c!=0)&&(count_j!=0)) {
- j=(t_job *)job->current->data;
- c=(t_client *)c_list->current->data;
+ while(list_next(&(priv.job))!=L_NO_NEXT_ELEMENT) {
+ j=(t_job *)priv.job.current->data;
+ if(j->status==IN_QUEUE) count_j++;
+ }
+ while(list_next(&(priv.client))!=L_NO_NEXT_ELEMENT) {
+ c=(t_client *)priv.client.current->data;
+ 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\n",count_j,count_c);
+ }
+
+ list_reset(&(priv.job));
+ list_reset(&(priv.client));
+
+ while(min) {
+ j=(t_job *)priv.job.current->data;
+ c=(t_client *)priv.client.current->data;