imap_parser_destroy(client->parser);
client_open_streams(client, fd_ssl);
+ client->common.io = io_add(client->common.fd, IO_READ,
+ client_input, client);
} else {
- client_send_line(client, " * BYE TLS handehake failed.");
- client_destroy(client, "TLS handshake failed");
+ client_send_line(client, "* BYE TLS initialization failed.");
+ client_destroy(client, "TLS initialization failed.");
}
- client->common.io =
- io_add(client->common.fd, IO_READ, client_input, client);
return TRUE;
}
client->common.io = NULL;
}
- net_disconnect(client->common.fd);
- client->common.fd = -1;
+ if (client->common.fd != -1) {
+ net_disconnect(client->common.fd);
+ client->common.fd = -1;
+ }
i_free(client->common.virtual_user);
client_unref(client);
proxy->refcount++;
ssl_handshake(proxy);
- if (!ssl_proxy_destroy(proxy))
- return -1;
+ if (!ssl_proxy_destroy(proxy)) {
+ /* handshake failed. return the disconnected socket anyway
+ so the caller doesn't try to use the old closed fd */
+ return sfd[1];
+ }
main_ref();
return sfd[1];
proxy->refcount++;
ssl_handshake_step(proxy);
- if (!ssl_proxy_destroy(proxy))
- return -1;
+ if (!ssl_proxy_destroy(proxy)) {
+ /* handshake failed. return the disconnected socket anyway
+ so the caller doesn't try to use the old closed fd */
+ return sfd[1];
+ }
main_ref();
return sfd[1];
o_stream_unref(client->output);
client_open_streams(client, fd_ssl);
+ client->common.io = io_add(client->common.fd, IO_READ,
+ client_input, client);
} else {
- client_send_line(client, "-ERR TLS handehake failed.");
- client_destroy(client, "TLS handshake failed");
+ client_send_line(client, "-ERR TLS initialization failed.");
+ client_destroy(client, "TLS initialization failed.");
}
- client->common.io =
- io_add(client->common.fd, IO_READ, client_input, client);
return TRUE;
}