stream: Allocate enough for tls upgrade
parent
b5f37d0227
commit
ade1046391
|
@ -23,6 +23,8 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#define STREAM_ALLOC_SIZE 4096
|
||||||
|
|
||||||
enum stream_state {
|
enum stream_state {
|
||||||
STREAM_STATE_NORMAL = 0,
|
STREAM_STATE_NORMAL = 0,
|
||||||
STREAM_STATE_CLOSED,
|
STREAM_STATE_CLOSED,
|
||||||
|
@ -68,8 +70,6 @@ struct stream_impl {
|
||||||
void (*exec_and_send)(struct stream*, stream_exec_fn, void* userdata);
|
void (*exec_and_send)(struct stream*, stream_exec_fn, void* userdata);
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Move some of these struct members into their respective implementation
|
|
||||||
// classes.
|
|
||||||
struct stream {
|
struct stream {
|
||||||
struct stream_impl *impl;
|
struct stream_impl *impl;
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,9 @@ struct stream_gnutls {
|
||||||
gnutls_session_t session;
|
gnutls_session_t session;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static_assert(sizeof(struct stream_gnutls) <= STREAM_ALLOC_SIZE,
|
||||||
|
"struct stream_gnutls has grown too large, increase STREAM_ALLOC_SIZE");
|
||||||
|
|
||||||
static int stream__try_tls_accept(struct stream* self);
|
static int stream__try_tls_accept(struct stream* self);
|
||||||
|
|
||||||
static int stream_gnutls_close(struct stream* base)
|
static int stream_gnutls_close(struct stream* base)
|
||||||
|
|
|
@ -32,6 +32,9 @@
|
||||||
#include "stream-common.h"
|
#include "stream-common.h"
|
||||||
#include "sys/queue.h"
|
#include "sys/queue.h"
|
||||||
|
|
||||||
|
static_assert(sizeof(struct stream) <= STREAM_ALLOC_SIZE,
|
||||||
|
"struct stream has grown too large, increase STREAM_ALLOC_SIZE");
|
||||||
|
|
||||||
static int stream_tcp_close(struct stream* self)
|
static int stream_tcp_close(struct stream* self)
|
||||||
{
|
{
|
||||||
if (self->state == STREAM_STATE_CLOSED)
|
if (self->state == STREAM_STATE_CLOSED)
|
||||||
|
@ -255,7 +258,7 @@ static struct stream_impl impl = {
|
||||||
|
|
||||||
struct stream* stream_new(int fd, stream_event_fn on_event, void* userdata)
|
struct stream* stream_new(int fd, stream_event_fn on_event, void* userdata)
|
||||||
{
|
{
|
||||||
struct stream* self = calloc(1, sizeof(*self));
|
struct stream* self = calloc(1, STREAM_ALLOC_SIZE);
|
||||||
if (!self)
|
if (!self)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue