It turns the nexus code was leaking quite a bit and also most probably
redirections were not working correctly. These patches should fix that.
Felipe Contreras (4):
nexus: connect after setting up
nexus: don't close the node manually
nexus: reorganize a bit
nexus: fix memory leaks
nexus.c | 31 +++++++++++++++++--------------
1 files changed, 17 insertions(+), 14 deletions(-)
Signed-off-by: Felipe Contreras <felipe.c...@gmail.com>
---
nexus.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/nexus.c b/nexus.c
index 108f8e3..d264856 100644
--- a/nexus.c
+++ b/nexus.c
@@ -384,12 +384,12 @@ nexus_read_cb(PnNode *conn,
nexus->parser = pn_parser_new(conn);
pn_ssl_conn_set_read_cb(ssl_conn, login_read_cb, nexus);
- pn_node_connect(conn, nexus->login_host, 443);
-
nexus->conn = conn;
nexus->open_handler = g_signal_connect(conn, "open", G_CALLBACK(login_open_cb), nexus);
nexus->error_handler = g_signal_connect(conn, "error", G_CALLBACK(close_cb), nexus);
+ pn_node_connect(conn, nexus->login_host, 443);
+
goto leave;
}
}
@@ -436,9 +436,9 @@ msn_nexus_connect(MsnNexus *nexus)
nexus->parser = pn_parser_new(conn);
pn_ssl_conn_set_read_cb(ssl_conn, nexus_read_cb, nexus);
- pn_node_connect(conn, "nexus.passport.com", 443);
-
nexus->conn = conn;
nexus->open_handler = g_signal_connect(conn, "open", G_CALLBACK(nexus_open_cb), nexus);
nexus->error_handler = g_signal_connect(conn, "error", G_CALLBACK(close_cb), nexus);
+
+ pn_node_connect(conn, "nexus.passport.com", 443);
}
--
1.6.6.1
Signed-off-by: Felipe Contreras <felipe.c...@gmail.com>
---
nexus.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/nexus.c b/nexus.c
index d264856..32e1749 100644
--- a/nexus.c
+++ b/nexus.c
@@ -236,7 +236,6 @@ login_read_cb(PnNode *conn,
}
leave:
- pn_node_close(conn);
g_object_unref(conn);
}
--
1.6.6.1
Signed-off-by: Felipe Contreras <felipe.c...@gmail.com>
---
nexus.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/nexus.c b/nexus.c
index 32e1749..0f01a3b 100644
--- a/nexus.c
+++ b/nexus.c
@@ -205,10 +205,8 @@ login_read_cb(PnNode *conn,
status = pn_parser_read_line(nexus->parser, &str, NULL, &terminator_pos, NULL);
- if (status == G_IO_STATUS_AGAIN) {
- g_object_unref(conn);
- return;
- }
+ if (status == G_IO_STATUS_AGAIN)
+ goto leave;
if (status != G_IO_STATUS_NORMAL) {
msn_session_set_error(nexus->session, MSN_ERROR_AUTH,
@@ -339,7 +337,7 @@ nexus_read_cb(PnNode *conn,
if (status != G_IO_STATUS_NORMAL) {
msn_session_set_error(nexus->session, MSN_ERROR_AUTH,
_("nexus stream error"));
- goto leave;
+ return;
}
if (str) {
--
1.6.6.1
Signed-off-by: Felipe Contreras <felipe.c...@gmail.com>
---
nexus.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/nexus.c b/nexus.c
index 0f01a3b..6842c9e 100644
--- a/nexus.c
+++ b/nexus.c
@@ -56,6 +56,7 @@ msn_nexus_destroy(MsnNexus *nexus)
g_signal_handler_disconnect(nexus->conn, nexus->error_handler);
if (nexus->open_handler)
g_signal_handler_disconnect(nexus->conn, nexus->open_handler);
+ g_object_unref(nexus->conn);
pn_parser_free(nexus->parser);
if (nexus->header)
@@ -226,6 +227,7 @@ login_read_cb(PnNode *conn,
nexus->header = NULL;
got_header(nexus, tmp);
g_free(tmp);
+ g_free(str);
break;
}
@@ -378,6 +380,13 @@ nexus_read_cb(PnNode *conn,
conn = PN_NODE(ssl_conn);
conn->session = nexus->session;
+ if (nexus->error_handler)
+ g_signal_handler_disconnect(nexus->conn, nexus->error_handler);
+ if (nexus->open_handler)
+ g_signal_handler_disconnect(nexus->conn, nexus->open_handler);
+ g_object_unref(nexus->conn);
+ pn_parser_free(nexus->parser);
+
nexus->parser = pn_parser_new(conn);
pn_ssl_conn_set_read_cb(ssl_conn, login_read_cb, nexus);
@@ -387,13 +396,10 @@ nexus_read_cb(PnNode *conn,
pn_node_connect(conn, nexus->login_host, 443);
- goto leave;
+ return;
}
}
}
-
-leave:
- pn_node_close(conn);
}
static void
--
1.6.6.1