Added "emergency collection" to 'io.tmpfile' and 'os.tmpname'

These operations also can give errors for lack of resources, so they
also will try "emergency collections" in case of resource errors.
Because there are now two libraries with that kind of handling,
'resourcetryagain' was moved to the auxiliary library to be shared
by the libraries.
This commit is contained in:
Roberto Ierusalimschy
2018-07-27 15:50:53 -03:00
parent aa4c5cf190
commit 3d838f635c
5 changed files with 71 additions and 50 deletions

View File

@@ -5538,6 +5538,20 @@ Leaves a copy of the module on the stack.
}
@APIEntry{int luaL_resourcetryagain (lua_State *L);|
@apii{0,0,m}
Try to release resources in case of errors.
This function uses @id{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.
}
@APIEntry{void luaL_setfuncs (lua_State *L, const luaL_Reg *l, int nup);|
@apii{nup,0,m}