Run application handlers on stream error.
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.
--- a/loudmouth/lm-connection.c Sun Jun 10 18:03:56 2007 +0200
+++ b/loudmouth/lm-connection.c Sun Jun 10 18:14:31 2007 +0200
@@ -287,7 +287,7 @@
}
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 @@
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 @@
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 @@
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;