From d2aeca9bb4517658e22529168c17d789db9dab43 Mon Sep 17 00:00:00 2001 From: James Booth Date: Tue, 16 Oct 2012 23:29:58 +0100 Subject: Attempted fix at causing segfault by freeing connection --- src/jabber.c | 18 +++++++++++------- src/jabber.h | 1 + src/profanity.c | 1 + 3 files changed, 13 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/jabber.c b/src/jabber.c index da606132..64d33666 100644 --- a/src/jabber.c +++ b/src/jabber.c @@ -70,6 +70,17 @@ jabber_init(const int disable_tls) jabber_conn.tls_disabled = disable_tls; } +void +jabber_shutdown(void) +{ + // free memory for connection and context + xmpp_conn_release(jabber_conn.conn); + xmpp_ctx_free(jabber_conn.ctx); + + // shutdown libstrophe + xmpp_shutdown(); +} + jabber_conn_status_t jabber_connect(const char * const user, const char * const passwd) @@ -306,13 +317,6 @@ _connection_handler(xmpp_conn_t * const conn, // received close stream response from server after disconnect if (jabber_conn.conn_status == JABBER_DISCONNECTING) { - // free memory for connection object and context - xmpp_conn_release(jabber_conn.conn); - xmpp_ctx_free(jabber_conn.ctx); - - // shutdown libstrophe - xmpp_shutdown(); - jabber_conn.conn_status = JABBER_DISCONNECTED; jabber_conn.presence = PRESENCE_OFFLINE; diff --git a/src/jabber.h b/src/jabber.h index 7e04d0bb..f9ad7fb6 100644 --- a/src/jabber.h +++ b/src/jabber.h @@ -41,6 +41,7 @@ typedef enum { } jabber_presence_t; void jabber_init(const int disable_tls); +void jabber_shutdown(void); jabber_conn_status_t jabber_connect(const char * const user, const char * const passwd); gboolean jabber_disconnect(void); diff --git a/src/profanity.c b/src/profanity.c index 249268a5..002b2453 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -281,6 +281,7 @@ _shutdown_init(void) while (jabber_get_connection_status() == JABBER_DISCONNECTING) { jabber_process_events(); } + jabber_shutdown(); } _shutdown(); -- cgit 1.4.1-2-gfad0 lue='fd72ec75e09c8a86a5708a4a9f6375038a96a5ce'/>
path: root/html/038new_text.cc.html
blob: 179c33a004d547b722eb6d1cb9f0523dc7db2542 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161