Changeset 2e89256


Ignore:
Timestamp:
2010-03-21T13:20:20Z (9 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
4ed9c8c
Parents:
aed152f
Message:

Remove dcc_poll() and just use the cond variable passed to I/O events.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • dcc.c

    raed152f r2e89256  
    2626#include "ft.h"
    2727#include "dcc.h"
    28 #include <poll.h>
    2928#include <netinet/tcp.h>
    3029#include <regex.h>
     
    260259
    261260/*
    262  * Checks poll(), same for receiving and sending
    263  */
    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 /*
    290261 * After setup, the transfer itself is handled entirely by this function.
    291262 * There are basically four things to handle: connect, receive, send, and error.
     
    295266        dcc_file_transfer_t *df = data;
    296267        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 ) &&
    303270            ( file->status & FT_STATUS_LISTENING ) )
    304271        {       
     
    325292        }
    326293
    327         if( revents & POLLIN )
     294        if( cond & GAIM_INPUT_READ )
    328295        {
    329296                int bytes_received;
     
    414381        dcc_file_transfer_t *df = data;
    415382        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 ) &&
    422385            ( ft->status & FT_STATUS_CONNECTING ) )
    423386        {
     
    430393        }
    431394
    432         if( revents & POLLIN )
     395        if( cond & GAIM_INPUT_READ )
    433396        {
    434397                int ret, done;
Note: See TracChangeset for help on using the changeset viewer.