Ticket #678: fd_leak_asf_http.patch
| File fd_leak_asf_http.patch, 6.7 KB (added by , 20 years ago) |
|---|
-
stream/network.c
238 238 ret = send( fd, http_hdr->buffer, http_hdr->buffer_size, 0 ); 239 239 if( ret!=(int)http_hdr->buffer_size ) { 240 240 mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_NW_ErrSendingHTTPRequest); 241 closesocket( fd ); 241 242 goto err_out; 242 243 } 243 244 -
stream/asf_mmst_streaming.c
626 626 627 627 asf_header_len = get_header (s, asf_header, stream->streaming_ctrl); 628 628 // mp_msg(MSGT_NETWORK,MSGL_INFO,"---------------------------------- asf_header %d\n",asf_header); 629 if (asf_header_len==0) return -1; //error reading header 629 if (asf_header_len==0) { 630 //error reading header 631 closesocket (s); 632 return -1; 633 } 630 634 packet_length = interp_header (asf_header, asf_header_len); 631 635 632 636 -
stream/asf_streaming.c
746 746 if(r <0) { 747 747 mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_SocketWriteError,strerror(errno)); 748 748 http_free( http_hdr ); 749 closesocket( fd ); 749 750 return -1; 750 751 } 751 752 i += r; … … 758 759 if( i<=0 ) { 759 760 perror("read"); 760 761 http_free( http_hdr ); 762 closesocket( fd ); 761 763 return -1; 762 764 } 763 765 http_response_append( http_hdr, buffer, i ); … … 770 772 if( ret<0 ) { 771 773 mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_HeaderParseFailed); 772 774 http_free( http_hdr ); 775 closesocket( fd ); 773 776 return -1; 774 777 } 775 778 switch( asf_http_ctrl->streaming_type ) { … … 779 782 if( http_hdr->body_size>0 ) { 780 783 if( streaming_bufferize( stream->streaming_ctrl, http_hdr->body, http_hdr->body_size )<0 ) { 781 784 http_free( http_hdr ); 785 closesocket( fd ); 782 786 return -1; 783 787 } 784 788 } … … 786 790 if( asf_http_ctrl->streaming_type!=ASF_PlainText_e ) { 787 791 // First request, we only got the ASF header. 788 792 ret = asf_streaming_parse_header(fd,stream->streaming_ctrl); 789 if(ret < 0) return -1; 793 if( ret < 0 ) { 794 http_free( http_hdr ); 795 closesocket( fd ); 796 return -1; 797 } 790 798 if(asf_http_ctrl->n_audio == 0 && asf_http_ctrl->n_video == 0) { 791 799 mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_NoStreamFound); 800 http_free( http_hdr ); 801 closesocket( fd ); 792 802 return -1; 793 803 } 794 804 asf_http_ctrl->request++; … … 802 812 if( http_hdr->body_size>0 ) { 803 813 if( streaming_bufferize( stream->streaming_ctrl, http_hdr->body, http_hdr->body_size )<0 ) { 804 814 http_free( http_hdr ); 815 closesocket( fd ); 805 816 return -1; 806 817 } 807 818 } … … 816 827 case ASF_Unknown_e: 817 828 default: 818 829 mp_msg(MSGT_NETWORK,MSGL_ERR,MSGTR_MPDEMUX_ASF_UnknownASFStreamingType); 819 closesocket(fd);820 830 http_free( http_hdr ); 831 closesocket( fd ); 821 832 return -1; 822 833 } 823 834 // Check if we got a redirect. -
stream/http.c
742 742 return -1; 743 743 } 744 744 745 stream->fd=fd;746 745 if( mp_msg_test(MSGT_NETWORK,MSGL_V) ) { 747 746 http_debug_hdr( http_hdr ); 748 747 } 749 750 stream->streaming_ctrl->data = (void*)http_hdr;751 748 752 749 // Check if we can make partial content requests and thus seek in http-streams 753 750 if( http_hdr!=NULL && http_hdr->status_code==200 ) { … … 761 758 switch( http_hdr->status_code ) { 762 759 case 200: { // OK 763 760 char *field_data = NULL; 761 stream->fd = fd; 762 stream->streaming_ctrl->data = (void*)http_hdr; 764 763 // note: I skip icy-notice1 and 2, as they contain html <BR> 765 764 // and are IMHO useless info ::atmos 766 765 if( (field_data = http_get_field(http_hdr, "icy-name")) != NULL ) … … 788 787 } 789 788 case 400: // Server Full 790 789 mp_msg(MSGT_NETWORK,MSGL_ERR,"Error: ICY-Server is full, skipping!\n"); 790 http_free(http_hdr); 791 closesocket(fd); 791 792 return -1; 792 793 case 401: // Service Unavailable 793 794 mp_msg(MSGT_NETWORK,MSGL_ERR,"Error: ICY-Server return service unavailable, skipping!\n"); 795 http_free(http_hdr); 796 closesocket(fd); 794 797 return -1; 795 798 case 403: // Service Forbidden 796 799 mp_msg(MSGT_NETWORK,MSGL_ERR,"Error: ICY-Server return 'Service Forbidden'\n"); 800 http_free(http_hdr); 801 closesocket(fd); 797 802 return -1; 798 803 case 404: // Resource Not Found 799 804 mp_msg(MSGT_NETWORK,MSGL_ERR,"Error: ICY-Server couldn't find requested stream, skipping!\n"); 805 http_free(http_hdr); 806 closesocket(fd); 800 807 return -1; 801 808 default: 802 809 mp_msg(MSGT_NETWORK,MSGL_ERR,"Error: unhandled ICY-Errorcode, contact MPlayer developers!\n"); 810 http_free(http_hdr); 811 closesocket(fd); 803 812 return -1; 804 813 } 805 814 } … … 807 816 // Assume standard http if not ICY 808 817 switch( http_hdr->status_code ) { 809 818 case 200: // OK 819 stream->fd = fd; 820 stream->streaming_ctrl->data = (void*)http_hdr; 810 821 // Look if we can use the Content-Type 811 822 content_type = http_get_field( http_hdr, "Content-Type" ); 812 823 if( content_type!=NULL ) { … … 834 845 // TODO: RFC 2616, recommand to detect infinite redirection loops 835 846 next_url = http_get_field( http_hdr, "Location" ); 836 847 if( next_url!=NULL ) { 837 closesocket( fd );838 848 stream->streaming_ctrl->url = url_redirect( &url, next_url ); 839 http_free( http_hdr );840 849 redirect = 1; 841 850 } 842 851 break; 843 852 case 401: // Authentication required 844 if( http_authenticate(http_hdr, url, &auth_retry)<0 ) return STREAM_UNSUPORTED; 853 if( http_authenticate(http_hdr, url, &auth_retry)<0 ) { 854 http_free(http_hdr); 855 closesocket(fd); 856 return STREAM_UNSUPORTED; 857 } 845 858 redirect = 1; 846 859 break; 847 860 default: 848 861 mp_msg(MSGT_NETWORK,MSGL_ERR,"Server returned %d: %s\n", http_hdr->status_code, http_hdr->reason_phrase ); 862 http_free(http_hdr); 863 closesocket(fd); 849 864 return -1; 850 865 } 866 http_free(http_hdr); 867 closesocket(fd); 851 868 } while( redirect ); 852 869 853 870 return -1; … … 870 887 mp_msg(MSGT_NETWORK,MSGL_ERR,"nop_streaming_start failed\n"); 871 888 streaming_ctrl_free(stream->streaming_ctrl); 872 889 stream->streaming_ctrl = NULL; 890 closesocket(stream->fd); 891 stream->fd = -1; 873 892 return STREAM_UNSUPORTED; 874 893 } 875 894 … … 895 914 if((seekable < 0) || (*file_format == DEMUXER_TYPE_ASF)) { 896 915 streaming_ctrl_free(stream->streaming_ctrl); 897 916 stream->streaming_ctrl = NULL; 917 if (stream->fd >= 0) { 918 closesocket(stream->fd); 919 stream->fd = -1; 920 } 898 921 return STREAM_UNSUPORTED; 899 922 } 900 923
