Ticket #358: ftpfs.patch

File ftpfs.patch, 2.7 KB (added by boris, 10 years ago)
  • src/vfs/ftpfs/ftpfs.c

    a b  
    989989    SUP->strict = ftpfs_use_unix_list_options ? RFC_AUTODETECT : RFC_STRICT; 
    990990    SUP->isbinary = TYPE_UNKNOWN; 
    991991    SUP->remote_is_amiga = 0; 
     992    SUP->ctl_connection_busy = 0; 
    992993    super->name = g_strdup ("/"); 
    993994    super->root = 
    994995        vfs_s_new_inode (vpath_element->class, super, 
     
    13591360    int s, j, data; 
    13601361    socklen_t fromlen = sizeof (from); 
    13611362 
     1363    /* FTP doesn't allow to open more than one file at a time */ 
     1364    if (SUP->ctl_connection_busy) 
     1365        return -1; 
     1366 
    13621367    s = ftpfs_initconn (me, super); 
    13631368    if (s == -1) 
    13641369        return -1; 
     
    13991404        close (s); 
    14001405    } 
    14011406    tty_disable_interrupt_key (); 
     1407    SUP->ctl_connection_busy = 1; 
    14021408    return data; 
    14031409} 
    14041410 
     
    17141720        { 
    17151721            me->verrno = ECONNRESET; 
    17161722            close (sock); 
     1723            SUP->ctl_connection_busy = 0; 
    17171724            tty_disable_interrupt_key (); 
    17181725            ftpfs_get_reply (me, SUP->sock, NULL, 0); 
    17191726            vfs_print_message (_("%s: failure"), me->name); 
     
    17421749    } 
    17431750 
    17441751    close (sock); 
     1752    SUP->ctl_connection_busy = 0; 
    17451753    me->verrno = E_REMOTE; 
    17461754    if ((ftpfs_get_reply (me, SUP->sock, NULL, 0) != COMPLETE)) 
    17471755        goto fallback; 
     
    18071815    if (h == -1) 
    18081816        ERRNOR (EIO, -1); 
    18091817 
    1810     sock = 
    1811         ftpfs_open_data_connection (me, super, ftp->append ? "APPE" : "STOR", name, TYPE_BINARY, 0); 
    1812     if (sock < 0 || fstat (h, &s) == -1) 
     1818    if (fstat (h, &s) == -1 || 
     1819          ((sock = ftpfs_open_data_connection (me, super, ftp->append ? "APPE" : "STOR", name, TYPE_BINARY, 0)) < 0)) 
    18131820    { 
    18141821        close (h); 
    18151822        return -1; 
     
    18631870    } 
    18641871    tty_disable_interrupt_key (); 
    18651872    close (sock); 
     1873    SUP->ctl_connection_busy = 0; 
    18661874    close (h); 
    18671875    if (ftpfs_get_reply (me, SUP->sock, NULL, 0) != COMPLETE) 
    18681876        ERRNOR (EIO, -1); 
     
    18701878  error_return: 
    18711879    tty_disable_interrupt_key (); 
    18721880    close (sock); 
     1881    SUP->ctl_connection_busy = 0; 
    18731882    close (h); 
    18741883    ftpfs_get_reply (me, SUP->sock, NULL, 0); 
    18751884    return -1; 
     
    18931902    if (FH_SOCK == -1) 
    18941903        ERRNOR (EACCES, 0); 
    18951904    fh->linear = LS_LINEAR_OPEN; 
    1896     ((ftp_super_data_t *) (FH_SUPER->data))->ctl_connection_busy = 1; 
    18971905    ((ftp_fh_data_t *) fh->data)->append = 0; 
    18981906    return 1; 
    18991907} 
     
    22082216 
    22092217        close (fh->handle); 
    22102218        fh->handle = -1; 
     2219        ftp->ctl_connection_busy = 0; 
    22112220        /* File is stored to destination already, so 
    22122221         * we prevent MEDATA->ftpfs_file_store() call from vfs_s_close () 
    22132222         */ 
     
    22162225            ERRNOR (EIO, -1); 
    22172226        vfs_s_invalidate (me, FH_SUPER); 
    22182227    } 
    2219  
    22202228    return 0; 
    22212229} 
    22222230