diff options
author | Alexey Shchepin <alexey@process-one.net> | 2004-08-22 21:54:14 +0000 |
---|---|---|
committer | Alexey Shchepin <alexey@process-one.net> | 2004-08-22 21:54:14 +0000 |
commit | 4103f30812ed99c984a2fdb16aabca139c9255d7 (patch) | |
tree | 449c3946ebd1e8c040656e119c4276e2d2d9cb00 /src/mod_offline.erl | |
parent | * src/msgs/nl.msg: Updated (thanks to Sander Devrieze) (diff) |
* src/mod_offline.erl: Added entire table locking on large message
queue
* src/ejabberd_sm.erl: Added offline_subscription_hook
* src/mod_offline.erl: Use offline_subscription_hook
* src/configure.erl: Updated (thanks to Sergei Golovan)
* src/Makefile.win32: Likewise
* src/tls/Makefile.win32: Likewise
* src/win32/: Likewise
* src/mod_announce.erl: Added announce to all users (thanks to
Sergei Golovan)
* doc/guide.tex: Updated (thanks to Sergei Golovan)
SVN Revision: 259
Diffstat (limited to '')
-rw-r--r-- | src/mod_offline.erl | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mod_offline.erl b/src/mod_offline.erl index 22e9b85ee..e96b8f371 100644 --- a/src/mod_offline.erl +++ b/src/mod_offline.erl @@ -25,6 +25,7 @@ -record(offline_msg, {user, timestamp, from, to, packet}). -define(PROCNAME, ejabberd_offline). +-define(OFFLINE_TABLE_LOCK_THRESHOLD, 1000). start(_) -> mnesia:create_table(offline_msg, @@ -33,6 +34,8 @@ start(_) -> {attributes, record_info(fields, offline_msg)}]), ejabberd_hooks:add(offline_message_hook, ?MODULE, store_packet, 50), + ejabberd_hooks:add(offline_subscription_hook, + ?MODULE, store_packet, 50), ejabberd_hooks:add(resend_offline_messages_hook, ?MODULE, pop_offline_messages, 50), register(?PROCNAME, spawn(?MODULE, init, [])). @@ -44,7 +47,14 @@ loop() -> receive #offline_msg{} = Msg -> Msgs = receive_all([Msg]), + Len = length(Msgs), F = fun() -> + if + Len >= ?OFFLINE_TABLE_LOCK_THRESHOLD -> + mnesia:write_lock_table(offline_msg); + true -> + ok + end, lists:foreach(fun(M) -> mnesia:write(M) end, Msgs) |