svn: /pecl/amqp/trunk/ amqp_connection.c amqp_queue.c
| From: | Pieter de Zwart | Date: | Fri, 16 Dec 2011 20:40:55 +0000 |
| Subject: | svn: /pecl/amqp/trunk/ amqp_connection.c amqp_queue.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-17398@lists.php.net to get a copy of this message | ||
pdezwart Fri, 16 Dec 2011 20:40:55 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=321077
Log:
* Fixing delivery mode support
* Fixing persistent connections
* Fixing segfault on certain read errors
Changed paths:
U pecl/amqp/trunk/amqp_connection.c
U pecl/amqp/trunk/amqp_queue.c
Modified: pecl/amqp/trunk/amqp_connection.c
===================================================================
--- pecl/amqp/trunk/amqp_connection.c 2011-12-16 19:47:34 UTC (rev 321076)
+++ pecl/amqp/trunk/amqp_connection.c 2011-12-16 20:40:55 UTC (rev 321077)
@@ -182,6 +182,11 @@
/* Pull the connection resource out for easy access */
amqp_connection_resource *resource = connection->connection_resource;
+ /* If it's persistent connection do not close this socket connection */
+ if (connection->is_connected == '\1' &&
connection->connection_resource->is_persistent) {
+ return;
+ }
+
/*
If we are trying to close the connection and the connection already closed, it will throw
SIGPIPE, which is fine, so ignore all SIGPIPES
@@ -529,8 +534,11 @@
/* Stash the connection resource in the connection */
connection->connection_resource = le->ptr;
+ /* Set connection status to connected */
+ connection->is_connected = '\1';
+
efree(key);
- return;
+ RETURN_TRUE;
}
/* No resource found: Instantiate the underlying connection */
@@ -586,7 +594,7 @@
/* Get the connection object out of the store */
connection = (amqp_connection_object *)zend_object_store_get_object(id TSRMLS_CC);
- if (connection->is_connected) {
+ if (connection->is_connected == '\1') {
php_amqp_disconnect(connection);
}
Modified: pecl/amqp/trunk/amqp_queue.c
===================================================================
--- pecl/amqp/trunk/amqp_queue.c 2011-12-16 19:47:34 UTC (rev 321076)
+++ pecl/amqp/trunk/amqp_queue.c 2011-12-16 20:40:55 UTC (rev 321077)
@@ -178,7 +178,12 @@
amqp_channel_close_t *err = (amqp_channel_close_t *)frame.payload.method.decoded;
char str[256];
char **pstr = (char **)&str;
- spprintf(pstr, 0, "Server error: %d", (int)err->reply_code);
+ if (err) {
+ spprintf(pstr, 0, "Server error: %d", (int)err->reply_code);
+ } else {
+ spprintf(pstr, 0, "Unknown server error occurred.");
+ }
+
zend_throw_exception(amqp_queue_exception_class_entry, *pstr, 0 TSRMLS_CC);
return AMQP_READ_ERROR;
}
@@ -247,6 +252,10 @@
AMQP_SET_LONG_PROPERTY(envelope->timestamp, p->timestamp);
}
+ if (p->_flags & AMQP_BASIC_DELIVERY_MODE_FLAG) {
+ AMQP_SET_LONG_PROPERTY(envelope->delivery_mode, p->delivery_mode);
+ }
+
if (p->_flags & AMQP_BASIC_PRIORITY_FLAG) {
AMQP_SET_LONG_PROPERTY(envelope->priority, p->priority);
}