Browse Source

Reapply idempotent atexit patch;

bjorn 4 years ago
parent
commit
d60277cc2e
1 changed files with 6 additions and 1 deletions
  1. 6 1
      enet.c

+ 6 - 1
enet.c

@@ -772,9 +772,14 @@ static const struct luaL_Reg enet_event_funcs [] = {
 	{NULL, NULL}
 	{NULL, NULL}
 };
 };
 
 
+static int initialized = 0;
+
 int luaopen_enet(lua_State *l) {
 int luaopen_enet(lua_State *l) {
 	enet_initialize();
 	enet_initialize();
-	atexit(enet_deinitialize);
+  if (!initialized) {
+    initialized = 1;
+    atexit(enet_deinitialize);
+  }
 
 
 	// create metatables
 	// create metatables
 	luaL_newmetatable(l, "enet_host");
 	luaL_newmetatable(l, "enet_host");