source: trunk/libtransmission/transmission.c @ 763

Last change on this file since 763 was 763, checked in by livings124, 16 years ago

lock torrent before accessing peers

  • Property svn:keywords set to Date Rev Author Id
File size: 21.6 KB
Line 
1/******************************************************************************
2 * $Id: transmission.c 763 2006-08-13 16:19:19Z livings124 $
3 *
4 * Copyright (c) 2005-2006 Transmission authors and contributors
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *****************************************************************************/
24
25#include "transmission.h"
26
27/***********************************************************************
28 * Local prototypes
29 **********************************************************************/
30static tr_torrent_t * torrentRealInit( tr_handle_t *, tr_torrent_t * tor,
31                                       int flags, int * error );
32static void torrentReallyStop( tr_torrent_t * );
33static void  downloadLoop( void * );
34static void  acceptLoop( void * );
35static void acceptStop( tr_handle_t * h );
36
37/***********************************************************************
38 * tr_init
39 ***********************************************************************
40 * Allocates a tr_handle_t structure and initializes a few things
41 **********************************************************************/
42tr_handle_t * tr_init()
43{
44    tr_handle_t * h;
45    int           i, r;
46
47    tr_netResolveThreadInit();
48
49    h = calloc( sizeof( tr_handle_t ), 1 );
50
51    /* Generate a peer id : "-TRxxyy-" + 12 random alphanumeric
52       characters, where xx is the major version number and yy the
53       minor version number (Azureus-style) */
54    sprintf( h->id, "-TR%02d%02d-", VERSION_MAJOR, VERSION_MINOR );
55    for( i = 8; i < 20; i++ )
56    {
57        r        = tr_rand( 36 );
58        h->id[i] = ( r < 26 ) ? ( 'a' + r ) : ( '0' + r - 26 ) ;
59    }
60
61    /* Random key */
62    for( i = 0; i < 20; i++ )
63    {
64        r         = tr_rand( 36 );
65        h->key[i] = ( r < 26 ) ? ( 'a' + r ) : ( '0' + r - 26 ) ;
66    }
67
68    /* Don't exit when writing on a broken socket */
69    signal( SIGPIPE, SIG_IGN );
70
71    /* Initialize rate and file descripts controls */
72    h->upload   = tr_rcInit();
73    h->download = tr_rcInit();
74    h->fdlimit  = tr_fdInit();
75    h->choking  = tr_chokingInit( h );
76
77    h->bindPort = -1;
78    h->bindSocket = -1;
79
80    h->acceptDie = 0;
81    tr_lockInit( &h->acceptLock );
82    tr_threadCreate( &h->acceptThread, acceptLoop, h );
83
84    return h;
85}
86
87/***********************************************************************
88 * tr_setBindPort
89 ***********************************************************************
90 *
91 **********************************************************************/
92void tr_setBindPort( tr_handle_t * h, int port )
93{
94    int sock = -1;
95    tr_torrent_t * tor;
96
97    if( h->bindPort == port )
98      return;
99
100#ifndef BEOS_NETSERVER
101    /* BeOS net_server seems to be unable to set incoming connections to
102       non-blocking. Too bad. */
103    if( !tr_fdSocketWillCreate( h->fdlimit, 0 ) )
104    {
105        /* XXX should handle failure here in a better way */
106        sock = tr_netBind( port );
107    }
108#else
109    return;
110#endif
111
112    tr_lockLock( &h->acceptLock );
113
114    h->bindPort = port;
115
116    for( tor = h->torrentList; tor; tor = tor->next )
117    {
118        tr_lockLock( &tor->lock );
119        if( NULL != tor->tracker )
120        {
121            tr_trackerChangePort( tor->tracker, port );
122        }
123        tr_lockUnlock( &tor->lock );
124    }
125
126    if( h->bindSocket > -1 )
127    {
128        tr_netClose( h->bindSocket );
129        tr_fdSocketClosed( h->fdlimit, 0 );
130    }
131
132    h->bindSocket = sock;
133
134    tr_lockUnlock( &h->acceptLock );
135}
136
137/***********************************************************************
138 * tr_setUploadLimit
139 ***********************************************************************
140 *
141 **********************************************************************/
142void tr_setUploadLimit( tr_handle_t * h, int limit )
143{
144    tr_rcSetLimit( h->upload, limit );
145    tr_chokingSetLimit( h->choking, limit );
146}
147
148/***********************************************************************
149 * tr_setDownloadLimit
150 ***********************************************************************
151 *
152 **********************************************************************/
153void tr_setDownloadLimit( tr_handle_t * h, int limit )
154{
155    tr_rcSetLimit( h->download, limit );
156}
157
158/***********************************************************************
159 * tr_torrentRates
160 ***********************************************************************
161 *
162 **********************************************************************/
163void tr_torrentRates( tr_handle_t * h, float * dl, float * ul )
164{
165    tr_torrent_t * tor;
166
167    *dl = 0.0;
168    *ul = 0.0;
169    for( tor = h->torrentList; tor; tor = tor->next )
170    {
171        tr_lockLock( &tor->lock );
172        if( tor->status & TR_STATUS_DOWNLOAD )
173            *dl += tr_rcRate( tor->download );
174        *ul += tr_rcRate( tor->upload );
175        tr_lockUnlock( &tor->lock );
176    }
177}
178
179tr_torrent_t * tr_torrentInit( tr_handle_t * h, const char * path,
180                               int flags, int * error )
181{
182    tr_torrent_t  * tor = calloc( sizeof( tr_torrent_t ), 1 );
183    int             saveCopy = ( TR_FSAVEPRIVATE & flags );
184
185    /* Parse torrent file */
186    if( tr_metainfoParse( &tor->info, path, NULL, saveCopy ) )
187    {
188        *error = TR_EINVALID;
189        free( tor );
190        return NULL;
191    }
192
193    return torrentRealInit( h, tor, flags, error );
194}
195
196tr_torrent_t * tr_torrentInitSaved( tr_handle_t * h, const char * hashStr,
197                                    int flags, int * error )
198{
199    tr_torrent_t  * tor = calloc( sizeof( tr_torrent_t ), 1 );
200
201    /* Parse torrent file */
202    if( tr_metainfoParse( &tor->info, NULL, hashStr, 0 ) )
203    {
204        *error = TR_EINVALID;
205        free( tor );
206        return NULL;
207    }
208
209    return torrentRealInit( h, tor, ( TR_FSAVEPRIVATE | flags ), error );
210}
211
212/***********************************************************************
213 * tr_torrentInit
214 ***********************************************************************
215 * Allocates a tr_torrent_t structure, then relies on tr_metainfoParse
216 * to fill it.
217 **********************************************************************/
218static tr_torrent_t * torrentRealInit( tr_handle_t * h, tr_torrent_t * tor,
219                                       int flags, int * error )
220{
221    tr_torrent_t  * tor_tmp;
222    tr_info_t     * inf;
223    int             i;
224    char          * s1, * s2;
225
226    inf        = &tor->info;
227    inf->flags = flags;
228
229    /* Make sure this torrent is not already open */
230    for( tor_tmp = h->torrentList; tor_tmp; tor_tmp = tor_tmp->next )
231    {
232        if( !memcmp( tor->info.hash, tor_tmp->info.hash,
233                     SHA_DIGEST_LENGTH ) )
234        {
235            *error = TR_EDUPLICATE;
236            free( inf->pieces );
237            free( inf->files );
238            free( tor );
239            return NULL;
240        }
241    }
242
243    tor->status = TR_STATUS_PAUSE;
244    tor->id     = h->id;
245    tor->key    = h->key;
246    tor->bindPort = &h->bindPort;
247        tor->finished = 0;
248
249
250    /* Guess scrape URL */
251    s1 = strchr( inf->trackerAnnounce, '/' );
252    while( ( s2 = strchr( s1 + 1, '/' ) ) )
253    {
254        s1 = s2;
255    }
256    s1++;
257    if( !strncmp( s1, "announce", 8 ) )
258    {
259        int pre  = (long) s1 - (long) inf->trackerAnnounce;
260        int post = strlen( inf->trackerAnnounce ) - pre - 8;
261        memcpy( tor->scrape, inf->trackerAnnounce, pre );
262        sprintf( &tor->scrape[pre], "scrape" );
263        memcpy( &tor->scrape[pre+6], &inf->trackerAnnounce[pre+8], post );
264    }
265
266    /* Escaped info hash for HTTP queries */
267    for( i = 0; i < SHA_DIGEST_LENGTH; i++ )
268    {
269        sprintf( &tor->hashString[3*i], "%%%02x", inf->hash[i] );
270    }
271
272    /* Block size: usually 16 ko, or less if we have to */
273    tor->blockSize  = MIN( inf->pieceSize, 1 << 14 );
274    tor->blockCount = ( inf->totalSize + tor->blockSize - 1 ) /
275                        tor->blockSize;
276    tor->completion = tr_cpInit( tor );
277
278    tr_lockInit( &tor->lock );
279
280    tor->globalUpload   = h->upload;
281    tor->globalDownload = h->download;
282    tor->fdlimit        = h->fdlimit;
283    tor->upload         = tr_rcInit();
284    tor->download       = tr_rcInit();
285 
286    /* We have a new torrent */
287    tr_lockLock( &h->acceptLock );
288    tor->prev = NULL;
289    tor->next = h->torrentList;
290    if( tor->next )
291    {
292        tor->next->prev = tor;
293    }
294    h->torrentList = tor;
295    (h->torrentCount)++;
296    tr_lockUnlock( &h->acceptLock );
297
298    if( 0 > h->bindPort )
299    {
300        tr_setBindPort( h, TR_DEFAULT_PORT );
301    }
302
303    return tor;
304}
305
306tr_info_t * tr_torrentInfo( tr_torrent_t * tor )
307{
308    return &tor->info;
309}
310
311/***********************************************************************
312 * tr_torrentScrape
313 **********************************************************************/
314int tr_torrentScrape( tr_torrent_t * tor, int * s, int * l )
315{
316    return tr_trackerScrape( tor, s, l );
317}
318
319void tr_torrentSetFolder( tr_torrent_t * tor, const char * path )
320{
321    tor->destination = strdup( path );
322    tr_ioLoadResume( tor );
323}
324
325char * tr_torrentGetFolder( tr_torrent_t * tor )
326{
327    return tor->destination;
328}
329
330void tr_torrentStart( tr_torrent_t * tor )
331{
332    if( tor->status & ( TR_STATUS_STOPPING | TR_STATUS_STOPPED ) )
333    {
334        /* Join the thread first */
335        torrentReallyStop( tor );
336    }
337
338    tor->status  = TR_STATUS_CHECK;
339    tor->tracker = tr_trackerInit( tor );
340
341    tor->date = tr_date();
342    tor->die = 0;
343    tr_threadCreate( &tor->thread, downloadLoop, tor );
344}
345
346void tr_torrentStop( tr_torrent_t * tor )
347{
348    tr_lockLock( &tor->lock );
349    tr_trackerStopped( tor->tracker );
350    tr_rcReset( tor->download );
351    tr_rcReset( tor->upload );
352    tor->status = TR_STATUS_STOPPING;
353    tor->stopDate = tr_date();
354    tr_lockUnlock( &tor->lock );
355}
356
357/***********************************************************************
358 * torrentReallyStop
359 ***********************************************************************
360 * Joins the download thread and frees/closes everything related to it.
361 **********************************************************************/
362static void torrentReallyStop( tr_torrent_t * tor )
363{
364    tor->die = 1;
365    tr_threadJoin( &tor->thread );
366    tr_dbg( "Thread joined" );
367
368    tr_trackerClose( tor->tracker );
369    tor->tracker = NULL;
370
371    while( tor->peerCount > 0 )
372    {
373        tr_peerRem( tor, 0 );
374    }
375}
376
377/***********************************************************************
378 * tr_torrentCount
379 ***********************************************************************
380 *
381 **********************************************************************/
382int tr_torrentCount( tr_handle_t * h )
383{
384    return h->torrentCount;
385}
386
387void tr_torrentIterate( tr_handle_t * h, tr_callback_t func, void * d )
388{
389    tr_torrent_t * tor, * next;
390
391    for( tor = h->torrentList; tor; tor = next )
392    {
393        next = tor->next;
394        func( tor, d );
395    }
396}
397
398int tr_getFinished( tr_torrent_t * tor )
399{
400    if( tor->finished )
401    {
402        tor->finished = 0;
403        return 1;
404    }
405    return 0;
406}
407
408tr_peer_t * tr_getPeer( tr_torrent_t * tor, int peerNum)
409{
410    tr_peer_t * peer;
411
412    tr_lockLock( &tor->lock );
413   
414    if (peerNum < 0 || peerNum >= tor->peerCount)
415        peer = NULL;
416    else
417        peer = tor->peers[peerNum];
418       
419    tr_lockUnlock( &tor->lock );
420   
421    return peer;
422}
423
424tr_stat_t * tr_torrentStat( tr_torrent_t * tor )
425{
426    tr_stat_t * s;
427    tr_info_t * inf = &tor->info;
428    int i;
429
430    tor->statCur = ( tor->statCur + 1 ) % 2;
431    s = &tor->stats[tor->statCur];
432
433    if( ( tor->status & TR_STATUS_STOPPED ) ||
434        ( ( tor->status & TR_STATUS_STOPPING ) &&
435          tr_date() > tor->stopDate + 60000 ) )
436    {
437        torrentReallyStop( tor );
438        tor->status = TR_STATUS_PAUSE;
439    }
440
441    tr_lockLock( &tor->lock );
442
443    s->status = tor->status;
444    s->error  = tor->error;
445    memcpy( s->trackerError, tor->trackerError,
446            sizeof( s->trackerError ) );
447
448    s->peersTotal       = 0;
449    s->peersUploading   = 0;
450    s->peersDownloading = 0;
451
452    for( i = 0; i < tor->peerCount; i++ )
453    {
454        if( tr_peerIsConnected( tor->peers[i] ) )
455        {
456            (s->peersTotal)++;
457            if( tr_peerIsUploading( tor->peers[i] ) )
458            {
459                (s->peersUploading)++;
460            }
461            if( tr_peerIsDownloading( tor->peers[i] ) )
462            {
463                (s->peersDownloading)++;
464            }
465        }
466    }
467
468    s->progress = tr_cpCompletionAsFloat( tor->completion );
469    if( tor->status & TR_STATUS_DOWNLOAD )
470        s->rateDownload = tr_rcRate( tor->download );
471    else
472        /* tr_rcRate() doesn't make the difference between 'piece'
473           messages and other messages, which causes a non-zero
474           download rate even tough we are not downloading. So we
475           force it to zero not to confuse the user. */
476        s->rateDownload = 0.0;
477    s->rateUpload = tr_rcRate( tor->upload );
478   
479    s->seeders  = tr_trackerSeeders(tor->tracker);
480        s->leechers = tr_trackerLeechers(tor->tracker);
481
482    if( s->rateDownload < 0.1 )
483    {
484        s->eta = -1;
485    }
486    else
487    {
488        s->eta = (float) ( 1.0 - s->progress ) *
489            (float) inf->totalSize / s->rateDownload / 1024.0;
490    }
491
492    s->downloaded = tor->downloaded;
493    s->uploaded   = tor->uploaded;
494
495    tr_lockUnlock( &tor->lock );
496
497    return s;
498}
499
500void tr_torrentAvailability( tr_torrent_t * tor, int8_t * tab, int size )
501{
502    int i, j, piece;
503
504    tr_lockLock( &tor->lock );
505    for( i = 0; i < size; i++ )
506    {
507        piece = i * tor->info.pieceCount / size;
508
509        if( tr_cpPieceIsComplete( tor->completion, piece ) )
510        {
511            tab[i] = -1;
512            continue;
513        }
514
515        tab[i] = 0;
516        for( j = 0; j < tor->peerCount; j++ )
517        {
518            if( tr_peerBitfield( tor->peers[j] ) &&
519                tr_bitfieldHas( tr_peerBitfield( tor->peers[j] ), piece ) )
520            {
521                (tab[i])++;
522            }
523        }
524    }
525    tr_lockUnlock( &tor->lock );
526}
527
528void tr_torrentRemoveSaved( tr_torrent_t * tor ) {
529    tr_metainfoRemoveSaved( tor->info.hashString );
530}
531
532/***********************************************************************
533 * tr_torrentClose
534 ***********************************************************************
535 * Frees memory allocated by tr_torrentInit.
536 **********************************************************************/
537void tr_torrentClose( tr_handle_t * h, tr_torrent_t * tor )
538{
539    tr_info_t * inf = &tor->info;
540
541    if( tor->status & ( TR_STATUS_STOPPING | TR_STATUS_STOPPED ) )
542    {
543        /* Join the thread first */
544        torrentReallyStop( tor );
545    }
546
547    tr_lockLock( &h->acceptLock );
548
549    h->torrentCount--;
550
551    tr_lockClose( &tor->lock );
552    tr_cpClose( tor->completion );
553
554    tr_rcClose( tor->upload );
555    tr_rcClose( tor->download );
556
557    if( tor->destination )
558    {
559        free( tor->destination );
560    }
561    free( inf->pieces );
562    free( inf->files );
563
564    if( tor->prev )
565    {
566        tor->prev->next = tor->next;
567    }
568    else
569    {
570        h->torrentList = tor->next;
571    }
572    if( tor->next )
573    {
574        tor->next->prev = tor->prev;
575    }
576    free( tor );
577
578    tr_lockUnlock( &h->acceptLock );
579}
580
581void tr_close( tr_handle_t * h )
582{
583    acceptStop( h );
584    tr_chokingClose( h->choking );
585    tr_fdClose( h->fdlimit );
586    tr_rcClose( h->upload );
587    tr_rcClose( h->download );
588    free( h );
589
590    tr_netResolveThreadClose();
591}
592
593/***********************************************************************
594 * downloadLoop
595 **********************************************************************/
596static void downloadLoop( void * _tor )
597{
598    tr_torrent_t * tor = _tor;
599    uint64_t       date1, date2;
600
601    tr_dbg( "Thread started" );
602
603#ifdef SYS_BEOS
604    /* This is required because on BeOS, SIGINT is sent to each thread,
605       which kills them not nicely */
606    signal( SIGINT, SIG_IGN );
607#endif
608
609    tr_lockLock( &tor->lock );
610
611    tr_cpReset( tor->completion );
612    tor->io     = tr_ioInit( tor );
613    tor->status = tr_cpIsSeeding( tor->completion ) ?
614                      TR_STATUS_SEED : TR_STATUS_DOWNLOAD;
615
616    while( !tor->die )
617    {
618        date1 = tr_date();
619
620        /* Are we finished ? */
621        if( ( tor->status & TR_STATUS_DOWNLOAD ) &&
622            tr_cpIsSeeding( tor->completion ) )
623        {
624            /* Done */
625            tor->status = TR_STATUS_SEED;
626                        tor->finished = 1;
627            tr_trackerCompleted( tor->tracker );
628            tr_ioSaveResume( tor->io );
629#ifndef __AMIGAOS4__
630            sync(); /* KLUDGE: all files should be closed and
631                       re-opened in read-only mode instead */
632#endif
633        }
634
635        /* Receive/send messages */
636        tr_peerPulse( tor );
637
638        /* Try to get new peers or to send a message to the tracker */
639        tr_trackerPulse( tor->tracker );
640
641        if( tor->status & TR_STATUS_STOPPED )
642        {
643            break;
644        }
645
646        /* Wait up to 20 ms */
647        date2 = tr_date();
648        if( date2 < date1 + 20 )
649        {
650            tr_lockUnlock( &tor->lock );
651            tr_wait( date1 + 20 - date2 );
652            tr_lockLock( &tor->lock );
653        }
654    }
655
656    tr_lockUnlock( &tor->lock );
657
658    tr_ioClose( tor->io );
659
660    tor->status = TR_STATUS_STOPPED;
661
662    tr_dbg( "Thread exited" );
663}
664
665/***********************************************************************
666 * acceptLoop
667 **********************************************************************/
668static void acceptLoop( void * _h )
669{
670    tr_handle_t * h = _h;
671    uint64_t      date1, date2, lastchoke = 0;
672    int           ii;
673    uint8_t     * hash;
674    tr_torrent_t * tor;
675
676    tr_dbg( "Accept thread started" );
677
678#ifdef SYS_BEOS
679    /* This is required because on BeOS, SIGINT is sent to each thread,
680       which kills them not nicely */
681    signal( SIGINT, SIG_IGN );
682#endif
683
684    tr_lockLock( &h->acceptLock );
685
686    while( !h->acceptDie )
687    {
688        date1 = tr_date();
689
690        /* Check for incoming connections */
691        if( h->bindSocket > -1 &&
692            h->acceptPeerCount < TR_MAX_PEER_COUNT &&
693            !tr_fdSocketWillCreate( h->fdlimit, 0 ) )
694        {
695            int            s;
696            struct in_addr addr;
697            in_port_t      port;
698            s = tr_netAccept( h->bindSocket, &addr, &port );
699            if( s > -1 )
700            {
701                h->acceptPeers[h->acceptPeerCount++] = tr_peerInit( addr, port, s );
702            }
703            else
704            {
705                tr_fdSocketClosed( h->fdlimit, 0 );
706            }
707        }
708
709        for( ii = 0; ii < h->acceptPeerCount; )
710        {
711            if( tr_peerRead( NULL, h->acceptPeers[ii] ) )
712            {
713                tr_peerDestroy( h->fdlimit, h->acceptPeers[ii] );
714                goto removePeer;
715            }
716            if( NULL != ( hash = tr_peerHash( h->acceptPeers[ii] ) ) )
717            {
718                for( tor = h->torrentList; tor; tor = tor->next )
719                {
720                    tr_lockLock( &tor->lock );
721                    if( 0 == memcmp( tor->info.hash, hash,
722                                     SHA_DIGEST_LENGTH ) )
723                    {
724                      tr_peerAttach( tor, h->acceptPeers[ii] );
725                      tr_lockUnlock( &tor->lock );
726                      goto removePeer;
727                    }
728                    tr_lockUnlock( &tor->lock );
729                }
730                tr_peerDestroy( h->fdlimit, h->acceptPeers[ii] );
731                goto removePeer;
732            }
733            if( date1 > tr_peerDate( h->acceptPeers[ii] ) + 10000 )
734            {
735                /* Give them 10 seconds to send the handshake */
736                tr_peerDestroy( h->fdlimit, h->acceptPeers[ii] );
737                goto removePeer;
738            }
739            ii++;
740            continue;
741           removePeer:
742            h->acceptPeerCount--;
743            memmove( &h->acceptPeers[ii], &h->acceptPeers[ii+1],
744                     ( h->acceptPeerCount - ii ) * sizeof( tr_peer_t * ) );
745        }
746
747        if( date1 > lastchoke + 2000 )
748        {
749            tr_chokingPulse( h->choking );
750            lastchoke = date1;
751        }
752
753        /* Wait up to 20 ms */
754        date2 = tr_date();
755        if( date2 < date1 + 20 )
756        {
757            tr_lockUnlock( &h->acceptLock );
758            tr_wait( date1 + 20 - date2 );
759            tr_lockLock( &h->acceptLock );
760        }
761    }
762
763    tr_lockUnlock( &h->acceptLock );
764
765    tr_dbg( "Accept thread exited" );
766}
767
768/***********************************************************************
769 * acceptStop
770 ***********************************************************************
771 * Joins the accept thread and frees/closes everything related to it.
772 **********************************************************************/
773static void acceptStop( tr_handle_t * h )
774{
775    int ii;
776
777    h->acceptDie = 1;
778    tr_threadJoin( &h->acceptThread );
779    tr_lockClose( &h->acceptLock );
780    tr_dbg( "Accept thread joined" );
781
782    for( ii = 0; ii < h->acceptPeerCount; ii++ )
783    {
784        tr_peerDestroy( h->fdlimit, h->acceptPeers[ii] );
785    }
786
787    if( h->bindSocket > -1 )
788    {
789        tr_netClose( h->bindSocket );
790        tr_fdSocketClosed( h->fdlimit, 0 );
791    }
792}
Note: See TracBrowser for help on using the repository browser.