mirror of https://git.kore.io/kore.git
More cleanup after introducing NOHTTP=1.
* The cli tools must know when building as KORE_NO_HTTP. * Reshuffle some structs around to avoid forward declarations. * Move wscbs under !KORE_NO_HTTP as its for websockets. * Remove unused members from struct connection. Applications that use the connect callbacks for new connections must now set the connection state themselves, see nohttp example.
This commit is contained in:
parent
4fd6d8a7a4
commit
428802afc8
|
@ -40,6 +40,9 @@ connection_setup(struct connection *c)
|
|||
* 128 bytes were read.
|
||||
*/
|
||||
net_recv_queue(c, 128, NETBUF_CALL_CB_ALWAYS, connection_recv_data);
|
||||
|
||||
/* We are responsible for setting the connection state. */
|
||||
c->state = CONN_STATE_ESTABLISHED;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -96,7 +96,6 @@ extern int daemon(int, int);
|
|||
#if !defined(KORE_NO_HTTP)
|
||||
struct http_request;
|
||||
#endif
|
||||
struct connection;
|
||||
|
||||
struct netbuf {
|
||||
u_int8_t *buf;
|
||||
|
@ -121,22 +120,6 @@ TAILQ_HEAD(netbuf_head, netbuf);
|
|||
#define KORE_TYPE_PGSQL_CONN 3
|
||||
#define KORE_TYPE_TASK 4
|
||||
|
||||
struct listener {
|
||||
u_int8_t type;
|
||||
u_int8_t addrtype;
|
||||
int fd;
|
||||
void (*connect)(struct connection *);
|
||||
|
||||
union {
|
||||
struct sockaddr_in ipv4;
|
||||
struct sockaddr_in6 ipv6;
|
||||
} addr;
|
||||
|
||||
LIST_ENTRY(listener) list;
|
||||
};
|
||||
|
||||
LIST_HEAD(listener_head, listener);
|
||||
|
||||
#define CONN_STATE_UNKNOWN 0
|
||||
#define CONN_STATE_SSL_SHAKE 1
|
||||
#define CONN_STATE_ESTABLISHED 2
|
||||
|
@ -181,7 +164,6 @@ struct connection {
|
|||
u_int8_t flags;
|
||||
void *hdlr_extra;
|
||||
X509 *cert;
|
||||
void *wscbs;
|
||||
int tls_reneg;
|
||||
|
||||
void (*disconnect)(struct connection *);
|
||||
|
@ -204,17 +186,33 @@ struct connection {
|
|||
struct netbuf *rnb;
|
||||
|
||||
#if !defined(KORE_NO_HTTP)
|
||||
void *wscbs;
|
||||
TAILQ_HEAD(, http_request) http_requests;
|
||||
#endif
|
||||
|
||||
TAILQ_ENTRY(connection) list;
|
||||
TAILQ_ENTRY(connection) flush_list;
|
||||
};
|
||||
|
||||
TAILQ_HEAD(connection_list, connection);
|
||||
extern struct connection_list connections;
|
||||
extern struct connection_list disconnected;
|
||||
|
||||
struct listener {
|
||||
u_int8_t type;
|
||||
u_int8_t addrtype;
|
||||
int fd;
|
||||
void (*connect)(struct connection *);
|
||||
|
||||
union {
|
||||
struct sockaddr_in ipv4;
|
||||
struct sockaddr_in6 ipv6;
|
||||
} addr;
|
||||
|
||||
LIST_ENTRY(listener) list;
|
||||
};
|
||||
|
||||
LIST_HEAD(listener_head, listener);
|
||||
|
||||
#if !defined(KORE_NO_HTTP)
|
||||
|
||||
struct kore_handler_params {
|
||||
|
|
|
@ -917,6 +917,10 @@ cli_compile_cfile(void *arg)
|
|||
args[idx++] = ppath;
|
||||
#endif
|
||||
|
||||
#if defined(KORE_NO_HTTP)
|
||||
args[idx++] = "-DKORE_NO_HTTP";
|
||||
#endif
|
||||
|
||||
args[idx++] = "-Wall";
|
||||
args[idx++] = "-Wmissing-declarations";
|
||||
args[idx++] = "-Wshadow";
|
||||
|
|
|
@ -50,7 +50,6 @@ kore_connection_new(void *owner)
|
|||
c->rnb = NULL;
|
||||
c->snb = NULL;
|
||||
c->cert = NULL;
|
||||
c->wscbs = NULL;
|
||||
c->owner = owner;
|
||||
c->tls_reneg = 0;
|
||||
c->disconnect = NULL;
|
||||
|
@ -61,6 +60,7 @@ kore_connection_new(void *owner)
|
|||
c->idle_timer.length = KORE_IDLE_TIMER_MAX;
|
||||
|
||||
#if !defined(KORE_NO_HTTP)
|
||||
c->wscbs = NULL;
|
||||
TAILQ_INIT(&(c->http_requests));
|
||||
#endif
|
||||
|
||||
|
@ -265,8 +265,8 @@ kore_connection_handle(struct connection *c)
|
|||
NETBUF_CALL_CB_ALWAYS, http_header_recv);
|
||||
#endif
|
||||
|
||||
tls_established:
|
||||
c->state = CONN_STATE_ESTABLISHED;
|
||||
tls_established:
|
||||
/* FALLTHROUGH */
|
||||
#endif /* !KORE_NO_TLS */
|
||||
case CONN_STATE_ESTABLISHED:
|
||||
|
|
Loading…
Reference in New Issue