Skip to content

Commit

Permalink
Only process commands if there's data read.
Browse files Browse the repository at this point in the history
Don't use leftover command data. The cmd_read value is always correct, so check
that cmd_read is nonzero before using data in the cmd buf.
  • Loading branch information
Keith Rarick committed Sep 25, 2007
1 parent 6ea4e18 commit c7669c9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions beanstalkd.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ reset_conn(conn c)
c->state = STATE_WANTCOMMAND;
}

#define cmd_is_ready(c) ((c)->fd && ((c)->state == STATE_WANTCOMMAND))
#define cmd_ready(c) ((c)->fd && ((c)->state == STATE_WANTCOMMAND))

static void
h_conn(const int fd, const short which, conn c)
Expand Down Expand Up @@ -382,7 +382,7 @@ h_conn(const int fd, const short which, conn c)
/* If we got here, it means we still have an open connection and we're
* ready to run a command. So we should check if we already got more
* commands to process. */
while (cmd_is_ready(c) && (c->cmd_len = cmd_len(c))) do_cmd(c);
while (cmd_ready(c) && c->cmd_read && (c->cmd_len = cmd_len(c))) do_cmd(c);
}

static void
Expand Down

0 comments on commit c7669c9

Please sign in to comment.