From da1d43a2c7ae0468f1d38f40c33a0d11ce4c2daf Mon Sep 17 00:00:00 2001 From: Edwin Mons Date: Wed, 29 Apr 2015 11:21:29 +0200 Subject: Honour global sluift timeout setting in add/remove contact The add_contact and remove_contact calls used a fixed timeout of -1, which could cause the operation to hang forever, even when a timeout was set. Test-Information: add_contact and remove_contact properly honour global timeout on a broken connection. Change-Id: I6bd877a8123ddab87b1f653c0cfda7a6b101dae7 diff --git a/Sluift/client.cpp b/Sluift/client.cpp index 79d988a..f1fc2c7 100644 --- a/Sluift/client.cpp +++ b/Sluift/client.cpp @@ -601,6 +601,8 @@ SLUIFT_LUA_FUNCTION_WITH_HELP( Sluift::globals.eventLoop.runOnce(); SluiftClient* client = getClient(L); RosterItemPayload item; + int timeout = getGlobalTimeout(L); + if (lua_type(L, 2) == LUA_TTABLE) { lua_getfield(L, 2, "jid"); const char* rawJID = lua_tostring(L, -1); @@ -639,7 +641,7 @@ SLUIFT_LUA_FUNCTION_WITH_HELP( roster->addItem(item); Sluift::Response response = client->sendVoidRequest( - SetRosterRequest::create(roster, client->getClient()->getIQRouter()), -1); + SetRosterRequest::create(roster, client->getClient()->getIQRouter()), timeout); if (response.error) { return response.convertToLuaResult(L); } @@ -659,12 +661,13 @@ SLUIFT_LUA_FUNCTION_WITH_HELP( Sluift::globals.eventLoop.runOnce(); SluiftClient* client = getClient(L); JID jid(Lua::checkString(L, 2)); + int timeout = getGlobalTimeout(L); RosterPayload::ref roster = boost::make_shared(); roster->addItem(RosterItemPayload(JID(Lua::checkString(L, 2)), "", RosterItemPayload::Remove)); return client->sendVoidRequest( - SetRosterRequest::create(roster, client->getClient()->getIQRouter()), -1).convertToLuaResult(L); + SetRosterRequest::create(roster, client->getClient()->getIQRouter()), timeout).convertToLuaResult(L); } SLUIFT_LUA_FUNCTION_WITH_HELP( -- cgit v0.10.2-6-g49f6