From 76b0300505d9c77192960b0b9588df2dd2bedc02 Mon Sep 17 00:00:00 2001 From: Badlop Date: Mon, 21 Feb 2011 12:55:40 +0100 Subject: [PATCH 1/2] Mention in release notes that Pubsub/PEP isn't ready for alpha-testing (EJAB-1393) --- doc/release_notes_3.0.0.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/release_notes_3.0.0.txt b/doc/release_notes_3.0.0.txt index 0791ac995..89ef1cb79 100644 --- a/doc/release_notes_3.0.0.txt +++ b/doc/release_notes_3.0.0.txt @@ -11,6 +11,7 @@ * The only supported migrations are * from any ejabberd 0.9.0 ... 2.1.5 to the final 3.0.0. * Don't use this preliminary ejabberd release for a production server. +* Also, Pubsub/PEP is not yet ready for alpha-testing in this release. * You can test this release with a blank database or with a copy of your * production database, but don't let your users connect to this copy * because their changes may get lost when you upgrade to the final 3.0.0. From 8f9bf47d78af91672085632dc15e7fbb46d67001 Mon Sep 17 00:00:00 2001 From: Badlop Date: Mon, 21 Feb 2011 13:37:55 +0100 Subject: [PATCH 2/2] New route_iq/5 accepting Timeout (thanks to Edwin Fine)(EJAB-1398) Also new register_iq_response_handler/5 --- src/ejabberd_local.erl | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/ejabberd_local.erl b/src/ejabberd_local.erl index 30d0b2c77..b3f8703a1 100644 --- a/src/ejabberd_local.erl +++ b/src/ejabberd_local.erl @@ -34,10 +34,12 @@ -export([route/3, route_iq/4, + route_iq/5, process_iq_reply/3, register_iq_handler/4, register_iq_handler/5, register_iq_response_handler/4, + register_iq_response_handler/5, unregister_iq_handler/2, unregister_iq_response_handler/2, refresh_iq_handlers/0, @@ -146,19 +148,31 @@ route(From, To, Packet) -> ok end. -route_iq(From, To, #iq{type = Type} = IQ, F) when is_function(F) -> +route_iq(From, To, IQ, F) -> + route_iq(From, To, IQ, F, undefined). + +route_iq(From, To, #iq{type = Type} = IQ, F, Timeout) when is_function(F) -> Packet = if Type == set; Type == get -> ID = list_to_binary(ejabberd_router:make_id()), Host = exmpp_jid:prep_domain(From), - register_iq_response_handler(Host, ID, undefined, F), + register_iq_response_handler(Host, ID, undefined, F, Timeout), exmpp_iq:iq_to_xmlel(IQ#iq{id = ID}); true -> exmpp_iq:iq_to_xmlel(IQ) end, ejabberd_router:route(From, To, Packet). -register_iq_response_handler(_Host, ID, Module, Function) -> - TRef = erlang:start_timer(?IQ_TIMEOUT, ejabberd_local, ID), +register_iq_response_handler(Host, ID, Module, Function) -> + register_iq_response_handler(Host, ID, Module, Function, undefined). + +register_iq_response_handler(_Host, ID, Module, Function, Timeout0) -> + Timeout = case Timeout0 of + undefined -> + ?IQ_TIMEOUT; + N when is_integer(N), N > 0 -> + N + end, + TRef = erlang:start_timer(Timeout, ejabberd_local, ID), ets:insert(iq_response, #iq_response{id = ID, module = Module, function = Function,