fix(lnm): some small bugs
ci/woodpecker/push/build Pipeline was successful
Details
ci/woodpecker/push/build Pipeline was successful
Details
parent
8ae59f1031
commit
876e5a7de4
|
@ -275,9 +275,10 @@ void lnm_http_loop_process_finish(lnm_http_conn *conn) {
|
|||
return;
|
||||
}
|
||||
|
||||
lnm_http_loop_ctx_reset(conn->ctx);
|
||||
lnm_http_loop_ctx *ctx = conn->ctx;
|
||||
lnm_http_loop_ctx_reset(ctx);
|
||||
|
||||
conn->state = lnm_loop_state_req;
|
||||
ctx->state = lnm_http_loop_state_parse_req;
|
||||
}
|
||||
|
||||
void (*process_fns[])(lnm_http_conn *conn) = {
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <poll.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lnm/common.h"
|
||||
#include "lnm/loop_internal.h"
|
||||
|
@ -43,10 +44,9 @@ lnm_err lnm_loop_accept(lnm_loop *l) {
|
|||
|
||||
// Append connection to list of connections
|
||||
if ((size_t)conn_fd >= l->conns.len) {
|
||||
lnm_loop_conn **new =
|
||||
l->conns.len == 0
|
||||
? calloc(sizeof(lnm_loop_conn *), conn_fd + 1)
|
||||
: realloc(l->conns.arr, sizeof(lnm_loop_conn *) * (conn_fd + 1));
|
||||
// We always calloc as a realloc might introduce unitialized values in the
|
||||
// array
|
||||
lnm_loop_conn **new = calloc(sizeof(lnm_loop_conn *), conn_fd + 1);
|
||||
|
||||
if (new == NULL) {
|
||||
close(conn_fd);
|
||||
|
@ -54,6 +54,11 @@ lnm_err lnm_loop_accept(lnm_loop *l) {
|
|||
return lnm_err_failed_alloc;
|
||||
}
|
||||
|
||||
if (l->conns.len > 0) {
|
||||
memcpy(new, l->conns.arr, l->conns.len * sizeof(lnm_loop_conn *));
|
||||
free(l->conns.arr);
|
||||
}
|
||||
|
||||
l->conns.arr = new;
|
||||
l->conns.len = conn_fd + 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue