Skip to content

Commit

Permalink
Fix ADDJOB MAXLEN off-by-one error
Browse files Browse the repository at this point in the history
  • Loading branch information
felixbuenemann committed Aug 10, 2015
1 parent 6dbfa4c commit 4ef6b01
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/job.c
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ void addjobCommand(client *c) {

/* If maxlen was specified, check that the local queue len is
* within the requested limits. */
if (maxlen && queueNameLength(c->argv[1]) > (unsigned long) maxlen) {
if (maxlen && queueNameLength(c->argv[1]) >= (unsigned long) maxlen) {
addReplySds(c,
sdsnew("-MAXLEN Queue is already longer than "
"the specified MAXLEN count\r\n"));
Expand Down
7 changes: 7 additions & 0 deletions tests/cluster/tests/03-jobs-queueing.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,10 @@ test "Single node jobs are correctly ordered in a FIFO fashion" {
assert {$body == $j}
}
}

test "ADDJOB fails if queue length exceeds MAXLEN" {
set qname [randomQueue]
D 0 addjob $qname myjob 5000 maxlen 1
catch {D 0 addjob $qname myjob 5000 maxlen 1} job_id
assert_match {MAXLEN*} $job_id
}

0 comments on commit 4ef6b01

Please sign in to comment.