Changeset 2e89256
- Timestamp:
- 2010-03-21T13:20:20Z (15 years ago)
- Branches:
- master
- Children:
- 4ed9c8c
- Parents:
- aed152f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
dcc.c
raed152f r2e89256 26 26 #include "ft.h" 27 27 #include "dcc.h" 28 #include <poll.h>29 28 #include <netinet/tcp.h> 30 29 #include <regex.h> … … 260 259 261 260 /* 262 * Checks poll(), same for receiving and sending263 */264 gboolean dcc_poll( dcc_file_transfer_t *df, int fd, short *revents )265 {266 struct pollfd pfd = { .fd = fd, .events = POLLHUP|POLLERR|POLLIN|POLLOUT };267 268 ASSERTSOCKOP( poll( &pfd, 1, 0 ), "poll()" )269 270 if( pfd.revents & POLLERR )271 {272 int sockerror;273 socklen_t errlen = sizeof( sockerror );274 275 if ( getsockopt( fd, SOL_SOCKET, SO_ERROR, &sockerror, &errlen ) )276 return dcc_abort( df, "getsockopt() failed, unknown socket error (weird!)" );277 278 return dcc_abort( df, "Socket error: %s", strerror( sockerror ) );279 }280 281 if( pfd.revents & POLLHUP )282 return dcc_abort( df, "Remote end closed connection" );283 284 *revents = pfd.revents;285 286 return TRUE;287 }288 289 /*290 261 * After setup, the transfer itself is handled entirely by this function. 291 262 * There are basically four things to handle: connect, receive, send, and error. … … 295 266 dcc_file_transfer_t *df = data; 296 267 file_transfer_t *file = df->ft; 297 short revents; 298 299 if( !dcc_poll( df, fd, &revents ) ) 300 return FALSE; 301 302 if( ( revents & POLLIN ) && 268 269 if( ( cond & GAIM_INPUT_READ ) && 303 270 ( file->status & FT_STATUS_LISTENING ) ) 304 271 { … … 325 292 } 326 293 327 if( revents & POLLIN)294 if( cond & GAIM_INPUT_READ ) 328 295 { 329 296 int bytes_received; … … 414 381 dcc_file_transfer_t *df = data; 415 382 file_transfer_t *ft = df->ft; 416 short revents; 417 418 if( !dcc_poll( df, fd, &revents ) ) 419 return FALSE; 420 421 if( ( revents & POLLOUT ) && 383 384 if( ( cond & GAIM_INPUT_WRITE ) && 422 385 ( ft->status & FT_STATUS_CONNECTING ) ) 423 386 { … … 430 393 } 431 394 432 if( revents & POLLIN)395 if( cond & GAIM_INPUT_READ ) 433 396 { 434 397 int ret, done;
Note: See TracChangeset
for help on using the changeset viewer.