Why does this work?

Can someone explain why the function resend_offline_messages in ejabberd_c2s.erl works? As far as I can see it takes saved messages and re-routes them through the ejabberd router when a presence is detected. All fine and good, but what happens if a new message arrives in the middle of this process? Surely this new message will be inserted in the middle of the saved messages, and we then have messages out of order?

Is incoming message routing somehow disabled during this process? Or is it just uncommon? And I wonder why it is done this way and the original code to directly send the messages commented out?

Syndicate content