From 2fc6b55dae7a120b4272ca0e9c356d1f96053bd9 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 31 Oct 2018 16:25:29 -0300 Subject: Removed resource-related "emergency collections" New to-be-closed variables is a better way to ensure the proper release of resources. --- lauxlib.c | 43 ------------------------------------------- 1 file changed, 43 deletions(-) (limited to 'lauxlib.c') diff --git a/lauxlib.c b/lauxlib.c index 53b8c9bb..78dfb4e9 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -290,49 +290,6 @@ LUALIB_API int luaL_execresult (lua_State *L, int stat) { /* }====================================================== */ -/* -** {====================================================== -** 'luaL_resourcetryagain' -** This function uses 'errno' to check whether the last error was -** related to lack of resources (e.g., not enough memory or too many -** open files). If so, the function performs a full garbage collection -** to try to release resources, and then it returns 1 to signal to -** the caller that it is worth trying again the failed operation. -** Otherwise, it returns 0. Because error codes are not ANSI C, the -** code must handle any combination of error codes that are defined. -** ======================================================= -*/ - -LUALIB_API int luaL_resourcetryagain (lua_State *L) { - -/* these are the resource-related errors in Linux */ -#if defined(EMFILE) || defined(ENFILE) || defined(ENOMEM) - -#if !defined(EMFILE) /* too many open files in the process */ -#define EMFILE -1 /* if not defined, use an impossible value */ -#endif - -#if !defined(ENFILE) /* too many open files in the system */ -#define ENFILE -1 -#endif - -#if !defined(ENOMEM) /* not enough memory */ -#define ENOMEM -1 -#endif - - if (errno == EMFILE || errno == ENFILE || errno == ENOMEM) { - lua_gc(L, LUA_GCCOLLECT); /* try to release resources with a full GC */ - return 1; /* signal to try again the creation */ - } - -#endif - - return 0; /* else, asume errors are not due to lack of resources */ - -} - -/* }====================================================== */ - /* ** {====================================================== -- cgit v1.2.3-55-g6feb