Changeset 7133
- Timestamp:
- Nov 21, 2008, 4:32:55 PM (14 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/net.c
r7122 r7133 120 120 createSocket( int type ) 121 121 { 122 const int fd = makeSocketNonBlocking( tr_fdSocketCreate( type ) ); 123 124 if( fd >= 0 ) { 125 const int buffsize = 1500*3; /* 3x MTU for most ethernet/wireless */ 126 setsockopt( fd, SOL_SOCKET, SO_SNDBUF, &buffsize, sizeof( buffsize ) ); 127 } 128 129 return fd; 130 } 131 132 int 133 tr_netOpenTCP( const struct in_addr * addr, 134 tr_port_t port ) 122 return makeSocketNonBlocking( tr_fdSocketCreate( type ) ); 123 } 124 125 static void 126 setSndBuf( tr_session * session, int fd ) 127 { 128 if( fd >= 0 ) 129 { 130 const int sndbuf = session->so_sndbuf; 131 setsockopt( fd, SOL_SOCKET, SO_SNDBUF, &sndbuf, sizeof( sndbuf ) ); 132 } 133 } 134 135 int 136 tr_netOpenTCP( tr_session * session, 137 const struct in_addr * addr, 138 tr_port_t port ) 135 139 { 136 140 int s; … … 140 144 if( ( s = createSocket( type ) ) < 0 ) 141 145 return -1; 146 147 setSndBuf( session, s ); 142 148 143 149 memset( &sock, 0, sizeof( sock ) ); … … 205 211 206 212 int 207 tr_netAccept( int b, 208 struct in_addr * addr, 209 tr_port_t * port ) 210 { 211 return makeSocketNonBlocking( tr_fdSocketAccept( b, addr, port ) ); 213 tr_netAccept( tr_session * session, 214 int b, 215 struct in_addr * addr, 216 tr_port_t * port ) 217 { 218 int fd = makeSocketNonBlocking( tr_fdSocketAccept( b, addr, port ) ); 219 setSndBuf( session, fd ); 220 return fd; 212 221 } 213 222 -
trunk/libtransmission/net.h
r6924 r7133 59 59 struct in_addr; 60 60 struct sockaddr_in; 61 struct tr_session; 61 62 62 63 /*********************************************************************** … … 70 71 * Sockets 71 72 **********************************************************************/ 72 int tr_netOpenTCP( const struct in_addr * addr, 73 int tr_netOpenTCP( struct tr_handle * session, 74 const struct in_addr * addr, 73 75 tr_port_t port ); 74 76 75 77 int tr_netBindTCP( int port ); 76 78 77 int tr_netAccept( int s, 78 struct in_addr *, 79 tr_port_t * ); 79 int tr_netAccept( struct tr_handle * session, 80 int bound, 81 struct in_addr * setme_addr, 82 tr_port_t * setme_port ); 80 83 81 84 int tr_netSetTOS( int s, -
trunk/libtransmission/peer-io.c
r7130 r7133 387 387 assert( torrentHash ); 388 388 389 socket = tr_netOpenTCP( in_addr, port );389 socket = tr_netOpenTCP( session, in_addr, port ); 390 390 391 391 return socket < 0 … … 493 493 tr_netClose( io->socket ); 494 494 495 io->socket = tr_netOpenTCP( &io->in_addr, io->port );495 io->socket = tr_netOpenTCP( io->session, &io->in_addr, io->port ); 496 496 497 497 if( io->socket >= 0 ) … … 716 716 *** 717 717 **/ 718 719 int720 tr_peerIoWantsBandwidth( const tr_peerIo * io,721 tr_direction direction )722 {723 assert( direction == TR_UP || direction == TR_DOWN );724 725 if( direction == TR_DOWN )726 {727 return TRUE; /* FIXME -- is there a good way to test for this? */728 }729 else730 {731 return EVBUFFER_LENGTH( EVBUFFER_OUTPUT( io->bufev ) )732 || EVBUFFER_LENGTH( io->output );733 }734 }735 718 736 719 void -
trunk/libtransmission/peer-io.h
r7125 r7133 129 129 **/ 130 130 131 int tr_peerIoWantsBandwidth ( const tr_peerIo * io,132 tr_direction direction );133 134 131 void tr_peerIoWrite ( tr_peerIo * io, 135 132 const void * writeme, -
trunk/libtransmission/port-forwarding.c
r6795 r7133 43 43 int publicPort; 44 44 45 tr_ handle * h;46 tr_timer * pulseTimer; 47 48 tr_ upnp * upnp;49 tr_ natpmp * natpmp;45 tr_timer * pulseTimer; 46 47 tr_upnp * upnp; 48 tr_natpmp * natpmp; 49 tr_session * session; 50 50 }; 51 51 … … 146 146 break; 147 147 148 socket = tr_netAccept( s-> bindSocket, &addr, &port );148 socket = tr_netAccept( s->session, s->bindSocket, &addr, &port ); 149 149 if( socket < 0 ) 150 150 break; … … 152 152 tr_deepLog( __FILE__, __LINE__, NULL, 153 153 "New INCOMING connection %d (%s)", 154 socket, tr_peerIoAddrStr( &addr, 155 port ) ); 156 157 tr_peerMgrAddIncoming( s->h->peerMgr, &addr, port, socket ); 154 socket, tr_peerIoAddrStr( &addr, port ) ); 155 156 tr_peerMgrAddIncoming( s->session->peerMgr, &addr, port, socket ); 158 157 } 159 158 } … … 178 177 tr_natpmpClose( shared->natpmp ); 179 178 tr_upnpClose( shared->upnp ); 180 shared-> h->shared = NULL;179 shared->session->shared = NULL; 181 180 tr_free( shared ); 182 181 keepPulsing = 0; … … 191 190 192 191 tr_shared * 193 tr_sharedInit( tr_ handle * h,194 int isEnabled,195 int publicPort )192 tr_sharedInit( tr_session * session, 193 int isEnabled, 194 int publicPort ) 196 195 { 197 196 tr_shared * s = tr_new0( tr_shared, 1 ); 198 197 199 s-> h = h;198 s->session = session; 200 199 s->publicPort = publicPort; 201 200 s->bindPort = -1; … … 203 202 s->natpmp = tr_natpmpInit( ); 204 203 s->upnp = tr_upnpInit( ); 205 s->pulseTimer = tr_timerNew( h, sharedPulse, s, 1000 );204 s->pulseTimer = tr_timerNew( session, sharedPulse, s, 1000 ); 206 205 s->isEnabled = isEnabled ? 1 : 0; 207 206 s->upnpStatus = TR_PORT_UNMAPPED; … … 225 224 s->publicPort = port; 226 225 227 while( ( tor = tr_torrentNext( s-> h, tor ) ) )226 while( ( tor = tr_torrentNext( s->session, tor ) ) ) 228 227 tr_torrentChangeMyPort( tor ); 229 228 } -
trunk/libtransmission/session.c
r7113 r7133 259 259 h->rawSpeed[TR_PEER_TO_CLIENT] = tr_rcInit( ); 260 260 h->rawSpeed[TR_CLIENT_TO_PEER] = tr_rcInit( ); 261 h->so_sndbuf = 1500 * 3; /* 3x MTU for most ethernet/wireless */ 261 262 262 263 if( configDir == NULL ) -
trunk/libtransmission/session.h
r7069 r7133 106 106 int metainfoLookupCount; 107 107 108 /* the size of the output buffer for peer connections */ 109 int so_sndbuf; 110 108 111 /* the rate at which pieces are being transferred between client and peer. 109 112 * protocol overhead is NOT included; this is only the piece data */
Note: See TracChangeset
for help on using the changeset viewer.