Commit 0eb599a2 authored by Niels Möller's avatar Niels Möller
Browse files

* src/write_buffer.c (write_buffer_pre_write): Use string_queue.

(do_write): Likewise.

Rev: src/write_buffer.c:1.21
Rev: src/write_buffer.h:1.19
parent 4dc21724
......@@ -31,28 +31,16 @@
#include <assert.h>
#include <string.h>
/* Prototype */
static void do_free_buffer(struct lsh_queue *q);
#define GABA_DEFINE
#include "write_buffer.h.x"
#undef GABA_DEFINE
static void do_free_buffer(struct lsh_queue *q)
{
FOR_QUEUE(q, struct buffer_node *, n)
{
lsh_string_free(n->packet);
lsh_space_free(n);
}
}
static void
do_write(struct abstract_write *w,
struct lsh_string *packet)
{
CAST(write_buffer, closure, w);
struct buffer_node *new;
debug("write_buffer: do_write length = %i\n",
packet->length);
......@@ -70,10 +58,8 @@ do_write(struct abstract_write *w,
}
/* Enqueue packet */
NEW_SPACE(new);
new->packet = packet;
lsh_queue_add_tail(&closure->q, &new->header);
string_queue_add_tail(&closure->q, packet);
#if 0
if (closure->try_write)
......@@ -146,15 +132,10 @@ int write_buffer_pre_write(struct write_buffer *buffer)
else
{
/* Dequeue a packet, if possible */
if (!lsh_queue_is_empty(&buffer->q))
{
struct buffer_node *n =
(struct buffer_node *) lsh_queue_remove_head(&buffer->q);
buffer->partial = n->packet;
if (!string_queue_is_empty(&buffer->q))
{
buffer->partial = string_queue_remove_head(&buffer->q);
buffer->pos = 0;
lsh_space_free(n);
}
else
break;
......@@ -198,7 +179,7 @@ struct write_buffer *write_buffer_alloc(UINT32 size)
res->try_write = try;
#endif
lsh_queue_init(&res->q);
string_queue_init(&res->q);
res->pos = 0;
res->partial = NULL;
......
......@@ -44,14 +44,6 @@
#define FLOW_CONTROL_REPORT(o, written) ((o)->report((o), written))
/* For the packet queue */
/* NOTE: No object header */
struct buffer_node
{
struct lsh_queue_node header;
struct lsh_string *packet;
};
/* GABA:
(class
(name write_buffer)
......@@ -72,8 +64,7 @@ struct buffer_node
;; (try_write . int)
(q indirect-special "struct lsh_queue"
#f do_free_buffer)
(q struct string_queue)
(pos . UINT32) ; Partial packet
(partial string)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment