Cleanup the io queue interface by hiding the internal structures of the
send queue, and read queue.
This commit is contained in:
parent
71cdf158e4
commit
be098144db
@ -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)
|
||||
{
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user