Making the option -N work fine; jobs get into running if there are free slots.
--- a/jobs.c Wed May 23 19:38:12 2012 +0200
+++ b/jobs.c Sat May 26 16:03:35 2012 +0200
@@ -502,10 +502,12 @@
{
struct Job *p;
+ const int free_slots = max_slots - busy_slots;
+
/* busy_slots may be bigger than the maximum slots,
* if the user was running many jobs, and suddenly
* trimmed the maximum slots down. */
- if (busy_slots >= max_slots)
+ if (free_slots <= 0)
return -1;
/* If there are no jobs to run... */
@@ -532,8 +534,11 @@
}
}
- ++busy_slots;
- return p->jobid;
+ if (free_slots >= p->num_slots)
+ {
+ busy_slots = busy_slots + p->num_slots;
+ return p->jobid;
+ }
}
p = p->next;
}
@@ -632,7 +637,7 @@
* we call this to clean up the jobs list in case of the client closing the
* connection. */
if (p->state == RUNNING)
- --busy_slots;
+ busy_slots = busy_slots - p->num_slots;
/* Mark state */
if (result->skipped)
--- a/main.c Wed May 23 19:38:12 2012 +0200
+++ b/main.c Sat May 26 16:03:35 2012 +0200
@@ -84,7 +84,7 @@
/* Parse options */
while(1) {
- c = getopt(argc, argv, ":VhKgClnfmBEr:t:c:o:p:w:u:s:U:i:L:dS:D:");
+ c = getopt(argc, argv, ":VhKgClnfmBEr:t:c:o:p:w:u:s:U:i:N:L:dS:D:");
if (c == -1)
break;