diff --git a/src/core/ioqueue.c b/src/core/ioqueue.c index 270dca5..9e2c69a 100644 --- a/src/core/ioqueue.c +++ b/src/core/ioqueue.c @@ -19,6 +19,23 @@ #include "uhub.h" +struct ioq_send +{ + size_t size; /** Size of send queue (in bytes, not messages) */ + size_t offset; /** Queue byte offset in the first message. Should be 0 unless a partial write. */ +#ifdef SSL_SUPPORT + size_t last_send; /** When using SSL, one have to send the exact same buffer and length if a write cannot complete. */ +#endif + struct linked_list* queue; /** List of queued messages (struct adc_message) */ +}; + +struct ioq_recv +{ + char* buf; + size_t size; +}; + + #ifdef DEBUG_SENDQ static void debug_msg(const char* prefix, struct adc_message* msg) { diff --git a/src/core/ioqueue.h b/src/core/ioqueue.h index 3dd9cb7..b1cbf38 100644 --- a/src/core/ioqueue.h +++ b/src/core/ioqueue.h @@ -21,25 +21,8 @@ #define HAVE_UHUB_IO_QUEUE_H struct adc_message; -struct linked_list; -typedef int (*ioq_write)(void* desc, const void* buf, size_t len); -typedef int (*ioq_read)(void* desc, void* buf, size_t len); - -struct ioq_send -{ - size_t size; /** Size of send queue (in bytes, not messages) */ - size_t offset; /** Queue byte offset in the first message. Should be 0 unless a partial write. */ -#ifdef SSL_SUPPORT - size_t last_send; /** When using SSL, one have to send the exact same buffer and length if a write cannot complete. */ -#endif - struct linked_list* queue; /** List of queued messages (struct adc_message) */ -}; - -struct ioq_recv -{ - char* buf; - size_t size; -}; +struct ioq_send; +struct ioq_recv; /** * Create a send queue diff --git a/src/core/route.c b/src/core/route.c index 6af5aa4..c872b3c 100644 --- a/src/core/route.c +++ b/src/core/route.c @@ -80,13 +80,13 @@ static int check_send_queue(struct hub_info* hub, struct hub_user* user, struct if (user_flag_get(user, flag_user_list)) return 1; - if ((user->send_queue->size + msg->length) > get_max_send_queue(hub)) + if ((ioq_send_get_bytes(user->send_queue) + msg->length) > get_max_send_queue(hub)) { LOG_WARN("send queue overflowed, message discarded."); return -1; } - if (user->send_queue->size > get_max_send_queue_soft(hub)) + if (ioq_send_get_bytes(user->send_queue) > get_max_send_queue_soft(hub)) { LOG_WARN("send queue soft overflowed."); return 0;