From 52526c295ccdbe48b4965b269482c0a9fba6e658 Mon Sep 17 00:00:00 2001 From: Aki Date: Sun, 15 Aug 2021 17:38:16 +0200 Subject: Separated connection and server Lua state --- connection.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'connection.c') diff --git a/connection.c b/connection.c index 8fad3c5..d321ae0 100644 --- a/connection.c +++ b/connection.c @@ -8,13 +8,10 @@ #include /// Creates new connection. -/// \param L Server's Lua state /// \param client File descriptor of client's socket /// \return Pointer to connection or NULL if an error occured -struct connection * connection_new(lua_State * L, const int client) +struct connection * connection_new(const int client) { - (void) L; // TODO: Review if lua_State is still needed for connections and server handler. - struct connection * c = malloc(sizeof(struct connection)); if (NULL == c) @@ -32,15 +29,9 @@ struct connection * connection_new(lua_State * L, const int client) } /// Frees all resources associated with the connection. -/// \param L Server's Lua state /// \param c Connection to free -void connection_free(lua_State * L, struct connection * c) +void connection_free(struct connection * c) { - if (LUA_NOREF != c->ref) - { - luaL_unref(L, LUA_REGISTRYINDEX, c->ref); - } - close(c->fd); // TODO: Check for errors in close()? free(c); } -- cgit v1.1