mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-10-18 01:54:08 +00:00
fixup! fixup! Lib: CBOR message streams and channels
This commit is contained in:
parent
50557d2b26
commit
65079628cf
@ -325,3 +325,12 @@ cbor_stream_attach(struct cbor_stream *stream, sock *sk)
|
||||
sk->data = stream;
|
||||
sk->rx_hook = cbor_stream_rx;
|
||||
}
|
||||
|
||||
void
|
||||
cbor_channel_done(struct cbor_channel *channel)
|
||||
{
|
||||
struct cbor_stream *stream = stream;
|
||||
HASH_REMOVE(stream->channels, CCH, channel);
|
||||
rp_free(channel->p);
|
||||
sl_free(channel);
|
||||
}
|
||||
|
19
lib/cbor.c
19
lib/cbor.c
@ -194,6 +194,25 @@ bool cbor_put_close(struct cbor_writer *w, u64 actual_size, bool strict)
|
||||
/* Tags: TODO! */
|
||||
|
||||
|
||||
/* Writer contexts */
|
||||
struct cbor_writer *
|
||||
cbor_reply_init(struct cbor_channel *cch)
|
||||
{
|
||||
struct cbor_writer *cw = &cch->writer;
|
||||
if (cch->stream->s->tbuf != cch->stream->s->tpos)
|
||||
bug("Not implemented reply to not-fully-flushed buffer");
|
||||
|
||||
cbor_writer_init(cw, cch->stream->writer_depth, cch->stream->s->tbuf, cch->stream->s->tbsize);
|
||||
return cw;
|
||||
}
|
||||
|
||||
void
|
||||
cbor_reply_send(struct cbor_channel *cch, struct cbor_writer *cw)
|
||||
{
|
||||
ASSERT_DIE(cw == &cch->writer);
|
||||
sk_send(cch->stream->s, cw->data.pos - cw->data.start);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
void cbor_epoch_time(struct cbor_writer *writer, int64_t time, int shift)
|
||||
|
@ -212,6 +212,7 @@ struct cbor_stream {
|
||||
CSTR_FINISH,
|
||||
CSTR_CLEANUP,
|
||||
} state;
|
||||
uint writer_depth;
|
||||
struct cbor_parser_context parser;
|
||||
};
|
||||
|
||||
@ -228,6 +229,7 @@ struct cbor_channel {
|
||||
pool *p;
|
||||
u64 id;
|
||||
u64 idhash;
|
||||
struct cbor_writer writer;
|
||||
};
|
||||
|
||||
extern struct cbor_channel cbor_channel_parse_error;
|
||||
@ -236,7 +238,7 @@ extern struct cbor_channel cbor_channel_parse_error;
|
||||
struct cbor_channel *cbor_channel_new(struct cbor_stream *);
|
||||
|
||||
/* Drop the channel */
|
||||
void cbor_done_channel(struct cbor_channel *);
|
||||
void cbor_channel_done(struct cbor_channel *);
|
||||
|
||||
struct cbor_writer *cbor_reply_init(struct cbor_channel *);
|
||||
void cbor_reply_send(struct cbor_channel *, struct cbor_writer *);
|
||||
|
Loading…
Reference in New Issue
Block a user