Changeset 21f7e7ea477453871b494758c2dec31e0c23287c

Show
Ignore:
Timestamp:
03/28/08 10:54:55 (5 months ago)
Author:
Jean-Paul Saman <jpsaman@videolan.org>
git-committer:
Jean-Paul Saman <jpsaman@videolan.org> 1206698095 +0100
git-parent:

[d0641277d87a51ed1602dc36f5585c9b4705dccb]

git-author:
Rafaël Carré <funman@videolan.org> 1206697525 +0100
Message:

MMS: close access on network timeout

defaults to timeout on 5s (configurable) without data (there will be 10 tries before returning EOF)
fix some EOF return paths
check malloc()

Signed-off-by: Jean-Paul Saman <jpsaman@videolan.org>

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/access/mms/mms.c

    r99fab90 r21f7e7e  
    6666    "if empty, the http_proxy environment variable will be tried." ) 
    6767 
     68#define TIMEOUT_TEXT N_("TCP/UDP timeout (ms)") 
     69#define TIMEOUT_LONGTEXT N_("Amount of time (in ms) to wait before aborting network reception of data. Note that there will be 10 retries before completely giving up.") 
     70 
    6871vlc_module_begin(); 
    6972    set_shortname( "MMS" ); 
     
    7578    add_integer( "mms-caching", 19 * DEFAULT_PTS_DELAY / 1000, NULL, 
    7679                 CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE ); 
     80 
     81    add_integer( "mms-timeout", 5000, NULL, TIMEOUT_TEXT, TIMEOUT_LONGTEXT, 
     82                 VLC_TRUE ); 
    7783 
    7884    add_bool( "mms-all", 0, NULL, ALL_TEXT, ALL_LONGTEXT, VLC_TRUE ); 
  • modules/access/mms/mmstu.c

    r5cb4066 r21f7e7e  
    112112    p_access->info.i_seekpoint = 0; 
    113113    p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) ); 
     114    if( !p_sys ) return VLC_ENOMEM; 
    114115    memset( p_sys, 0, sizeof( access_sys_t ) ); 
     116 
     117    p_sys->i_timeout = var_CreateGetInteger( p_access, "mms-timeout" ); 
    115118 
    116119    /* *** Parse URL and get server addr/port and path *** */ 
     
    346349    while( !p_access->b_die ) 
    347350    { 
    348         mms_HeaderMediaRead( p_access, MMS_PACKET_CMD ); 
     351        if( mms_HeaderMediaRead( p_access, MMS_PACKET_CMD ) < 0 ) 
     352        { 
     353            p_access->info.b_eof = VLC_TRUE; 
     354            return VLC_EGENERIC; 
     355        } 
     356 
    349357        if( p_sys->i_command == 0x1e ) 
    350358        { 
     
    356364    while( !p_access->b_die ) 
    357365    { 
    358         mms_HeaderMediaRead( p_access, MMS_PACKET_CMD ); 
     366        if( mms_HeaderMediaRead( p_access, MMS_PACKET_CMD ) < 0 ) 
     367        { 
     368            p_access->info.b_eof = VLC_TRUE; 
     369            return VLC_EGENERIC; 
     370        } 
    359371        if( p_sys->i_command == 0x05 ) 
    360372        { 
     
    365377 
    366378    /* get a packet */ 
    367     mms_HeaderMediaRead( p_access, MMS_PACKET_MEDIA ); 
     379    if( mms_HeaderMediaRead( p_access, MMS_PACKET_MEDIA ) < 0 ) 
     380    { 
     381        p_access->info.b_eof = VLC_TRUE; 
     382        return VLC_EGENERIC; 
     383    } 
     384 
    368385    msg_Dbg( p_access, "Streaming restarted" ); 
    369386 
     
    387404 
    388405    /* *** now send data if needed *** */ 
    389     while( i_data < (size_t)i_len ) 
     406    while( i_data < i_len ) 
    390407    { 
    391408        if( p_access->info.i_pos < p_sys->i_header ) 
     
    504521    p_sys->p_cmd = NULL; 
    505522    p_sys->i_cmd = 0; 
    506     p_access->info.b_eof = 0
     523    p_access->info.b_eof = VLC_FALSE
    507524 
    508525    /* *** send command 1 : connection request *** */ 
     
    853870                 "unknown answer (0x%x instead of 0x05)", 
    854871                 p_sys->i_command ); 
    855         return( -1 )
     872        return -1
    856873    } 
    857874    else 
    858875    { 
    859876        /* get a packet */ 
    860         mms_HeaderMediaRead( p_access, MMS_PACKET_MEDIA ); 
     877        if( mms_HeaderMediaRead( p_access, MMS_PACKET_MEDIA ) < 0 ) 
     878            return -1; 
    861879        msg_Dbg( p_access, "streaming started" ); 
    862         return( 0 )
     880        return 0
    863881    } 
    864882} 
     
    10291047        /* We'll wait 0.5 second if nothing happens */ 
    10301048        timeout = 500; 
     1049 
     1050        if( i_try * timeout > p_sys->i_timeout ) 
     1051        { 
     1052            msg_Err(p_access, "no data received"); 
     1053            return -1; 
     1054        } 
    10311055 
    10321056        if( i_try > 3 && (p_sys->i_buffer_tcp > 0 || p_sys->i_buffer_udp > 0) ) 
     
    14441468                case 0x03: 
    14451469                    msg_Warn( p_access, "socket closed by server" ); 
    1446                     p_access->info.b_eof = 1
     1470                    p_access->info.b_eof = VLC_TRUE
    14471471                    return VLC_EGENERIC; 
    14481472                case 0x1e: 
    14491473                    msg_Warn( p_access, "end of media stream" ); 
    1450                     p_access->info.b_eof = 1
     1474                    p_access->info.b_eof = VLC_TRUE
    14511475                    return VLC_EGENERIC; 
    14521476                default: 
     
    14551479        } 
    14561480    } 
     1481    p_access->info.b_eof = VLC_TRUE; 
    14571482    msg_Warn( p_access, "failed to receive command (aborting)" ); 
    14581483 
     
    14911516                case 0x03: 
    14921517                    msg_Warn( p_access, "socket closed by server" ); 
    1493                     p_access->info.b_eof = 1
     1518                    p_access->info.b_eof = VLC_TRUE
    14941519                    return -1; 
    14951520                case 0x1e: 
    14961521                    msg_Warn( p_access, "end of media stream" ); 
    1497                     p_access->info.b_eof = 1
     1522                    p_access->info.b_eof = VLC_TRUE
    14981523                    return -1; 
    14991524                case 0x20: 
     
    15131538    msg_Err( p_access, "cannot receive %s (aborting)", 
    15141539             ( i_type == MMS_PACKET_HEADER ) ? "header" : "media data" ); 
     1540    p_access->info.b_eof = VLC_TRUE; 
    15151541    return -1; 
    15161542} 
  • modules/access/mms/mmstu.h

    r29ec304 r21f7e7e  
    4545 
    4646    asf_header_t    asfh; 
     47 
     48    unsigned    i_timeout; 
    4749 
    4850    /* */