Skip to content

Commit

Permalink
Attempt to disconnect cleanly
Browse files Browse the repository at this point in the history
  • Loading branch information
mgdm committed Oct 4, 2013
1 parent 6ea5910 commit e32a65e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mosquitto.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ PHP_MOSQUITTO_API char *php_mosquitto_strerror_wrapper(int err)
static void mosquitto_client_object_destroy(void *object TSRMLS_DC)
{
mosquitto_client_object *client = (mosquitto_client_object *) object;

/* Disconnect cleanly, but disregard an error if it wasn't connected */
mosquitto_disconnect(client->client);
zend_hash_destroy(client->std.properties);
FREE_HASHTABLE(client->std.properties);
mosquitto_destroy(client->client);
Expand Down Expand Up @@ -566,12 +569,13 @@ PHP_MOSQUITTO_API void php_mosquitto_subscribe_callback(struct mosquitto *mosq,
/* {{{ mosquitto_client_methods */
const zend_function_entry mosquitto_client_methods[] = {
PHP_ME(Mosquitto_Client, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
PHP_ME(Mosquitto_Client, setCredentials, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Mosquitto_Client, connect, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Mosquitto_Client, onConnect, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Mosquitto_Client, onDisconnect, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Mosquitto_Client, onSubscribe, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Mosquitto_Client, onMessage, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Mosquitto_Client, setCredentials, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Mosquitto_Client, connect, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Mosquitto_Client, disconnect, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Mosquitto_Client, publish, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Mosquitto_Client, subscribe, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Mosquitto_Client, loop, NULL, ZEND_ACC_PUBLIC)
Expand Down

0 comments on commit e32a65e

Please sign in to comment.