--- a/src/irc_net.c Thu Apr 16 01:20:09 2009 +0300
+++ b/src/irc_net.c Sun Apr 19 04:04:42 2009 +0300
@@ -290,24 +290,30 @@
return SET_ERROR(err, ERR_CALLOC);
// initialize
+ // XXX: info shouldn't be copied directly
net->info = *info;
TAILQ_INIT(&net->channels);
LIST_INIT(&net->users);
if (info->raw_sock) {
- // direct sock_stream connection
log_debug("connected using raw socket: %p", info->raw_sock);
+ // direct sock_stream connection
sock = info->raw_sock;
// then create the conn right away
if (irc_net_connected(net, sock, err))
goto error;
- } else if (info->use_ssl) {
+ } else if (info->ssl_cred) {
+ // aquire a ref
+ // NOTE: before any error handling
+ sock_ssl_client_cred_get(net->info.ssl_cred);
+
log_debug("connecting to [%s]:%s using SSL", info->hostname, info->service);
- if (sock_ssl_connect_async(&sock, info->hostname, info->service, &irc_net_on_connect, net, err))
+ // connect
+ if (sock_ssl_connect_async(&sock, info->hostname, info->service, net->info.ssl_cred, &irc_net_on_connect, net, err))
goto error;
} else {
@@ -337,21 +343,31 @@
void irc_net_destroy (struct irc_net *net)
{
- struct irc_chan *next = TAILQ_FIRST(&net->channels), *chan;
+ struct irc_chan *chan_next = TAILQ_FIRST(&net->channels), *chan;
+ struct irc_user *user_next = LIST_FIRST(&net->users), *user;
// our conn
if (net->conn)
irc_conn_destroy(net->conn);
// our channels
- while (next) {
- chan = next;
- next = TAILQ_NEXT(chan, net_channels);
+ while ((chan = chan_next)) {
+ chan_next = TAILQ_NEXT(chan, net_channels);
irc_chan_destroy(chan);
}
- // XXX: our users
+ // our users
+ // XXX: this disregards external refs
+ while ((user = user_next)) {
+ user_next = LIST_NEXT(user, net_users);
+
+ irc_user_destroy(user);
+ }
+
+ // our info
+ if (net->info.ssl_cred)
+ sock_ssl_client_cred_put(net->info.ssl_cred);
// ourselves
free(net);