summaryrefslogtreecommitdiffhomepage
path: root/connection.c
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2021-08-15 17:38:16 +0200
committerAki <please@ignore.pl>2021-08-15 17:38:16 +0200
commit52526c295ccdbe48b4965b269482c0a9fba6e658 (patch)
treed0cb9a1432e41525f8d724ccc68d9f3dc43184bd /connection.c
parent3070ac071925261691d785b78450483f996d2e51 (diff)
downloadplop-52526c295ccdbe48b4965b269482c0a9fba6e658.zip
plop-52526c295ccdbe48b4965b269482c0a9fba6e658.tar.gz
plop-52526c295ccdbe48b4965b269482c0a9fba6e658.tar.bz2
Separated connection and server Lua state
Diffstat (limited to 'connection.c')
-rw-r--r--connection.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/connection.c b/connection.c
index 8fad3c5..d321ae0 100644
--- a/connection.c
+++ b/connection.c
@@ -8,13 +8,10 @@
#include <lua.h>
/// 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);
}