aboutsummaryrefslogtreecommitdiff
path: root/src/examples/mhd2spdy_spdy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/examples/mhd2spdy_spdy.c')
-rw-r--r--src/examples/mhd2spdy_spdy.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/src/examples/mhd2spdy_spdy.c b/src/examples/mhd2spdy_spdy.c
index 2630df6d..95ec43c8 100644
--- a/src/examples/mhd2spdy_spdy.c
+++ b/src/examples/mhd2spdy_spdy.c
@@ -727,7 +727,7 @@ spdy_connect(const struct URI *uri,
727 spdylay_session_callbacks callbacks; 727 spdylay_session_callbacks callbacks;
728 int fd; 728 int fd;
729 SSL *ssl=NULL; 729 SSL *ssl=NULL;
730 struct SPDY_Connection * connection; 730 struct SPDY_Connection * connection = NULL;
731 int rv; 731 int rv;
732 732
733 spdy_setup_spdylay_callbacks(&callbacks); 733 spdy_setup_spdylay_callbacks(&callbacks);
@@ -757,11 +757,7 @@ spdy_connect(const struct URI *uri,
757 { 757 {
758 PRINT_INFO("Closing SSL"); 758 PRINT_INFO("Closing SSL");
759 //no spdy on the other side 759 //no spdy on the other side
760 SSL_shutdown(ssl); 760 goto free_and_fail;
761 close(fd);
762 SSL_free(ssl);
763
764 return NULL;
765 } 761 }
766 } 762 }
767 else 763 else
@@ -770,12 +766,13 @@ spdy_connect(const struct URI *uri,
770 } 766 }
771 767
772 if(NULL == (connection = au_malloc(sizeof(struct SPDY_Connection)))) 768 if(NULL == (connection = au_malloc(sizeof(struct SPDY_Connection))))
773 return NULL; 769 goto free_and_fail;
774 770
775 connection->is_tls = is_tls; 771 connection->is_tls = is_tls;
776 connection->ssl = ssl; 772 connection->ssl = ssl;
777 connection->want_io = IO_NONE; 773 connection->want_io = IO_NONE;
778 connection->host = strdup(uri->host); 774 if(NULL == (connection->host = strdup(uri->host)))
775 goto free_and_fail;
779 776
780 /* Here make file descriptor non-block */ 777 /* Here make file descriptor non-block */
781 spdy_socket_make_non_block(fd); 778 spdy_socket_make_non_block(fd);
@@ -791,6 +788,24 @@ spdy_connect(const struct URI *uri,
791 connection->fd = fd; 788 connection->fd = fd;
792 789
793 return connection; 790 return connection;
791
792 //for GOTO
793 free_and_fail:
794 if(NULL != connection)
795 {
796 free(connection->host);
797 free(connection);
798 }
799
800 if(is_tls)
801 SSL_shutdown(ssl);
802
803 close(fd);
804
805 if(is_tls)
806 SSL_free(ssl);
807
808 return NULL;
794} 809}
795 810
796 811