Browse Source

Extend mg.write() to return a boolean

xtne6f 10 years ago
parent
commit
97368471d0
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/mod_lua.inl

+ 6 - 2
src/mod_lua.inl

@@ -409,15 +409,19 @@ lsp_write(lua_State *L)
 	const char *str;
 	size_t size;
 	int i;
+	int rv = 1;
 
 	for (i = 1; i <= num_args; i++) {
 		if (lua_isstring(L, i)) {
 			str = lua_tolstring(L, i, &size);
-			mg_write(conn, str, size);
+			if (mg_write(conn, str, size) != (int)size) {
+				rv = 0;
+			}
 		}
 	}
+	lua_pushboolean(L, rv);
 
-	return 0;
+	return 1;
 }