feat(lnm): add some internal logging
This commit is contained in:
parent
3aa0ace863
commit
dde83584a7
2 changed files with 30 additions and 4 deletions
|
|
@ -6,8 +6,11 @@
|
|||
#include <unistd.h>
|
||||
|
||||
#include "lnm/common.h"
|
||||
#include "lnm/log.h"
|
||||
#include "lnm/loop_internal.h"
|
||||
|
||||
static const char *section = "loop";
|
||||
|
||||
lnm_err lnm_loop_init(lnm_loop **out, void *gctx,
|
||||
lnm_err (*ctx_init)(void **out, void *gctx),
|
||||
void (*ctx_free)(void *ctx),
|
||||
|
|
@ -34,6 +37,8 @@ lnm_err lnm_loop_accept(lnm_loop *l) {
|
|||
int conn_fd = accept(l->listen_fd, NULL, NULL);
|
||||
|
||||
if (conn_fd < 0) {
|
||||
lnm_lcritical(section, "accept failed: %i", conn_fd);
|
||||
|
||||
return lnm_err_failed_network;
|
||||
}
|
||||
|
||||
|
|
@ -72,6 +77,8 @@ lnm_err lnm_loop_accept(lnm_loop *l) {
|
|||
|
||||
l->conns.open++;
|
||||
|
||||
lnm_ldebug(section, "connection opened with fd %i", conn_fd);
|
||||
|
||||
return lnm_err_ok;
|
||||
}
|
||||
|
||||
|
|
@ -130,6 +137,8 @@ lnm_err lnm_loop_run(lnm_loop *l) {
|
|||
poll_args[0].fd = l->listen_fd;
|
||||
poll_args[0].events = POLLIN;
|
||||
|
||||
lnm_linfo(section, "started on fd %i", l->listen_fd);
|
||||
|
||||
while (1) {
|
||||
nfds_t poll_args_len = 1;
|
||||
|
||||
|
|
@ -171,6 +180,8 @@ lnm_err lnm_loop_run(lnm_loop *l) {
|
|||
close(conn->fd);
|
||||
|
||||
l->conns.open--;
|
||||
lnm_ldebug(section, "connection closed with fd %i", conn->fd);
|
||||
|
||||
lnm_loop_conn_free(l, conn);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue