Bugs fixed - HenryHu/pybbs GitHub Wiki

2012.4.4

The "Unrecognized stanza {...}presence" bug.

Generally, this bug is not completely fixed now. Its root cause is the extra notification thread. This introduces races between this thread and the main thread. Originally, the main thread is the only thread, and all the operations are serially performed. So there is no races. But now, the new notification thread may access data structures newly allocated in the main thread which have not been fully initialized.

So the "unrecognized stanza..." exception is caused by XMPPServer objects which have not been fully initialized. The connection may be newly created, and it's still in the early stage of negotiation. The handlers in XMPPServer class have not been registered, so the "presence" stanza is not recognized.

Now we just capture the exceptions occurred in the process of sending notifications. In theory, if we can wrap all the possible accesses with try...catch, then this problem would not show up. But we should restore the single-threaded architecture, and allow only the main thread to access the objects. The notification thread should either be removed, and move its work into the main thread, or just delegate all the jobs of sending messages to the main thread.