Run application handlers on stream error. master
authorMikael Hallendal <micke@imendio.com>
Sun, 10 Jun 2007 16:14:31 +0000 (18:14 +0200)
committerMikael Hallendal <micke@imendio.com>
Sun, 10 Jun 2007 16:14:31 +0000 (18:14 +0200)
Patch from Owen Taylor that fixes LM-104 where application handlers weren't run on stream error.

It also fixes a problem where a variable is incorrectly overwritten.

loudmouth/lm-connection.c

index 21784c6aa8391a4c807294523feed965f29fd7bf..74ed958550cbac4adf7516523a98cb5dba0d2b57 100644 (file)
@@ -287,7 +287,7 @@ connection_handle_message (LmConnection *connection, LmMessage *m)
        }
        else if (lm_message_get_type (m) == LM_MESSAGE_TYPE_STREAM_ERROR) {
                connection_stream_error (connection, m);
-               goto out;
+               goto run_global_handlers;
        }
        
        id = lm_message_node_get_attribute (m->node, "id");
@@ -306,6 +306,7 @@ connection_handle_message (LmConnection *connection, LmMessage *m)
                goto out;
        }
 
+run_global_handlers:
        for (l = connection->handlers[lm_message_get_type (m)]; 
             l && result == LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS; 
             l = l->next) {
@@ -1463,7 +1464,7 @@ connection_auth_reply (LmMessageHandler *handler,
 static void
 connection_stream_error (LmConnection *connection, LmMessage *m)
 {
-       LmMessageNode *node;
+       LmMessageNode *node, *child;
 
        g_return_if_fail (connection != NULL);
        g_return_if_fail (m != NULL);
@@ -1471,16 +1472,16 @@ connection_stream_error (LmConnection *connection, LmMessage *m)
        node = m->node;
 
        /* Resource conflict */
-       node = lm_message_node_get_child (node, "conflict");
-       if (node) {
+       child = lm_message_node_get_child (node, "conflict");
+       if (child) {
                lm_verbose ("Stream error: Conflict (resource connected elsewhere)\n");
                connection->disconnect_reason = LM_DISCONNECT_REASON_RESOURCE_CONFLICT;
                return;
        }
 
        /* XML is crack */
-       node = lm_message_node_get_child (node, "xml-not-well-formed");
-       if (node) {
+       child = lm_message_node_get_child (node, "xml-not-well-formed");
+       if (child) {
                lm_verbose ("Stream error: XML not well formed\n");
                connection->disconnect_reason = LM_DISCONNECT_REASON_INVALID_XML;
                return;