SVN Account for Maintaining AMQP PECL extension (SVN Form Completed)

From: Date: Tue, 24 May 2011 20:12:13 +0000
Subject: SVN Account for Maintaining AMQP PECL extension (SVN Form Completed)
Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-8298@lists.php.net to get a copy of this message
Hello, This is a second request for an SVN account to help maintain AMQP. I went ahead and submitted the form for an SVN account. If I could get this approved that would be great, I am trying to submit a bug fix. I am working with Pieter De Zwart who is the maintainer for the extension. I have attached the bug fix to this email. Thanks, Jonathan Tansavatdi

Index: tests/amqpqueue_consume_basic.phpt =================================================================== --- tests/amqpqueue_consume_basic.phpt (revision 311202) +++ tests/amqpqueue_consume_basic.phpt (working copy) @@ -4,5 +4,87 @@ <?php if (!extension_loaded("amqp")) print "skip"; ?> --FILE-- <?php +$cnn = new AMQPConnection(); +$cnn->connect(); + +// Declare a new exchange +$ex = new AMQPExchange($cnn); +$ex->declare('exchange1', AMQP_EX_TYPE_FANOUT); + +// Create a new queue +$q = new AMQPQueue($cnn); +$queueName = 'queue1' . time(); +$q->declare($queueName); + +// Bind it on the exchange to routing.key +$ex->bind($queueName, 'routing.*'); + +// Publish a message to the exchange with a routing key +$ex->publish('message', 'routing.1'); +$ex->publish('message2', 'routing.2'); +$ex->publish('message3', 'routing.3'); + +// Read from the queue +$options = array( + 'min' => 1, + 'max' => 10, + 'ack' => false +); +$msg = $q->consume($options); +var_dump($msg); ?> --EXPECT-- +array(3) { + [0]=> + array(7) { + ["consumer_tag"]=> + string(33) "amq.ctag-B7pSjCczI4Q3aJMmYSz03Q==" + ["delivery_tag"]=> + int(1) + ["redelivered"]=> + bool(false) + ["routing_key"]=> + string(9) "routing.1" + ["exchange"]=> + string(9) "exchange1" + ["Content-type"]=> + string(10) "text/plain" + ["message_body"]=> + string(7) "message" + } + [1]=> + array(7) { + ["consumer_tag"]=> + string(33) "amq.ctag-B7pSjCczI4Q3aJMmYSz03Q==" + ["delivery_tag"]=> + int(2) + ["redelivered"]=> + bool(false) + ["routing_key"]=> + string(9) "routing.2" + ["exchange"]=> + string(9) "exchange1" + ["Content-type"]=> + string(10) "text/plain" + ["message_body"]=> + string(8) "message2" + } + [2]=> + array(7) { + ["consumer_tag"]=> + string(33) "amq.ctag-B7pSjCczI4Q3aJMmYSz03Q==" + ["delivery_tag"]=> + int(3) + ["redelivered"]=> + bool(false) + ["routing_key"]=> + string(9) "routing.3" + ["exchange"]=> + string(9) "exchange1" + ["Content-type"]=> + string(10) "text/plain" + ["message_body"]=> + string(8) "message3" + } +} + Index: amqp_queue.c =================================================================== --- amqp_queue.c (revision 311202) +++ amqp_queue.c (working copy) @@ -1,25 +1,25 @@ /* +---------------------------------------------------------------------+ - | PHP Version 5 | + | PHP Version 5 | +---------------------------------------------------------------------+ - | Copyright (c) 1997-2007 The PHP Group | + | Copyright (c) 1997-2007 The PHP Group | +---------------------------------------------------------------------+ - | This source file is subject to version 3.01 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - | | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + | | | This source uses the librabbitmq under the MPL. For the MPL, please | - | see LICENSE-MPL-RabbitMQ | + | see LICENSE-MPL-RabbitMQ | +---------------------------------------------------------------------+ | Author: Alexandre Kalendarev akalend@mail.ru Copyright (c) 2009-2010| - | Maintainer: Pieter de Zwart pdezwart@php.net | - | Contributers: | - | - Andrey Hristov | - | - Brad Rodriguez brodriguez@php.net | + | Maintainer: Pieter de Zwart pdezwart@php.net | + | Contributers: | + | - Andrey Hristov | + | - Brad Rodriguez brodriguez@php.net | +---------------------------------------------------------------------+ */ @@ -497,8 +497,6 @@ { zval *id; amqp_queue_object *ctx; - char *name; - int name_len; int queue_len; amqp_rpc_reply_t res; @@ -585,14 +583,7 @@ int i; array_init(return_value); char *buf = NULL; - - buf = (char*) emalloc(FRAME_MAX); - if (!buf) { - zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Out of memory (malloc)" ,0 TSRMLS_CC); - } - - zval *message; - MAKE_STD_ZVAL(message); + amqp_boolean_t messages_left; for (i = 0; i < max_consume; i++) { @@ -634,6 +625,8 @@ } /* initialize message array */ + zval *message; + MAKE_STD_ZVAL(message); array_init(message); /* get message metadata */ @@ -729,6 +722,11 @@ body_target = frame.payload.properties.body_size; body_received = 0; + buf = (char*) emalloc(FRAME_MAX); + if (!buf) { + zend_throw_exception(zend_exception_get_default(TSRMLS_C), "Out of memory (malloc)" ,0 TSRMLS_CC); + } + /* resize buffer if necessary */ if (body_target > buf_max) { int count_buf = body_target / FRAME_MAX +1;
« previous php.pecl.dev (#8298) next »