Changeset 11903
- Timestamp:
- Feb 18, 2011, 12:23:51 AM (12 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/peer-io.c
r11857 r11903 26 26 #include <event2/event.h> 27 27 #include <event2/bufferevent.h> 28 #include "utp.h" 28 29 29 30 #include "transmission.h" … … 368 369 tr_bool isIncoming, 369 370 tr_bool isSeed, 370 int socket ) 371 int socket, 372 struct UTPSocket * utp_socket) 371 373 { 372 374 tr_peerIo * io; … … 377 379 assert( tr_isBool( isSeed ) ); 378 380 assert( tr_amInEventThread( session ) ); 381 assert( (socket < 0) == (utp_socket != NULL) ); 379 382 380 383 if( socket >= 0 ) { … … 392 395 io->port = port; 393 396 io->socket = socket; 397 io->utp_socket = utp_socket; 394 398 io->isIncoming = isIncoming != 0; 395 399 io->timeCreated = tr_time( ); 396 400 io->inbuf = evbuffer_new( ); 397 401 io->outbuf = evbuffer_new( ); 398 io->event_read = event_new( session->event_base, io->socket, EV_READ, event_read_cb, io );399 io->event_write = event_new( session->event_base, io->socket, EV_WRITE, event_write_cb, io );400 402 tr_bandwidthConstruct( &io->bandwidth, session, parent ); 401 403 tr_bandwidthSetPeer( &io->bandwidth, io ); 402 404 dbgmsg( io, "bandwidth is %p; its parent is %p", &io->bandwidth, parent ); 405 406 if( io->socket >= 0 ) { 407 io->event_read = event_new( session->event_base, 408 io->socket, EV_READ, event_read_cb, io ); 409 io->event_write = event_new( session->event_base, 410 io->socket, EV_WRITE, event_write_cb, io ); 411 } 403 412 404 413 return io; … … 410 419 const tr_address * addr, 411 420 tr_port port, 412 int fd ) 421 int fd, 422 struct UTPSocket * utp_socket ) 413 423 { 414 424 assert( session ); 415 425 assert( tr_isAddress( addr ) ); 416 assert( fd >= 0 ); 417 418 return tr_peerIoNew( session, parent, addr, port, NULL, TRUE, FALSE, fd);426 427 return tr_peerIoNew( session, parent, addr, port, NULL, TRUE, FALSE, 428 fd, utp_socket ); 419 429 } 420 430 … … 437 447 438 448 return fd < 0 ? NULL 439 : tr_peerIoNew( session, parent, addr, port, torrentHash, FALSE, isSeed, fd ); 449 : tr_peerIoNew( session, parent, addr, port, 450 torrentHash, FALSE, isSeed, fd, NULL ); 440 451 } 441 452 … … 450 461 assert( io->session != NULL ); 451 462 assert( io->session->events != NULL ); 463 464 if( io->socket < 0 ) 465 return; 466 467 assert( io->session->events != NULL ); 452 468 assert( event_initialized( io->event_read ) ); 453 469 assert( event_initialized( io->event_write ) ); 454 455 if( io->socket < 0 )456 return;457 470 458 471 if( ( event & EV_READ ) && ! ( io->pendingEvents & EV_READ ) ) … … 476 489 assert( tr_amInEventThread( io->session ) ); 477 490 assert( io->session != NULL ); 491 492 if( io->socket < 0 ) 493 return; 494 478 495 assert( io->session->events != NULL ); 479 496 assert( event_initialized( io->event_read ) ); … … 533 550 evbuffer_free( io->outbuf ); 534 551 evbuffer_free( io->inbuf ); 535 tr_netClose( io->session, io->socket ); 552 if( io->socket >= 0 ) 553 tr_netClose( io->session, io->socket ); 554 if( io->utp_socket != NULL ) 555 UTP_Close( io->utp_socket ); 536 556 tr_cryptoFree( io->crypto ); 537 557 tr_list_free( &io->outbuf_datatypes, tr_free ); … … 640 660 event_disable( io, EV_READ | EV_WRITE ); 641 661 642 if( io->socket >= 0 ) 662 if( io->socket >= 0 ) { 643 663 tr_netClose( session, io->socket ); 664 io->socket = -1; 665 } 666 if( io->utp_socket != NULL ) { 667 UTP_Close(io->utp_socket); 668 io->utp_socket = NULL; 669 } 644 670 645 671 event_free( io->event_read ); -
trunk/libtransmission/peer-io.h
r11857 r11903 84 84 tr_port port; 85 85 int socket; 86 struct UTPSocket *utp_socket; 86 87 87 88 int refCount; … … 126 127 const struct tr_address * addr, 127 128 tr_port port, 128 int socket ); 129 int socket, 130 struct UTPSocket * utp_socket ); 129 131 130 132 void tr_peerIoRefImpl ( const char * file, -
trunk/libtransmission/peer-mgr.c
r11900 r11903 18 18 19 19 #include <event2/event.h> 20 #include "utp.h" 20 21 21 22 #include "transmission.h" … … 2008 2009 tr_address * addr, 2009 2010 tr_port port, 2010 int socket ) 2011 int socket, 2012 struct UTPSocket * utp_socket ) 2011 2013 { 2012 2014 tr_session * session; … … 2020 2022 { 2021 2023 tr_dbg( "Banned IP address \"%s\" tried to connect to us", tr_ntop_non_ts( addr ) ); 2022 tr_netClose( session, socket ); 2024 if(socket >= 0) 2025 tr_netClose( session, socket ); 2026 else 2027 UTP_Close( utp_socket ); 2023 2028 } 2024 2029 else if( getExistingHandshake( &manager->incomingHandshakes, addr ) ) 2025 2030 { 2026 tr_netClose( session, socket ); 2031 if(socket >= 0) 2032 tr_netClose( session, socket ); 2033 else 2034 UTP_Close( utp_socket ); 2027 2035 } 2028 2036 else /* we don't have a connection to them yet... */ … … 2031 2039 tr_handshake * handshake; 2032 2040 2033 io = tr_peerIoNewIncoming( session, session->bandwidth, addr, port, socket );2041 io = tr_peerIoNewIncoming( session, session->bandwidth, addr, port, socket, utp_socket ); 2034 2042 2035 2043 handshake = tr_handshakeNew( io, … … 2613 2621 2614 2622 pch = stat->flagStr; 2623 if( peer->io->utp_socket != NULL) *pch++ = 'T'; 2615 2624 if( t->optimistic == peer ) *pch++ = 'O'; 2616 2625 if( stat->isDownloadingFrom ) *pch++ = 'D'; -
trunk/libtransmission/peer-mgr.h
r11709 r11903 35 35 */ 36 36 37 struct UTPSocket; 37 38 struct tr_peer_stat; 38 39 struct tr_torrent; … … 164 165 tr_address * addr, 165 166 tr_port port, 166 int socket ); 167 int socket, 168 struct UTPSocket *utp_socket ); 167 169 168 170 tr_pex * tr_peerMgrCompactToPex( const void * compact, -
trunk/libtransmission/session.c
r11800 r11903 195 195 tr_deepLog( __FILE__, __LINE__, NULL, "new incoming connection %d (%s)", 196 196 clientSocket, tr_peerIoAddrStr( &clientAddr, clientPort ) ); 197 tr_peerMgrAddIncoming( session->peerMgr, &clientAddr, clientPort, clientSocket ); 197 tr_peerMgrAddIncoming( session->peerMgr, &clientAddr, clientPort, 198 clientSocket, NULL ); 198 199 } 199 200 }
Note: See TracChangeset
for help on using the changeset viewer.