Changeset 4ed9c8c
- Timestamp:
- 2010-03-21T15:10:07Z (15 years ago)
- Branches:
- master
- Children:
- a81d679
- Parents:
- 2e89256
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
dcc.c
r2e89256 r4ed9c8c 294 294 if( cond & GAIM_INPUT_READ ) 295 295 { 296 int bytes_received;297 296 int ret; 298 297 299 ASSERTSOCKOP( ret = recv( fd, &bytes_received, sizeof( bytes_received ), MSG_PEEK ), "Receiving" ); 298 ASSERTSOCKOP( ret = recv( fd, ( (char*) &df->acked ) + df->acked_len, 299 sizeof( df->acked ) - df->acked_len, 0 ), "Receiving" ); 300 300 301 301 if( ret == 0 ) 302 302 return dcc_abort( df, "Remote end closed connection" ); 303 304 if( ret < 4 )305 {306 imcb_log( df->ic, "WARNING: DCC SEND: receiver sent only %d bytes instead of 4, shouldn't happen too often!", ret );303 304 /* How likely is it that a 32-bit integer gets split accross 305 packet boundaries? Chances are rarely 0 so let's be sure. */ 306 if( ( df->acked_len = ( df->acked_len + ret ) % 4 ) > 0 ) 307 307 return TRUE; 308 } 309 310 ASSERTSOCKOP( ret = recv( fd, &bytes_received, sizeof( bytes_received ), 0 ), "Receiving" ); 311 if( ret != 4 ) 312 return dcc_abort( df, "MSG_PEEK'ed 4, but can only dequeue %d bytes", ret ); 313 314 bytes_received = ntohl( bytes_received ); 308 309 df->acked = ntohl( df->acked ); 315 310 316 311 /* If any of this is actually happening, the receiver should buy a new IRC client */ 317 312 318 if ( bytes_received > df->bytes_sent )319 return dcc_abort( df, "Receiver magically received more bytes than sent ( %d > %d ) (BUG at receiver?)", bytes_received, df->bytes_sent );320 321 if ( bytes_received < file->bytes_transferred )322 return dcc_abort( df, "Receiver lost bytes? ( has %d, had %d ) (BUG at receiver?)", bytes_received, file->bytes_transferred );313 if ( df->acked > df->bytes_sent ) 314 return dcc_abort( df, "Receiver magically received more bytes than sent ( %d > %d ) (BUG at receiver?)", df->acked, df->bytes_sent ); 315 316 if ( df->acked < file->bytes_transferred ) 317 return dcc_abort( df, "Receiver lost bytes? ( has %d, had %d ) (BUG at receiver?)", df->acked, file->bytes_transferred ); 323 318 324 file->bytes_transferred = bytes_received;319 file->bytes_transferred = df->acked; 325 320 326 321 if( file->bytes_transferred >= file->file_size ) { … … 412 407 done ) 413 408 { 414 int ack, ackret;415 ack = htonl( ft->bytes_transferred = df->bytes_sent );409 guint32 ack = htonl( ft->bytes_transferred = df->bytes_sent ); 410 int ackret; 416 411 417 412 ASSERTSOCKOP( ackret = send( fd, &ack, 4, 0 ), "Sending DCC ACK" ); -
dcc.h
r2e89256 r4ed9c8c 77 77 size_t bytes_sent; 78 78 79 /* 80 * Handle the wonderful sadly-not-deprecated ACKs. 81 */ 82 guint32 acked; 83 int acked_len; 84 79 85 /* imc's handle */ 80 86 file_transfer_t *ft;
Note: See TracChangeset
for help on using the changeset viewer.