aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMikhail Galanin <mgalanin@mimecast.com>2018-09-05 11:18:34 +0100
committerMikhail Galanin <mgalanin@mimecast.com>2018-09-05 11:18:34 +0100
commit7c13830ca02e80e332641f66ea6b0c47c0ae8c94 (patch)
treec36c9ce19381f93bfe91689294630a5558c04ad7 /src
parent8fa5200f60ab2f32d759dbf980dd3e6cc7e23f70 (diff)
downloadrspamd-7c13830ca02e80e332641f66ea6b0c47c0ae8c94.tar.gz
rspamd-7c13830ca02e80e332641f66ea6b0c47c0ae8c94.zip
[Minor] timeout in seconds everywhere (as documentation says)
Diffstat (limited to 'src')
-rw-r--r--src/lua/lua_tcp.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/lua/lua_tcp.c b/src/lua/lua_tcp.c
index 2cf2919bf..5f67607bb 100644
--- a/src/lua/lua_tcp.c
+++ b/src/lua/lua_tcp.c
@@ -213,7 +213,7 @@ static const struct luaL_reg tcp_libm[] = {
LUA_FUNCTION_DEF (tcp_sync, close);
/***
- * @method set_timeout(timeout)
+ * @method set_timeout(seconds)
*
* Sets timeout for IO operations
*/
@@ -1813,14 +1813,16 @@ lua_tcp_set_timeout (lua_State *L)
{
LUA_TRACE_POINT;
struct lua_tcp_cbdata *cbd = lua_check_tcp (L, 1);
- gdouble ms = lua_tonumber (L, 2);
+ gdouble seconds = lua_tonumber (L, 2);
if (cbd == NULL) {
return luaL_error (L, "invalid arguments");
}
+ if (!lua_isnumber (L, 2)) {
+ return luaL_error (L, "invalid arguments: 'seconds' is expected to be number");
+ }
- ms *= 1000.0;
- double_to_tv (ms, &cbd->tv);
+ double_to_tv (seconds, &cbd->tv);
return 0;
}
@@ -2019,7 +2021,7 @@ lua_tcp_sync_set_timeout (lua_State *L)
{
LUA_TRACE_POINT;
struct lua_tcp_cbdata *cbd = lua_check_sync_tcp (L, 1);
- gdouble ms = lua_tonumber (L, 2);
+ gdouble seconds = lua_tonumber (L, 2);
if (cbd == NULL) {
return luaL_error (L, "invalid arguments: self is not rspamd{tcp_sync}");
@@ -2028,8 +2030,7 @@ lua_tcp_sync_set_timeout (lua_State *L)
return luaL_error (L, "invalid arguments: second parameter is expected to be number");
}
- ms *= 1000.0;
- double_to_tv (ms, &cbd->tv);
+ double_to_tv (seconds, &cbd->tv);
return 0;
}