Incorrectly reading payload
Status: Beta
Brought to you by:
icyliquid
By definition the reserve command should read data for a length of <bytes> as returned by the command. However due to a bug if the <data> portion of the result contains one or more \r\n's the resulting payload is incorrect and the buffer is never fully read. The put() function however handles this correctly.
A very lazy temporary bug fix would be the following:
public function reserve_with_timeout($in_timeout=0)
{
if (BeanStalk::DEBUG) echo __METHOD__."\n";
$this->safe_send_message("reserve-with-timeout {$in_timeout}");
$real = $this->safe_read_message();
$res = $this->check_reply($real, array(
'/RESERVED (\d+) (\d+)/' => self::OPERATION_OK,
'/DEADLINE_SOON/' => self::ERROR_DEADLINE_SOON,
'/TIMED_OUT/' => self::ERROR_TIMED_OUT
), $data);
if ($res == self::OPERATION_OK)
{
$jid = $data[0];
$bytes = $data[1];
$job = $this->safe_read_message($bytes,0);
if (strlen($job) < $bytes)
{
$job .= BeanQueue::MSG_DELIM.substr($this->rbuf, 0, strlen($this->rbuf) - 2);
$this->rbuf = '';
$this->rbuflen = 0;
}
return BeanQueueJob::open($this, $jid, $job);
}
return $res;
}