moonbridge
diff moonbridge.c @ 42:0bb356c04f6b
Methods :close() and :cancel() return true value on success; Added assert(...) calls to moonbridge_http.lua on writing to client
author | jbe |
---|---|
date | Sun Mar 08 01:09:28 2015 +0100 (2015-03-08) |
parents | b6619de6f494 |
children | f2efab1ba3d0 |
line diff
1.1 --- a/moonbridge.c Sun Mar 08 00:53:35 2015 +0100 1.2 +++ b/moonbridge.c Sun Mar 08 01:09:28 2015 +0100 1.3 @@ -993,7 +993,8 @@ 1.4 } else { 1.5 luaL_argerror(L, 1, "Not a connection socket"); 1.6 } 1.7 - return 0; 1.8 + lua_pushboolean(L, 1); // TODO: return nil or false on error instead of throwing error 1.9 + return 1; 1.10 } 1.11 1.12 /* Lua function to close both input and output stream from/to peer */ 1.13 @@ -1010,7 +1011,8 @@ 1.14 if (moonbr_child_close_peersocket(timeout)) { 1.15 moonbr_child_lua_errno_error(L, "Could not close socket connection with peer"); 1.16 } 1.17 - return 0; 1.18 + lua_pushboolean(L, 1); // TODO: return nil or false on error instead of throwing error 1.19 + return 1; 1.20 } 1.21 1.22 /* Lua function to close both input and output stream from/to peer */ 1.23 @@ -1021,7 +1023,8 @@ 1.24 if (moonbr_child_cancel_peersocket()) { 1.25 moonbr_child_lua_errno_error(L, "Could not cancel socket connection with peer"); 1.26 } 1.27 - return 0; 1.28 + lua_pushboolean(L, 1); // TODO: return nil or false on error instead of throwing error 1.29 + return 1; 1.30 } 1.31 1.32 /* Methods of (bidirectional) socket object passed to handler */ 1.33 @@ -2242,7 +2245,7 @@ 1.34 while (maxlen > 0 ? maxlen-- : maxlen) { 1.35 byte = fgetc(file); 1.36 if (byte == EOF) { 1.37 - if (ferror(file)) { 1.38 + if (ferror(file)) { // TODO: return nil or false on error instead of throwing error 1.39 char errmsg[MOONBR_MAXSTRERRORLEN]; 1.40 strerror_r(errno, errmsg, MOONBR_MAXSTRERRORLEN); /* use thread-safe call in case child created threads */ 1.41 luaL_error(L, "%s", errmsg);