[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pecl-cvs
Subject:    [PECL-CVS] =?utf-8?q?svn:_/pecl/amqp/trunk/_amqp=5Fchannel.c_amqp=5Fexchange.c_amqp=5Fqueue.c_php=5F
From:       Pieter_de_Zwart <pdezwart () php ! net>
Date:       2011-10-26 18:51:24
Message-ID: svn-pdezwart-1319655084-318444-1124855258 () svn ! php ! net
[Download RAW message or body]

pdezwart                                 Wed, 26 Oct 2011 18:51:24 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=318444

Log:
* Throwing appropriate exceptions when things break
* Fixing test

Changed paths:
    U   pecl/amqp/trunk/amqp_channel.c
    U   pecl/amqp/trunk/amqp_exchange.c
    U   pecl/amqp/trunk/amqp_queue.c
    U   pecl/amqp/trunk/php_amqp.h
    U   pecl/amqp/trunk/tests/amqpqueue_consume_basic.phpt


["svn-diffs-318444.txt" (text/x-diff)]

Modified: pecl/amqp/trunk/amqp_channel.c
===================================================================
--- pecl/amqp/trunk/amqp_channel.c	2011-10-26 17:32:39 UTC (rev 318443)
+++ pecl/amqp/trunk/amqp_channel.c	2011-10-26 18:51:24 UTC (rev 318444)
@@ -104,7 +104,7 @@

 	/* Pull out and verify the connection */
 	connection = AMQP_GET_CONNECTION(channel);
-	AMQP_VERIFY_CONNECTION(connection, amqp_channel_exception_class_entry, "Could not \
create channel."); +	AMQP_VERIFY_CONNECTION(connection, "Could not create channel.");

 	/* Figure out what the next available channel is on this connection */
 	channel->channel_id = get_next_available_channel(connection, channel);
@@ -189,7 +189,7 @@
 	channel->prefetch_size = 0;

 	connection = AMQP_GET_CONNECTION(channel);
-	AMQP_VERIFY_CONNECTION(connection, amqp_channel_exception_class_entry, "Could not \
set prefetch count."); +	AMQP_VERIFY_CONNECTION(connection, "Could not set prefetch \
count.");

 	/* If we are already connected, set the new prefetch count */
 	if (channel->is_connected) {
@@ -229,7 +229,7 @@
 	channel->prefetch_size = prefetch_size;

 	connection = AMQP_GET_CONNECTION(channel);
-	AMQP_VERIFY_CONNECTION(connection, amqp_channel_exception_class_entry, "Could not \
set prefetch size."); +	AMQP_VERIFY_CONNECTION(connection, "Could not set prefetch \
size.");

 	/* If we are already connected, set the new prefetch count */
 	if (channel->is_connected) {
@@ -270,7 +270,7 @@
 	channel->prefetch_count = prefetch_count;

 	connection = AMQP_GET_CONNECTION(channel);
-	AMQP_VERIFY_CONNECTION(connection, amqp_channel_exception_class_entry, "Could not \
set qos parameters."); +	AMQP_VERIFY_CONNECTION(connection, "Could not set qos \
parameters.");

 	/* If we are already connected, set the new prefetch count */
 	if (channel->is_connected) {
@@ -305,7 +305,7 @@
 	channel = (amqp_channel_object *)zend_object_store_get_object(id TSRMLS_CC);

 	connection = AMQP_GET_CONNECTION(channel);
-	AMQP_VERIFY_CONNECTION(connection, amqp_channel_exception_class_entry, "Could not \
start the transaction."); +	AMQP_VERIFY_CONNECTION(connection, "Could not start the \
transaction.");

 	amqp_tx_select_t s;
 	amqp_method_number_t select_ok = AMQP_TX_SELECT_OK_METHOD;
@@ -350,7 +350,7 @@
 	channel = (amqp_channel_object *)zend_object_store_get_object(id TSRMLS_CC);

 	connection = AMQP_GET_CONNECTION(channel);
-	AMQP_VERIFY_CONNECTION(connection, amqp_channel_exception_class_entry, "Could not \
start the transaction."); +	AMQP_VERIFY_CONNECTION(connection, "Could not start the \
transaction.");

 	amqp_tx_commit_t s;
 	amqp_method_number_t commit_ok = AMQP_TX_COMMIT_OK_METHOD;
@@ -394,7 +394,7 @@
 	channel = (amqp_channel_object *)zend_object_store_get_object(id TSRMLS_CC);

 	connection = AMQP_GET_CONNECTION(channel);
-	AMQP_VERIFY_CONNECTION(connection, amqp_channel_exception_class_entry, "Could not \
start the transaction."); +	AMQP_VERIFY_CONNECTION(connection, "Could not start the \
transaction.");

 	amqp_tx_rollback_t s;
 	amqp_method_number_t rollback_ok = AMQP_TX_ROLLBACK_OK_METHOD;

Modified: pecl/amqp/trunk/amqp_exchange.c
===================================================================
--- pecl/amqp/trunk/amqp_exchange.c	2011-10-26 17:32:39 UTC (rev 318443)
+++ pecl/amqp/trunk/amqp_exchange.c	2011-10-26 18:51:24 UTC (rev 318444)
@@ -106,7 +106,7 @@
 	/* Pull the channel out */
 	channel = AMQP_GET_CHANNEL(exchange);

-	AMQP_VERIFY_CHANNEL(channel, amqp_exchange_exception_class_entry, "Could not create \
exchange."); +	AMQP_VERIFY_CHANNEL(channel, "Could not create exchange.");

 	/* We have a valid connection: */
 	exchange->is_connected = '\1';
@@ -399,10 +399,10 @@
 	exchange = (amqp_exchange_object *)zend_object_store_get_object(id TSRMLS_CC);

 	channel = AMQP_GET_CHANNEL(exchange);
-	AMQP_VERIFY_CHANNEL(channel, amqp_exchange_exception_class_entry, "Could not \
declare exchange."); +	AMQP_VERIFY_CHANNEL(channel, "Could not declare exchange.");

 	connection = AMQP_GET_CONNECTION(channel);
-	AMQP_VERIFY_CONNECTION(connection, amqp_exchange_exception_class_entry, "Could not \
declare exchange."); +	AMQP_VERIFY_CONNECTION(connection, "Could not declare \
exchange.");

 	/* Check that the exchange has a name */
 	if (exchange->name_len < 1) {
@@ -485,10 +485,10 @@
 	}

 	channel = AMQP_GET_CHANNEL(exchange);
-	AMQP_VERIFY_CHANNEL(channel, amqp_exchange_exception_class_entry, "Could not \
declare exchange."); +	AMQP_VERIFY_CHANNEL(channel, "Could not declare exchange.");

 	connection = AMQP_GET_CONNECTION(channel);
-	AMQP_VERIFY_CONNECTION(connection, amqp_exchange_exception_class_entry, "Could not \
declare exchange."); +	AMQP_VERIFY_CONNECTION(connection, "Could not declare \
exchange.");

 	amqp_method_number_t method_ok = AMQP_EXCHANGE_DELETE_OK_METHOD;
 	res = amqp_simple_rpc(
@@ -712,10 +712,10 @@
 	}

 	channel = AMQP_GET_CHANNEL(exchange);
-	AMQP_VERIFY_CHANNEL(channel, amqp_exchange_exception_class_entry, "Could not \
publish to exchange exchange."); +	AMQP_VERIFY_CHANNEL(channel, "Could not publish to \
exchange exchange.");

 	connection = AMQP_GET_CONNECTION(channel);
-	AMQP_VERIFY_CONNECTION(connection, amqp_exchange_exception_class_entry, "Could not \
publish to exchange exchange."); +	AMQP_VERIFY_CONNECTION(connection, "Could not \
publish to exchange exchange.");

 	/* Start ignoring SIGPIPE */
 	old_handler = signal(SIGPIPE, SIG_IGN);
@@ -778,10 +778,10 @@
 	exchange = (amqp_exchange_object *)zend_object_store_get_object(id TSRMLS_CC);

 	channel = AMQP_GET_CHANNEL(exchange);
-	AMQP_VERIFY_CHANNEL(channel, amqp_exchange_exception_class_entry, "Could not bind \
to exchange."); +	AMQP_VERIFY_CHANNEL(channel, "Could not bind to exchange.");

 	connection = AMQP_GET_CONNECTION(channel);
-	AMQP_VERIFY_CONNECTION(connection, amqp_exchange_exception_class_entry, "Could not \
bind to exchanges."); +	AMQP_VERIFY_CONNECTION(connection, "Could not bind to \
exchanges.");

 	amqp_queue_bind_t s;
 	s.ticket				= 0;

Modified: pecl/amqp/trunk/amqp_queue.c
===================================================================
--- pecl/amqp/trunk/amqp_queue.c	2011-10-26 17:32:39 UTC (rev 318443)
+++ pecl/amqp/trunk/amqp_queue.c	2011-10-26 18:51:24 UTC (rev 318444)
@@ -114,7 +114,7 @@
 	channel = AMQP_GET_CHANNEL(queue);

 	/* Check that the given connection has a channel, before trying to pull the \
                connection off the stack */
-	AMQP_VERIFY_CHANNEL(channel, amqp_queue_exception_class_entry, "Could not construct \
queue."); +	AMQP_VERIFY_CHANNEL(channel, "Could not construct queue.");

 	/* We have a valid connection: */
 	queue->is_connected = '\1';
@@ -373,10 +373,10 @@
 	}

 	channel = AMQP_GET_CHANNEL(queue);
-	AMQP_VERIFY_CHANNEL(channel, amqp_queue_exception_class_entry, "Could not declare \
queue."); +	AMQP_VERIFY_CHANNEL(channel, "Could not declare queue.");

 	connection = AMQP_GET_CONNECTION(channel);
-	AMQP_VERIFY_CONNECTION(connection, amqp_queue_exception_class_entry, "Could not \
declare queue."); +	AMQP_VERIFY_CONNECTION(connection, "Could not declare queue.");

 	amqp_table_t *arguments = convert_zval_to_arguments(queue->arguments);

@@ -439,10 +439,10 @@
 	}

 	channel = AMQP_GET_CHANNEL(queue);
-	AMQP_VERIFY_CHANNEL(channel, amqp_queue_exception_class_entry, "Could not bind \
queue."); +	AMQP_VERIFY_CHANNEL(channel, "Could not bind queue.");

 	connection = AMQP_GET_CONNECTION(channel);
-	AMQP_VERIFY_CONNECTION(connection, amqp_queue_exception_class_entry, "Could not \
bind queue."); +	AMQP_VERIFY_CONNECTION(connection, "Could not bind queue.");

 	amqp_queue_bind_t s;
 	s.ticket 				= 0;
@@ -515,10 +515,10 @@
 	queue = (amqp_queue_object *)zend_object_store_get_object(id TSRMLS_CC);

 	channel = AMQP_GET_CHANNEL(queue);
-	AMQP_VERIFY_CHANNEL(channel, amqp_queue_exception_class_entry, "Could not get \
queue."); +	AMQP_VERIFY_CHANNEL(channel, "Could not get queue.");

 	connection = AMQP_GET_CONNECTION(channel);
-	AMQP_VERIFY_CONNECTION(connection, amqp_queue_exception_class_entry, "Could not get \
queue."); +	AMQP_VERIFY_CONNECTION(connection, "Could not get queue.");

 	amqp_table_t *arguments = convert_zval_to_arguments(queue->arguments);

@@ -815,10 +815,10 @@
 	}

 	channel = AMQP_GET_CHANNEL(queue);
-	AMQP_VERIFY_CHANNEL(channel, amqp_queue_exception_class_entry, "Could not get from \
queue."); +	AMQP_VERIFY_CHANNEL(channel, "Could not get from queue.");

 	connection = AMQP_GET_CONNECTION(channel);
-	AMQP_VERIFY_CONNECTION(connection, amqp_queue_exception_class_entry, "Could not get \
from queue."); +	AMQP_VERIFY_CONNECTION(connection, "Could not get from queue.");

 	/* Set the QOS for this channel to match the max_messages */
 	amqp_basic_qos(
@@ -1194,10 +1194,10 @@
 	}

 	channel = AMQP_GET_CHANNEL(queue);
-	AMQP_VERIFY_CHANNEL(channel, amqp_queue_exception_class_entry, "Could not ack \
message."); +	AMQP_VERIFY_CHANNEL(channel, "Could not ack message.");

 	connection = AMQP_GET_CONNECTION(channel);
-	AMQP_VERIFY_CONNECTION(connection, amqp_queue_exception_class_entry, "Could not ack \
message."); +	AMQP_VERIFY_CONNECTION(connection, "Could not ack message.");

 	s.delivery_tag = deliveryTag;
 	s.multiple = (AMQP_MULTIPLE & flags) ? 1 : 0;
@@ -1249,10 +1249,10 @@
 	}

 	channel = AMQP_GET_CHANNEL(queue);
-	AMQP_VERIFY_CHANNEL(channel, amqp_queue_exception_class_entry, "Could not ack \
message."); +	AMQP_VERIFY_CHANNEL(channel, "Could not ack message.");

 	connection = AMQP_GET_CONNECTION(channel);
-	AMQP_VERIFY_CONNECTION(connection, amqp_queue_exception_class_entry, "Could not ack \
message."); +	AMQP_VERIFY_CONNECTION(connection, "Could not ack message.");

 	s.delivery_tag = deliveryTag;
 	s.multiple = (AMQP_MULTIPLE & flags) ? 1 : 0;
@@ -1303,10 +1303,10 @@
 	}

 	channel = AMQP_GET_CHANNEL(queue);
-	AMQP_VERIFY_CHANNEL(channel, amqp_queue_exception_class_entry, "Could not purge \
queue."); +	AMQP_VERIFY_CHANNEL(channel, "Could not purge queue.");

 	connection = AMQP_GET_CONNECTION(channel);
-	AMQP_VERIFY_CONNECTION(connection, amqp_queue_exception_class_entry, "Could not \
purge queue."); +	AMQP_VERIFY_CONNECTION(connection, "Could not purge queue.");

 	s.ticket		= 0;
 	s.queue.len		= queue->name_len;
@@ -1366,10 +1366,10 @@
 	}

 	channel = AMQP_GET_CHANNEL(queue);
-	AMQP_VERIFY_CHANNEL(channel, amqp_queue_exception_class_entry, "Could not cancel \
queue."); +	AMQP_VERIFY_CHANNEL(channel, "Could not cancel queue.");

 	connection = AMQP_GET_CONNECTION(channel);
-	AMQP_VERIFY_CONNECTION(connection, amqp_queue_exception_class_entry, "Could not \
cancel queue."); +	AMQP_VERIFY_CONNECTION(connection, "Could not cancel queue.");

 	if (consumer_tag_len) {
 		s.consumer_tag.len = consumer_tag_len;
@@ -1436,10 +1436,10 @@
 	}

 	channel = AMQP_GET_CHANNEL(queue);
-	AMQP_VERIFY_CHANNEL(channel, amqp_queue_exception_class_entry, "Could not unbind \
queue."); +	AMQP_VERIFY_CHANNEL(channel, "Could not unbind queue.");

 	connection = AMQP_GET_CONNECTION(channel);
-	AMQP_VERIFY_CONNECTION(connection, amqp_queue_exception_class_entry, "Could not \
unbind queue."); +	AMQP_VERIFY_CONNECTION(connection, "Could not unbind queue.");

 	amqp_queue_unbind_t s;
 	s.ticket				= 0;
@@ -1504,10 +1504,10 @@
 	}

 	channel = AMQP_GET_CHANNEL(queue);
-	AMQP_VERIFY_CHANNEL(channel, amqp_queue_exception_class_entry, "Could not delete \
queue."); +	AMQP_VERIFY_CHANNEL(channel, "Could not delete queue.");

 	connection = AMQP_GET_CONNECTION(channel);
-	AMQP_VERIFY_CONNECTION(connection, amqp_queue_exception_class_entry, "Could not \
delete queue."); +	AMQP_VERIFY_CONNECTION(connection, "Could not delete queue.");

 	s.queue.len		= queue->name_len;
 	s.queue.bytes	= queue->name;

Modified: pecl/amqp/trunk/php_amqp.h
===================================================================
--- pecl/amqp/trunk/php_amqp.h	2011-10-26 17:32:39 UTC (rev 318443)
+++ pecl/amqp/trunk/php_amqp.h	2011-10-26 18:51:24 UTC (rev 318444)
@@ -207,19 +207,19 @@
 #define AMQP_GET_CONNECTION(object) \
  	(amqp_connection_object *) zend_object_store_get_object((object)->connection \
TSRMLS_CC); \

-#define AMQP_VERIFY_CHANNEL(channel, exception, error) \
+#define AMQP_VERIFY_CHANNEL(channel, error) \
 	if ((channel)->is_connected != '\1') { \
 		char verify_channel_tmp[255]; \
 		snprintf(verify_channel_tmp, 255, "%s. No channel available.", error); \
-		zend_throw_exception((exception), verify_channel_tmp, 0 TSRMLS_CC); \
+		zend_throw_exception(amqp_channel_exception_class_entry, verify_channel_tmp, 0 \
TSRMLS_CC); \  return; \
 	} \

-#define AMQP_VERIFY_CONNECTION(connection, exception, error) \
+#define AMQP_VERIFY_CONNECTION(connection, error) \
 	if ((connection)->is_connected != '\1') { \
 		char verify_connection_tmp[255]; \
 		snprintf(verify_connection_tmp, 255, "%s. No conection available.", error); \
-		zend_throw_exception((exception), verify_connection_tmp, 0 TSRMLS_CC); \
+		zend_throw_exception(amqp_connection_exception_class_entry, verify_connection_tmp, \
0 TSRMLS_CC); \  return; \
 	} \


Modified: pecl/amqp/trunk/tests/amqpqueue_consume_basic.phpt
===================================================================
--- pecl/amqp/trunk/tests/amqpqueue_consume_basic.phpt	2011-10-26 17:32:39 UTC (rev \
                318443)
+++ pecl/amqp/trunk/tests/amqpqueue_consume_basic.phpt	2011-10-26 18:51:24 UTC (rev \
318444) @@ -36,7 +36,6 @@
 }

 $ex->delete();
-$q->delete();
 ?>
 --EXPECT--
 message



-- 
PECL CVS Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic