mod_http: Use hostname from the correct context (thanks gryffus)
[prosody.git] / util-src / pposix.c
index f5cc827032976c74c3ac624620b46aebb85c658a..4fb1fb56b5346f062d9310b70a8788c177320a09 100644 (file)
@@ -36,7 +36,7 @@
 #include "lauxlib.h"
 
 #include <fcntl.h>
-#if defined(_GNU_SOURCE)
+#if defined(__linux__) && defined(_GNU_SOURCE)
 #include <linux/falloc.h>
 #endif
 
@@ -500,6 +500,7 @@ int lc_setrlimit(lua_State *L) {
        if(arguments < 1 || arguments > 3) {
                lua_pushboolean(L, 0);
                lua_pushstring(L, "incorrect-arguments");
+               return 2;
        }
 
        resource = luaL_checkstring(L, 1);
@@ -665,11 +666,13 @@ int lc_fallocate(lua_State* L)
 {
        off_t offset, len;
        FILE *f = *(FILE**) luaL_checkudata(L, 1, LUA_FILEHANDLE);
+       if (f == NULL)
+               luaL_error(L, "attempt to use a closed file");
 
        offset = luaL_checkinteger(L, 2);
        len = luaL_checkinteger(L, 3);
 
-#if defined(_GNU_SOURCE)
+#if defined(__linux__) && defined(_GNU_SOURCE)
        if(fallocate(fileno(f), FALLOC_FL_KEEP_SIZE, offset, len) == 0)
        {
                lua_pushboolean(L, 1);