diff options
Diffstat (limited to 'src/examples/mhd2spdy_spdy.c')
-rw-r--r-- | src/examples/mhd2spdy_spdy.c | 77 |
1 files changed, 47 insertions, 30 deletions
diff --git a/src/examples/mhd2spdy_spdy.c b/src/examples/mhd2spdy_spdy.c index 2bc87976..41c45317 100644 --- a/src/examples/mhd2spdy_spdy.c +++ b/src/examples/mhd2spdy_spdy.c | |||
@@ -370,14 +370,19 @@ spdy_cb_on_stream_close(spdylay_session *session, | |||
370 | 370 | ||
371 | --glob_opt.streams_opened; | 371 | --glob_opt.streams_opened; |
372 | --proxy->spdy_connection->streams_opened; | 372 | --proxy->spdy_connection->streams_opened; |
373 | PRINT_INFO2("closing stream: str opened %i", glob_opt.streams_opened); | 373 | PRINT_INFO2("closing stream: str opened %i; remove proxy %i", glob_opt.streams_opened, proxy->id); |
374 | 374 | ||
375 | DLL_remove(proxy->spdy_connection->proxies_head, proxy->spdy_connection->proxies_tail, proxy); | ||
376 | |||
377 | if(proxy->http_active) | 375 | if(proxy->http_active) |
376 | { | ||
378 | proxy->spdy_active = false; | 377 | proxy->spdy_active = false; |
378 | //DLL_remove(proxy->spdy_connection->proxies_head, proxy->spdy_connection->proxies_tail, proxy); | ||
379 | } | ||
379 | else | 380 | else |
380 | free_proxy(proxy); | 381 | { |
382 | PRINT_INFO2("proxy free close id %i ", proxy->id); | ||
383 | //DLL_remove(proxy->spdy_connection->proxies_head, proxy->spdy_connection->proxies_tail, proxy); | ||
384 | //free_proxy(proxy); | ||
385 | } | ||
381 | } | 386 | } |
382 | 387 | ||
383 | 388 | ||
@@ -615,6 +620,7 @@ spdy_socket_set_tcp_nodelay(int fd) | |||
615 | /* | 620 | /* |
616 | * Update |pollfd| based on the state of |connection|. | 621 | * Update |pollfd| based on the state of |connection|. |
617 | */ | 622 | */ |
623 | /* | ||
618 | void | 624 | void |
619 | spdy_ctl_poll(struct pollfd *pollfd, | 625 | spdy_ctl_poll(struct pollfd *pollfd, |
620 | struct SPDY_Connection *connection) | 626 | struct SPDY_Connection *connection) |
@@ -630,7 +636,7 @@ spdy_ctl_poll(struct pollfd *pollfd, | |||
630 | { | 636 | { |
631 | pollfd->events |= POLLOUT; | 637 | pollfd->events |= POLLOUT; |
632 | } | 638 | } |
633 | } | 639 | }*/ |
634 | 640 | ||
635 | 641 | ||
636 | /* | 642 | /* |
@@ -766,12 +772,26 @@ spdy_connect(const struct URI *uri, | |||
766 | void | 772 | void |
767 | spdy_free_connection(struct SPDY_Connection * connection) | 773 | spdy_free_connection(struct SPDY_Connection * connection) |
768 | { | 774 | { |
775 | struct Proxy *proxy; | ||
776 | |||
769 | if(NULL != connection) | 777 | if(NULL != connection) |
770 | { | 778 | { |
779 | for(proxy = connection->proxies_head; NULL != proxy; proxy=proxy->next) | ||
780 | { | ||
781 | DLL_remove(connection->proxies_head, connection->proxies_tail, proxy); | ||
782 | proxy->spdy_active = false; | ||
783 | proxy->spdy_error = true; | ||
784 | PRINT_INFO2("spdy_free_connection for id %i", proxy->id); | ||
785 | if(!proxy->http_active) | ||
786 | { | ||
787 | //free_proxy(proxy); | ||
788 | } | ||
789 | } | ||
771 | spdylay_session_del(connection->session); | 790 | spdylay_session_del(connection->session); |
772 | SSL_free(connection->ssl); | 791 | SSL_free(connection->ssl); |
773 | free(connection->host); | 792 | free(connection->host); |
774 | free(connection); | 793 | //free(connection); |
794 | connection->session = NULL; | ||
775 | } | 795 | } |
776 | } | 796 | } |
777 | 797 | ||
@@ -835,12 +855,15 @@ spdy_request(const char **nv, | |||
835 | if(ret != 0) { | 855 | if(ret != 0) { |
836 | spdy_diec("spdylay_spdy_submit_request", ret); | 856 | spdy_diec("spdylay_spdy_submit_request", ret); |
837 | } | 857 | } |
858 | PRINT_INFO2("adding proxy %i", proxy->id); | ||
859 | if(NULL != connection->proxies_head) | ||
860 | PRINT_INFO2("before proxy %i", connection->proxies_head->id); | ||
838 | DLL_insert(connection->proxies_head, connection->proxies_tail, proxy); | 861 | DLL_insert(connection->proxies_head, connection->proxies_tail, proxy); |
839 | 862 | ||
840 | return ret; | 863 | return ret; |
841 | } | 864 | } |
842 | 865 | ||
843 | 866 | /* | |
844 | void | 867 | void |
845 | spdy_get_pollfdset(struct pollfd fds[], | 868 | spdy_get_pollfdset(struct pollfd fds[], |
846 | struct SPDY_Connection *connections[], | 869 | struct SPDY_Connection *connections[], |
@@ -864,6 +887,7 @@ spdy_get_pollfdset(struct pollfd fds[], | |||
864 | 887 | ||
865 | for(proxy = glob_opt.spdy_connection->proxies_head; NULL != proxy; proxy=proxy->next) | 888 | for(proxy = glob_opt.spdy_connection->proxies_head; NULL != proxy; proxy=proxy->next) |
866 | { | 889 | { |
890 | abort(); | ||
867 | DLL_remove(glob_opt.spdy_connection->proxies_head, glob_opt.spdy_connection->proxies_tail, proxy); | 891 | DLL_remove(glob_opt.spdy_connection->proxies_head, glob_opt.spdy_connection->proxies_tail, proxy); |
868 | proxy->spdy_active = false; | 892 | proxy->spdy_active = false; |
869 | } | 893 | } |
@@ -893,6 +917,7 @@ spdy_get_pollfdset(struct pollfd fds[], | |||
893 | 917 | ||
894 | for(proxy = connection->proxies_head; NULL != proxy; proxy=proxy->next) | 918 | for(proxy = connection->proxies_head; NULL != proxy; proxy=proxy->next) |
895 | { | 919 | { |
920 | abort(); | ||
896 | DLL_remove(connection->proxies_head, connection->proxies_tail, proxy); | 921 | DLL_remove(connection->proxies_head, connection->proxies_tail, proxy); |
897 | proxy->spdy_active = false; | 922 | proxy->spdy_active = false; |
898 | } | 923 | } |
@@ -910,7 +935,7 @@ spdy_get_pollfdset(struct pollfd fds[], | |||
910 | //, "TODO max num of conn reached; close something" | 935 | //, "TODO max num of conn reached; close something" |
911 | assert(NULL == connection); | 936 | assert(NULL == connection); |
912 | } | 937 | } |
913 | 938 | */ | |
914 | 939 | ||
915 | int | 940 | int |
916 | spdy_get_selectfdset(fd_set * read_fd_set, | 941 | spdy_get_selectfdset(fd_set * read_fd_set, |
@@ -921,7 +946,7 @@ spdy_get_selectfdset(fd_set * read_fd_set, | |||
921 | nfds_t *real_size) | 946 | nfds_t *real_size) |
922 | { | 947 | { |
923 | struct SPDY_Connection *connection; | 948 | struct SPDY_Connection *connection; |
924 | struct Proxy *proxy; | 949 | struct SPDY_Connection *next_connection; |
925 | bool ret; | 950 | bool ret; |
926 | int maxfd = 0; | 951 | int maxfd = 0; |
927 | 952 | ||
@@ -936,14 +961,9 @@ spdy_get_selectfdset(fd_set * read_fd_set, | |||
936 | except_fd_set, glob_opt.spdy_connection); | 961 | except_fd_set, glob_opt.spdy_connection); |
937 | if(!ret) | 962 | if(!ret) |
938 | { | 963 | { |
939 | //PRINT_INFO("TODO drop connection"); | ||
940 | glob_opt.streams_opened -= glob_opt.spdy_connection->streams_opened; | 964 | glob_opt.streams_opened -= glob_opt.spdy_connection->streams_opened; |
941 | 965 | ||
942 | for(proxy = glob_opt.spdy_connection->proxies_head; NULL != proxy; proxy=proxy->next) | 966 | PRINT_INFO("spdy_free_connection in spdy_get_selectfdset"); |
943 | { | ||
944 | DLL_remove(glob_opt.spdy_connection->proxies_head, glob_opt.spdy_connection->proxies_tail, proxy); | ||
945 | proxy->spdy_active = false; | ||
946 | } | ||
947 | spdy_free_connection(glob_opt.spdy_connection); | 967 | spdy_free_connection(glob_opt.spdy_connection); |
948 | glob_opt.spdy_connection = NULL; | 968 | glob_opt.spdy_connection = NULL; |
949 | } | 969 | } |
@@ -963,18 +983,15 @@ spdy_get_selectfdset(fd_set * read_fd_set, | |||
963 | ret = spdy_ctl_select(read_fd_set, | 983 | ret = spdy_ctl_select(read_fd_set, |
964 | write_fd_set, | 984 | write_fd_set, |
965 | except_fd_set, connection); | 985 | except_fd_set, connection); |
986 | |||
987 | next_connection = connection->next; | ||
966 | if(!ret) | 988 | if(!ret) |
967 | { | 989 | { |
968 | //PRINT_INFO("TODO drop connection"); | ||
969 | glob_opt.streams_opened -= connection->streams_opened; | 990 | glob_opt.streams_opened -= connection->streams_opened; |
970 | DLL_remove(glob_opt.spdy_connections_head, glob_opt.spdy_connections_tail, connection); | 991 | DLL_remove(glob_opt.spdy_connections_head, glob_opt.spdy_connections_tail, connection); |
971 | glob_opt.total_spdy_connections--; | 992 | glob_opt.total_spdy_connections--; |
972 | 993 | ||
973 | for(proxy = connection->proxies_head; NULL != proxy; proxy=proxy->next) | 994 | PRINT_INFO("spdy_free_connection in spdy_get_selectfdset"); |
974 | { | ||
975 | DLL_remove(connection->proxies_head, connection->proxies_tail, proxy); | ||
976 | proxy->spdy_active = false; | ||
977 | } | ||
978 | spdy_free_connection(connection); | 995 | spdy_free_connection(connection); |
979 | } | 996 | } |
980 | else | 997 | else |
@@ -983,7 +1000,7 @@ spdy_get_selectfdset(fd_set * read_fd_set, | |||
983 | ++(*real_size); | 1000 | ++(*real_size); |
984 | if(maxfd < connection->fd) maxfd = connection->fd; | 1001 | if(maxfd < connection->fd) maxfd = connection->fd; |
985 | } | 1002 | } |
986 | connection = connection->next; | 1003 | connection = next_connection; |
987 | } | 1004 | } |
988 | 1005 | ||
989 | //, "TODO max num of conn reached; close something" | 1006 | //, "TODO max num of conn reached; close something" |
@@ -992,7 +1009,7 @@ spdy_get_selectfdset(fd_set * read_fd_set, | |||
992 | return maxfd; | 1009 | return maxfd; |
993 | } | 1010 | } |
994 | 1011 | ||
995 | 1012 | /* | |
996 | void | 1013 | void |
997 | spdy_run(struct pollfd fds[], | 1014 | spdy_run(struct pollfd fds[], |
998 | struct SPDY_Connection *connections[], | 1015 | struct SPDY_Connection *connections[], |
@@ -1029,9 +1046,13 @@ spdy_run(struct pollfd fds[], | |||
1029 | } | 1046 | } |
1030 | for(proxy = connections[i]->proxies_head; NULL != proxy; proxy=proxy->next) | 1047 | for(proxy = connections[i]->proxies_head; NULL != proxy; proxy=proxy->next) |
1031 | { | 1048 | { |
1049 | abort(); | ||
1032 | DLL_remove(connections[i]->proxies_head, connections[i]->proxies_tail, proxy); | 1050 | DLL_remove(connections[i]->proxies_head, connections[i]->proxies_tail, proxy); |
1033 | proxy->spdy_active = false; | 1051 | proxy->spdy_active = false; |
1052 | proxy->spdy_error = true; | ||
1053 | PRINT_INFO2("spdy_free_connection for id %i", proxy->id); | ||
1034 | } | 1054 | } |
1055 | PRINT_INFO("spdy_free_connection in loop"); | ||
1035 | spdy_free_connection(connections[i]); | 1056 | spdy_free_connection(connections[i]); |
1036 | } | 1057 | } |
1037 | } | 1058 | } |
@@ -1039,6 +1060,7 @@ spdy_run(struct pollfd fds[], | |||
1039 | PRINT_INFO("not called"); | 1060 | PRINT_INFO("not called"); |
1040 | } | 1061 | } |
1041 | } | 1062 | } |
1063 | */ | ||
1042 | 1064 | ||
1043 | void | 1065 | void |
1044 | spdy_run_select(fd_set * read_fd_set, | 1066 | spdy_run_select(fd_set * read_fd_set, |
@@ -1049,7 +1071,6 @@ spdy_run_select(fd_set * read_fd_set, | |||
1049 | { | 1071 | { |
1050 | int i; | 1072 | int i; |
1051 | int ret; | 1073 | int ret; |
1052 | struct Proxy *proxy; | ||
1053 | 1074 | ||
1054 | for(i=0; i<size; ++i) | 1075 | for(i=0; i<size; ++i) |
1055 | { | 1076 | { |
@@ -1071,11 +1092,7 @@ spdy_run_select(fd_set * read_fd_set, | |||
1071 | DLL_remove(glob_opt.spdy_connections_head, glob_opt.spdy_connections_tail, connections[i]); | 1092 | DLL_remove(glob_opt.spdy_connections_head, glob_opt.spdy_connections_tail, connections[i]); |
1072 | glob_opt.total_spdy_connections--; | 1093 | glob_opt.total_spdy_connections--; |
1073 | } | 1094 | } |
1074 | for(proxy = connections[i]->proxies_head; NULL != proxy; proxy=proxy->next) | 1095 | PRINT_INFO("in spdy_run_select"); |
1075 | { | ||
1076 | DLL_remove(connections[i]->proxies_head, connections[i]->proxies_tail, proxy); | ||
1077 | proxy->spdy_active = false; | ||
1078 | } | ||
1079 | spdy_free_connection(connections[i]); | 1096 | spdy_free_connection(connections[i]); |
1080 | } | 1097 | } |
1081 | } | 1098 | } |