daemon various nitpicks

- session: data length would be difference between start and end
  indices, but the function is unused so why even have it?
parent 2d87427c
Pipeline #42675 canceled with stages
in 2 seconds
...@@ -184,9 +184,7 @@ void tcp_timeout_trigger(uv_timer_t *timer) ...@@ -184,9 +184,7 @@ void tcp_timeout_trigger(uv_timer_t *timer)
static void tcp_recv(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf) static void tcp_recv(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf)
{ {
uv_loop_t *loop = handle->loop;
struct session *s = handle->data; struct session *s = handle->data;
assert(s && session_get_handle(s) == (uv_handle_t *)handle && assert(s && session_get_handle(s) == (uv_handle_t *)handle &&
handle->type == UV_TCP); handle->type == UV_TCP);
...@@ -200,8 +198,6 @@ static void tcp_recv(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf) ...@@ -200,8 +198,6 @@ static void tcp_recv(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf)
return; return;
} }
struct worker_ctx *worker = loop->data;
if (nread < 0 || !buf->base) { if (nread < 0 || !buf->base) {
if (kr_verbose_status) { if (kr_verbose_status) {
struct sockaddr *peer = session_get_peer(s); struct sockaddr *peer = session_get_peer(s);
...@@ -240,6 +236,7 @@ static void tcp_recv(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf) ...@@ -240,6 +236,7 @@ static void tcp_recv(uv_stream_t *handle, ssize_t nread, const uv_buf_t *buf)
worker_end_tcp(s); worker_end_tcp(s);
} }
session_wirebuf_compress(s); session_wirebuf_compress(s);
struct worker_ctx *worker = handle->loop->data;
mp_flush(worker->pkt_pool.ctx); mp_flush(worker->pkt_pool.ctx);
} }
......
...@@ -689,11 +689,6 @@ uint8_t *session_wirebuf_get_start(struct session *session) ...@@ -689,11 +689,6 @@ uint8_t *session_wirebuf_get_start(struct session *session)
return session->wire_buf; return session->wire_buf;
} }
size_t session_wirebuf_get_len(struct session *session)
{
return session->wire_buf_end_idx;
}
size_t session_wirebuf_get_size(struct session *session) size_t session_wirebuf_get_size(struct session *session)
{ {
return session->wire_buf_size; return session->wire_buf_size;
......
...@@ -119,8 +119,6 @@ int session_timer_stop(struct session *session); ...@@ -119,8 +119,6 @@ int session_timer_stop(struct session *session);
uint8_t *session_wirebuf_get_start(struct session *session); uint8_t *session_wirebuf_get_start(struct session *session);
/** Get size of session wirebuffer. */ /** Get size of session wirebuffer. */
size_t session_wirebuf_get_size(struct session *session); size_t session_wirebuf_get_size(struct session *session);
/** Get length of data in the session wirebuffer. */
size_t session_wirebuf_get_len(struct session *session);
/** Get pointer to the beginning of free space in session wirebuffer. */ /** Get pointer to the beginning of free space in session wirebuffer. */
uint8_t *session_wirebuf_get_free_start(struct session *session); uint8_t *session_wirebuf_get_free_start(struct session *session);
/** Get amount of free space in session wirebuffer. */ /** Get amount of free space in session wirebuffer. */
......
...@@ -451,7 +451,12 @@ ssize_t tls_process_input_data(struct session *s, const uint8_t *buf, ssize_t nr ...@@ -451,7 +451,12 @@ ssize_t tls_process_input_data(struct session *s, const uint8_t *buf, ssize_t nr
} }
assert(tls_p->session == s); assert(tls_p->session == s);
assert(tls_p->recv_buf == buf && nread <= sizeof(tls_p->recv_buf)); const bool ok = tls_p->recv_buf == buf && nread <= sizeof(tls_p->recv_buf);
if (!ok) {
assert(false);
/* don't risk overflowing the buffer if we have a mistake somewhere */
return kr_error(EINVAL);
}
const char *logstring = tls_p->client_side ? client_logstring : server_logstring; const char *logstring = tls_p->client_side ? client_logstring : server_logstring;
......
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