Changeset 3232
- Timestamp:
- Sep 29, 2007, 2:19:23 PM (15 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/handshake.c
r3231 r3232 1085 1085 handshake->doneUserData = doneUserData; 1086 1086 handshake->handle = tr_peerIoGetHandle( io ); 1087 1088 1087 handshake->startTimer = tr_timerNew( handshake->handle, 1089 1088 handshakeStart, -
trunk/libtransmission/peer-mgr.c
r3231 r3232 32 32 #include "utils.h" 33 33 34 #include "pthread.h" 35 34 36 enum 35 37 { … … 107 109 tr_ptrArray * handshakes; /* in-process */ 108 110 tr_lock * lock; 109 uint8_t isLocked;111 pthread_t lockThread; 110 112 }; 111 113 … … 117 119 managerLock( struct tr_peerMgr * manager ) 118 120 { 119 assert( !manager->isLocked);121 assert( manager->lockThread != pthread_self() ); 120 122 tr_lockLock( manager->lock ); 121 manager-> isLocked = TRUE;123 manager->lockThread = pthread_self(); 122 124 } 123 125 static void 124 126 managerUnlock( struct tr_peerMgr * manager ) 125 127 { 126 assert( manager-> isLocked);127 manager-> isLocked = FALSE;128 assert( manager->lockThread == pthread_self() ); 129 manager->lockThread = 0; 128 130 tr_lockUnlock( manager->lock ); 129 131 } … … 141 143 torrentIsLocked( Torrent * t ) 142 144 { 143 return t!=NULL && t->manager!=NULL && t->manager->isLocked; 144 } 145 146 #define managerLock(a) fprintf(stderr,"%s:%d locking\n",__FILE__,__LINE__); managerLock(a); 145 return t!=NULL && t->manager!=NULL && t->manager->lockThread!=0; 146 } 147 147 148 148 /** … … 509 509 setme->priority = inf->pieces[piece].priority; 510 510 setme->peerCount = 0; 511 setme->fastAllowed = 0; 511 512 /* FIXME */ 512 513 // setme->fastAllowed = tr_bitfieldHas( t->tor->allowedList, i); … … 771 772 Torrent * t = (Torrent *) vt; 772 773 const tr_peermsgs_event * e = (const tr_peermsgs_event *) vevent; 773 774 torrentLock( t ); 774 const int needLock = !torrentIsLocked( t ); 775 776 if( needLock ) 777 torrentLock( t ); 775 778 776 779 switch( e->eventType ) … … 811 814 } 812 815 813 torrentUnlock( t ); 816 if( needLock ) 817 torrentUnlock( t ); 814 818 } 815 819 … … 895 899 tr_handshake * handshake; 896 900 897 assert( manager-> isLocked);901 assert( manager->lockThread!=0 ); 898 902 assert( io != NULL ); 899 903
Note: See TracChangeset
for help on using the changeset viewer.