Skip to content
Browse files

wake up waiting clients when unpausing a tube

fixes #113
  • Loading branch information...
1 parent 92798cf commit 9020d9a4d4916658896512880b7ac7824305203a @kr committed
Showing with 36 additions and 0 deletions.
  1. +30 −0 integ-test.c
  2. +6 −0 prot.c
View
30 integ-test.c
@@ -641,6 +641,36 @@ cttestreservewithtimeout2conn()
void
+cttestunpausetube()
+{
+ int fd0, fd1;
+
+ port = SERVER();
+ fd0 = mustdiallocal(port);
+ fd1 = mustdiallocal(port);
+
+ mustsend(fd0, "put 0 0 0 0\r\n");
+ mustsend(fd0, "\r\n");
+ ckresp(fd0, "INSERTED 1\r\n");
+
+ mustsend(fd0, "pause-tube default 86400\r\n");
+ ckresp(fd0, "PAUSED\r\n");
+
+ mustsend(fd1, "reserve\r\n");
+
+ mustsend(fd0, "pause-tube default 0\r\n");
+ ckresp(fd0, "PAUSED\r\n");
+
+ // ckresp will time out if this takes too long, so the
+ // test will not pass.
+ ckresp(fd1, "RESERVED 1 0\r\n");
+ ckresp(fd1, "\r\n");
+
+ killsrv();
+}
+
+
+void
cttestbinlogemptyexit()
{
mkdtemp(dir);
View
6 prot.c
@@ -1525,6 +1525,12 @@ dispatch_cmd(Conn *c)
t = tube_find(name);
if (!t) return reply_msg(c, MSG_NOTFOUND);
+ // Always pause for a positive amount of time, to make sure
+ // that waiting clients wake up when the deadline arrives.
+ if (delay == 0) {
+ delay = 1;
+ }
+
t->deadline_at = nanoseconds() + delay;
t->pause = delay;
t->stat.pause_ct++;

0 comments on commit 9020d9a

Please sign in to comment.
Something went wrong with that request. Please try again.