ext/mosquitto/client.h in mosquitto-0.2 vs ext/mosquitto/client.h in mosquitto-0.3
- old
+ new
@@ -1,9 +1,10 @@
#ifndef MOSQUITTO_CLIENT_H
#define MOSQUITTO_CLIENT_H
typedef struct mosquitto_callback_t mosquitto_callback_t;
+typedef struct mosquitto_callback_waiting_t mosquitto_callback_waiting_t;
typedef struct {
struct mosquitto *mosq;
VALUE connect_cb;
VALUE disconnect_cb;
@@ -13,18 +14,29 @@
VALUE unsubscribe_cb;
VALUE log_cb;
VALUE callback_thread;
pthread_mutex_t callback_mutex;
pthread_cond_t callback_cond;
+ mosquitto_callback_waiting_t *waiter;
mosquitto_callback_t *callback_queue;
} mosquitto_client_wrapper;
#define MosquittoGetClient(obj) \
mosquitto_client_wrapper *client = NULL; \
Data_Get_Struct(obj, mosquitto_client_wrapper, client); \
if (!client) rb_raise(rb_eTypeError, "uninitialized Mosquitto client!");
+#define RetryNotConnectedOnce() \
+ if (retried == false) { \
+ mosquitto_reconnect(client->mosq); \
+ time.tv_sec = 0; \
+ time.tv_usec = 300 * 1000; \
+ rb_thread_wait_for(time); \
+ retried = true; \
+ goto retry_once; \
+ }
+
#define MosquittoAssertCallback(cb, arity) \
if (NIL_P(cb)){ \
cb = proc; \
} else { \
if (rb_class_of(cb) != rb_cProc) \
@@ -88,13 +100,11 @@
mosquitto_client_wrapper *client;
void *data;
mosquitto_callback_t *next;
};
-typedef struct mosquitto_callback_waiting_t mosquitto_callback_waiting_t;
struct mosquitto_callback_waiting_t {
mosquitto_callback_t *callback;
- mosquitto_client_wrapper *client;
bool abort;
};
struct nogvl_connect_args {
struct mosquitto *mosq;