Changeset 7594 for trunk/libtransmission/peer-io.c
- Timestamp:
- Jan 3, 2009, 4:57:40 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/peer-io.c
r7593 r7594 234 234 } 235 235 236 static int236 static ssize_t 237 237 tr_evbuffer_write( tr_peerIo * io, int fd, size_t howmuch ) 238 238 { 239 int e; 240 ssize_t n; 239 241 struct evbuffer * buffer = io->outbuf; 240 int n = MIN( EVBUFFER_LENGTH( buffer ), howmuch ); 241 int e;242 243 howmuch = MIN( EVBUFFER_LENGTH( buffer ), howmuch ); 242 244 243 245 errno = 0; … … 248 250 #endif 249 251 e = errno; 250 dbgmsg( io, "wrote %d to peer (%s)", n, (n==-1?strerror(e):"") ); 251 252 if( n == -1 ) 253 return -1; 254 if (n == 0) 255 return 0; 256 evbuffer_drain( buffer, n ); 252 dbgmsg( io, "wrote %zd to peer (%s)", n, (n==-1?strerror(e):"") ); 253 254 if( n > 0 ) 255 evbuffer_drain( buffer, n ); 257 256 258 257 return n; … … 729 728 ***/ 730 729 731 static int730 static ssize_t 732 731 tr_peerIoTryRead( tr_peerIo * io, size_t howmuch ) 733 732 { 734 int res = 0;733 ssize_t res = 0; 735 734 736 735 if(( howmuch = tr_bandwidthClamp( &io->bandwidth, TR_DOWN, howmuch ))) … … 741 740 e = errno; 742 741 743 dbgmsg( io, "read % d from peer (%s)", res, (res==-1?strerror(e):"") );742 dbgmsg( io, "read %zd from peer (%s)", res, (res==-1?strerror(e):"") ); 744 743 745 744 if( EVBUFFER_LENGTH( io->inbuf ) ) … … 751 750 if( res == 0 ) 752 751 what |= EVBUFFER_EOF; 753 dbgmsg( io, "tr_peerIoTryRead got an error. res is % d, what is %hd, errno is %d (%s)", res, what, e, strerror( e ) );752 dbgmsg( io, "tr_peerIoTryRead got an error. res is %zd, what is %hd, errno is %d (%s)", res, what, e, strerror( e ) ); 754 753 io->gotError( io, what, io->userData ); 755 754 } … … 759 758 } 760 759 761 static int760 static ssize_t 762 761 tr_peerIoTryWrite( tr_peerIo * io, size_t howmuch ) 763 762 { 764 int n = 0;763 ssize_t n = 0; 765 764 766 765 if(( howmuch = tr_bandwidthClamp( &io->bandwidth, TR_UP, howmuch ))) … … 768 767 int e; 769 768 errno = 0; 770 n = tr_evbuffer_write( io, io->socket, (int)howmuch );769 n = tr_evbuffer_write( io, io->socket, howmuch ); 771 770 e = errno; 772 771 … … 777 776 { 778 777 const short what = EVBUFFER_WRITE | EVBUFFER_ERROR; 779 dbgmsg( io, "tr_peerIoTryWrite got an error. res is % d, what is %hd, errno is %d (%s)", n, what, e, strerror( e ) );778 dbgmsg( io, "tr_peerIoTryWrite got an error. res is %zd, what is %hd, errno is %d (%s)", n, what, e, strerror( e ) ); 780 779 io->gotError( io, what, io->userData ); 781 780 } … … 785 784 } 786 785 787 int786 ssize_t 788 787 tr_peerIoFlush( tr_peerIo * io, tr_direction dir, size_t limit ) 789 788 { 790 int bytesUsed;789 ssize_t bytesUsed; 791 790 792 791 assert( tr_isPeerIo( io ) ); 793 792 assert( tr_isDirection( dir ) ); 794 793 795 if( dir ==TR_DOWN )794 if( dir == TR_DOWN ) 796 795 bytesUsed = tr_peerIoTryRead( io, limit ); 797 796 else 798 797 bytesUsed = tr_peerIoTryWrite( io, limit ); 799 798 800 dbgmsg( io, "flushing peer-io, direction %d, limit %zu, bytesUsed % d", (int)dir, limit, bytesUsed );799 dbgmsg( io, "flushing peer-io, direction %d, limit %zu, bytesUsed %zd", (int)dir, limit, bytesUsed ); 801 800 return bytesUsed; 802 801 }
Note: See TracChangeset
for help on using the changeset viewer.