Changeset 7486
- Timestamp:
- Dec 24, 2008, 2:50:08 AM (12 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/peer-io.c
r7476 r7486 215 215 { 216 216 int res; 217 int e; 217 218 tr_peerIo * io = vio; 218 219 … … 236 237 } 237 238 239 errno = 0; 238 240 res = evbuffer_read( io->inbuf, fd, howmuch ); 241 e = errno; 239 242 240 243 if( res > 0 ) … … 252 255 what |= EVBUFFER_EOF; 253 256 else if( res == -1 ) { 254 if( e rrno == EAGAIN || errno== EINTR ) {257 if( e == EAGAIN || e == EINTR ) { 255 258 tr_peerIoSetEnabled( io, dir, TRUE ); 256 259 return; … … 259 262 } 260 263 264 dbgmsg( io, "event_read_cb got an error. res is %d, what is %hd, errno is %d (%s)", res, what, e, strerror( e ) ); 265 261 266 if( io->gotError != NULL ) 262 267 io->gotError( io, what, io->userData ); … … 269 274 struct evbuffer * buffer = io->outbuf; 270 275 int n = MIN( EVBUFFER_LENGTH( buffer ), howmuch ); 271 276 int e; 277 278 errno = 0; 272 279 #ifdef WIN32 273 280 n = send(fd, buffer->buffer, n, 0 ); … … 275 282 n = write(fd, buffer->buffer, n ); 276 283 #endif 277 dbgmsg( io, "wrote %d to peer (%s)", n, (n==-1?strerror(errno):"") ); 284 e = errno; 285 dbgmsg( io, "wrote %d to peer (%s)", n, (n==-1?strerror(e):"") ); 278 286 279 287 if( n == -1 ) … … 290 298 { 291 299 int res = 0; 300 int e; 292 301 short what = EVBUFFER_WRITE; 293 302 tr_peerIo * io = vio; … … 309 318 } 310 319 320 errno = 0; 311 321 res = tr_evbuffer_write( io, fd, howmuch ); 322 e = errno; 323 312 324 if (res == -1) { 313 325 #ifndef WIN32 314 326 /*todo. evbuffer uses WriteFile when WIN32 is set. WIN32 system calls do not 315 327 * *set errno. thus this error checking is not portable*/ 316 if (e rrno == EAGAIN || errno == EINTR || errno== EINPROGRESS)328 if (e == EAGAIN || e == EINTR || e == EINPROGRESS) 317 329 goto reschedule; 318 330 /* error case */ … … 342 354 343 355 error: 356 357 dbgmsg( io, "event_write_cb got an error. res is %d, what is %hd, errno is %d (%s)", res, what, e, strerror( e ) ); 358 344 359 if( io->gotError != NULL ) 345 360 io->gotError( io, what, io->userData ); … … 892 907 tr_peerIoTryRead( tr_peerIo * io, size_t howmuch ) 893 908 { 894 int res; 895 896 assert( tr_isPeerIo( io ) ); 897 898 howmuch = tr_bandwidthClamp( io->bandwidth, TR_DOWN, howmuch ); 899 900 res = howmuch ? evbuffer_read( io->inbuf, io->socket, howmuch ) : 0; 901 902 dbgmsg( io, "read %d from peer (%s)", res, (res==-1?strerror(errno):"") ); 903 904 if( EVBUFFER_LENGTH( io->inbuf ) ) 905 canReadWrapper( io ); 906 907 if( ( res <= 0 ) && ( io->gotError ) && ( errno != EAGAIN ) && ( errno != EINTR ) && ( errno != EINPROGRESS ) ) 909 int res = 0; 910 911 assert( tr_isPeerIo( io ) ); 912 913 if(( howmuch = tr_bandwidthClamp( io->bandwidth, TR_DOWN, howmuch ))) 908 914 { 909 short what = EVBUFFER_READ | EVBUFFER_ERROR; 910 if( res == 0 ) 911 what |= EVBUFFER_EOF; 912 io->gotError( io, what, io->userData ); 915 int e; 916 errno = 0; 917 res = evbuffer_read( io->inbuf, io->socket, howmuch ); 918 e = errno; 919 920 dbgmsg( io, "read %d from peer (%s)", res, (res==-1?strerror(e):"") ); 921 922 if( EVBUFFER_LENGTH( io->inbuf ) ) 923 canReadWrapper( io ); 924 925 if( ( res <= 0 ) && ( io->gotError ) && ( e != EAGAIN ) && ( e != EINTR ) && ( e != EINPROGRESS ) ) 926 { 927 short what = EVBUFFER_READ | EVBUFFER_ERROR; 928 if( res == 0 ) 929 what |= EVBUFFER_EOF; 930 dbgmsg( io, "tr_peerIoTryRead got an error. res is %d, what is %hd, errno is %d (%s)", res, what, e, strerror( e ) ); 931 io->gotError( io, what, io->userData ); 932 } 913 933 } 914 934 … … 923 943 assert( tr_isPeerIo( io ) ); 924 944 925 howmuch = tr_bandwidthClamp( io->bandwidth, TR_UP, howmuch ); 926 927 n = tr_evbuffer_write( io, io->socket, (int)howmuch ); 928 929 if( n > 0 ) 930 didWriteWrapper( io, n ); 931 932 if( ( n < 0 ) && ( io->gotError ) && ( errno != EPIPE ) && ( errno != EAGAIN ) && ( errno != EINTR ) && ( errno != EINPROGRESS ) ) { 933 short what = EVBUFFER_WRITE | EVBUFFER_ERROR; 934 io->gotError( io, what, io->userData ); 945 if(( howmuch = tr_bandwidthClamp( io->bandwidth, TR_UP, howmuch ))) 946 { 947 int e; 948 errno = 0; 949 n = tr_evbuffer_write( io, io->socket, (int)howmuch ); 950 e = errno; 951 952 if( n > 0 ) 953 didWriteWrapper( io, n ); 954 955 if( ( n < 0 ) && ( io->gotError ) && ( e != EPIPE ) && ( e != EAGAIN ) && ( e != EINTR ) && ( e != EINPROGRESS ) ) 956 { 957 const short what = EVBUFFER_WRITE | EVBUFFER_ERROR; 958 dbgmsg( io, "tr_peerIoTryWrite got an error. res is %d, what is %hd, errno is %d (%s)", n, what, e, strerror( e ) ); 959 io->gotError( io, what, io->userData ); 960 } 935 961 } 936 962 -
trunk/libtransmission/peer-mgr.c
r7476 r7486 914 914 atom->myflags |= MYFLAG_BANNED; 915 915 peer->doPurge = 1; 916 tordbg( t, "banning peer %s", 917 tr_peerIoAddrStr( &atom->addr, atom->port ) ); 916 tordbg( t, "banning peer %s", tr_peerIoAddrStr( &atom->addr, atom->port ) ); 918 917 } 919 918 } … … 1141 1140 addStrike( t, peer ); 1142 1141 peer->doPurge = 1; 1143 tordbg( t, "setting doPurge because we got an EINVAL error");1142 tordbg( t, "setting %s doPurge flag because we got an EINVAL error", tr_peerIoAddrStr( &peer->addr, peer->port ) ); 1144 1143 } 1145 1144 else if( ( e->err == ERANGE ) … … 1149 1148 /* some protocol error from the peer */ 1150 1149 peer->doPurge = 1; 1151 tordbg( t, "setting doPurge because we got an ERANGE, EMSGSIZE, or ENOTCONN error");1150 tordbg( t, "setting %s doPurge flag because we got an ERANGE, EMSGSIZE, or ENOTCONN error", tr_peerIoAddrStr( &peer->addr, peer->port ) ); 1152 1151 } 1153 1152 else /* a local error, such as an IO error */
Note: See TracChangeset
for help on using the changeset viewer.