X-Git-Url: http://git.cascardo.eti.br/?p=cascardo%2Frnetproxy.git;a=blobdiff_plain;f=popproxy.c;h=070738fa2e510fef8e504733acf3209111a28fd9;hp=03cc6d79bb9e0f97317a51f7cf5dd764e20a41a7;hb=442dc01c2b410071ff214a22f31adb25a62890b2;hpb=043ca84c41983eb4bb55ebef2cf6e94695dfd437 diff --git a/popproxy.c b/popproxy.c index 03cc6d7..070738f 100644 --- a/popproxy.c +++ b/popproxy.c @@ -45,6 +45,7 @@ server_conn_new (char *server, char *port) int fd; HCConn *conn; HCConn *ssl_conn; + int r; fd = hc_tcp_connect (server, port); if (fd < 0) { @@ -53,8 +54,21 @@ server_conn_new (char *server, char *port) } conn = hc_conn_new (NULL, NULL); ssl_conn = hc_conn_new (NULL, NULL); - hc_conn_set_driver_channel (conn, fd); - hc_conn_set_driver_ssl_client (ssl_conn, conn); + r = hc_conn_set_driver_channel (conn, fd); + if (r != 0) + { + hc_conn_close (ssl_conn); + hc_conn_close (conn); + close (fd); + return NULL; + } + r = hc_conn_set_driver_ssl_client (ssl_conn, conn); + if (r != 0) + { + hc_conn_close (ssl_conn); + hc_conn_close (conn); + return NULL; + } return ssl_conn; } @@ -83,6 +97,7 @@ new_client (int fd, struct sockaddr *addr, socklen_t saddr, gpointer data) HCConn *pop_conn; HCConn *server_conn; struct pop_address *address = data; + int r; if (fd < 0) { g_critical ("Server has received an error event."); @@ -98,10 +113,23 @@ new_client (int fd, struct sockaddr *addr, socklen_t saddr, gpointer data) } conn = hc_conn_new (NULL, NULL); - hc_conn_set_driver_channel (conn, fd); + r = hc_conn_set_driver_channel (conn, fd); + if (r != 0) + { + hc_conn_close (server_conn); + hc_conn_close (conn); + close (fd); + return; + } pop_conn = hc_conn_new (NULL, NULL); - hc_conn_set_driver_pop (pop_conn, conn); - + r = hc_conn_set_driver_pop (pop_conn, conn); + if (r != 0) + { + hc_conn_close (server_conn); + hc_conn_close (pop_conn); + hc_conn_close (conn); + return; + } hc_conn_set_callback (pop_conn, push_other, server_conn); hc_conn_set_callback (server_conn, push_other, pop_conn);