~ubuntu-branches/ubuntu/maverick/transmission/maverick-updates

« back to all changes in this revision

Viewing changes to libtransmission/fdlimit.c

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson, Krzysztof Klimonda, Chris Coulson
  • Date: 2009-09-09 09:06:11 UTC
  • mfrom: (1.1.27 upstream)
  • Revision ID: james.westby@ubuntu.com-20090909090611-09ai2hyo66h1dhv8
Tags: 1.74-0ubuntu1
[ Krzysztof Klimonda ]
* Merge from debian unstable, remaining changes:
  - debian/control:
    + Added replaces & provides clutch (now included as part of transmission).
    + add liblaunchpad-integration to Build-Depends
  - debian/rules:
    + Create a PO template during package build.
  - debian/patches/01_lpi.patch:
    + Integrate Transmission with Launchpad
  - debian/patches/20_add_X-Ubuntu-Gettext-Domain.diff:
    + Add X-Ubuntu-Gettext-Domain to .desktop file.
* debian/control:
  - add lsb-release to Build-Depends
* This includes the QT client in transmission-qt.

[ Chris Coulson ]
* Update to new upstream version 1.74 (LP: #418367):
  - Better data recovery in the case of an OS or Transmission crash
  - If a data file is moved, stop the torrent instead of redownloading 
    it (LP: #419304).
  - Fix bug that didn't list some peers in the resume file and in PEX
  - More helpful torrent error messages
  - DHT now honors the bind-address-ipv4 configuration option
  - Fix Debian build error with miniupnpc
  - Fix Cygwin build error with strtold
  - Update to a newer snapshot of miniupnpc
  - Fix crash that occurred when adding torrents on some desktops
  - Synchronize the statusbar's and torrent list's speeds
  - Fix the Properties dialog's "Origin" field for multiple torrents
* debian/rules, debian/control:
  - Don't run autoreconf at build time and don't build-dep on libtool.
* debian/control:
  - transmission-common replaces transmission-gtk (<< 1.74) rather than
    (<= 1.73-1).
* Refreshed patches:
  - 01_lpi.patch.
  - dont_build_libevent.patch.
  - qt_client_use_system_libevent.patch.
* Dropped patches not needed anymore:
  - updateminiupnpcstrings_double_escape_slash.patch
* Added 99_autoreconf.patch for autotools update.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 * $Id: fdlimit.c 8823 2009-07-17 17:23:03Z charles $
 
2
 * $Id: fdlimit.c 8960 2009-08-17 18:49:21Z jhujhiti $
3
3
 *
4
4
 * Copyright (c) 2005-2008 Transmission authors and contributors
5
5
 *
181
181
 
182
182
        if( !success ) /* if nothing else works, do it the old-fashioned way */
183
183
        {
184
 
            uint8_t buf[ 4096 ]; 
185
 
            memset( buf, 0, sizeof( buf ) ); 
186
 
            success = TRUE; 
187
 
            while ( success && ( length > 0 ) ) 
188
 
            { 
189
 
                const int thisPass = MIN( length, sizeof( buf ) ); 
190
 
                success = write( fd, buf, thisPass ) == thisPass; 
191
 
                length -= thisPass; 
192
 
            } 
 
184
            uint8_t buf[ 4096 ];
 
185
            memset( buf, 0, sizeof( buf ) );
 
186
            success = TRUE;
 
187
            while ( success && ( length > 0 ) )
 
188
            {
 
189
                const int thisPass = MIN( length, sizeof( buf ) );
 
190
                success = write( fd, buf, thisPass ) == thisPass;
 
191
                length -= thisPass;
 
192
            }
193
193
        }
194
194
 
195
195
        close( fd );
316
316
    if( doWrite && !alreadyExisted && ( preallocationMode == TR_PREALLOCATE_FULL ) )
317
317
        if( preallocateFileFull( filename, desiredFileSize ) )
318
318
            tr_inf( _( "Preallocated file \"%s\"" ), filename );
319
 
    
 
319
 
320
320
    /* open the file */
321
321
    flags = doWrite ? ( O_RDWR | O_CREAT ) : O_RDONLY;
322
322
#ifdef O_SEQUENTIAL
446
446
        }
447
447
 
448
448
        assert( winner >= 0 );
449
 
       
 
449
 
450
450
        if( fileIsOpen( &gFd->openFiles[winner] ) )
451
451
        {
452
452
            dbgmsg( "closing file \"%s\"", gFd->openFiles[winner].filename );
478
478
}
479
479
 
480
480
void
481
 
tr_fdFileReturn( int fd )
482
 
{
483
 
    struct tr_openfile * o;
484
 
    const struct tr_openfile * end;
485
 
 
486
 
    for( o=gFd->openFiles, end=o+gFd->openFileLimit; o!=end; ++o )
487
 
    {
488
 
        if( o->fd != fd )
489
 
            continue;
490
 
        dbgmsg( "releasing file \"%s\"", o->filename );
491
 
        break;
492
 
    }
493
 
}
494
 
 
495
 
void
496
481
tr_fdFileClose( const char * filename )
497
482
{
498
483
    struct tr_openfile * o;
538
523
    if( gFd->socketCount < getSocketMax( gFd ) )
539
524
        if( ( s = socket( domain, type, 0 ) ) < 0 )
540
525
        {
541
 
#ifdef SYS_DARWIN
542
526
            if( sockerrno != EAFNOSUPPORT )
543
 
#endif
544
 
            tr_err( _( "Couldn't create socket: %s" ),
545
 
                   tr_strerror( sockerrno ) );
 
527
                tr_err( _( "Couldn't create socket: %s" ),
 
528
                        tr_strerror( sockerrno ) );
546
529
        }
547
530
 
548
531
    if( s > -1 )
576
559
 
577
560
    if( s >= 0 )
578
561
    {
579
 
        /* "The ss_family field of the sockaddr_storage structure will always 
580
 
         * align with the family field of any protocol-specific structure." */ 
581
 
        if( sock.ss_family == AF_INET ) 
 
562
        /* "The ss_family field of the sockaddr_storage structure will always
 
563
         * align with the family field of any protocol-specific structure." */
 
564
        if( sock.ss_family == AF_INET )
582
565
        {
583
566
            struct sockaddr_in *si;
584
567
            union { struct sockaddr_storage dummy; struct sockaddr_in si; } s;
585
568
            s.dummy = sock;
586
569
            si = &s.si;
587
 
            addr->type = TR_AF_INET; 
588
 
            addr->addr.addr4.s_addr = si->sin_addr.s_addr; 
589
 
            *port = si->sin_port; 
590
 
        } 
591
 
        else 
592
 
        { 
 
570
            addr->type = TR_AF_INET;
 
571
            addr->addr.addr4.s_addr = si->sin_addr.s_addr;
 
572
            *port = si->sin_port;
 
573
        }
 
574
        else
 
575
        {
593
576
            struct sockaddr_in6 *si;
594
577
            union { struct sockaddr_storage dummy; struct sockaddr_in6 si; } s;
595
578
            s.dummy = sock;
596
579
            si = &s.si;
597
 
            addr->type = TR_AF_INET6; 
 
580
            addr->type = TR_AF_INET6;
598
581
            addr->addr.addr6 = si->sin6_addr;
599
 
            *port = si->sin6_port; 
600
 
        } 
 
582
            *port = si->sin6_port;
 
583
        }
601
584
        ++gFd->socketCount;
602
585
    }
603
586