Ignore:
Timestamp:
Sep 23, 2008 9:40:11 AM (16 years ago)
Author:
bennylp
Message:

More ticket #622: some more fixes to ioqueue_epoll, it passes pjlib-test now (thanks Simon Chen for the patch!)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/ioqueue_epoll.c

    r2300 r2308  
    11/* $Id$ */ 
    22/*  
    3  * Copyright (C)2003-2008 Benny Prijono <benny@prijono.org> 
     3 * Copyright (C)2003-2007 Benny Prijono <benny@prijono.org> 
    44 * 
    55 * This program is free software; you can redistribute it and/or modify 
     
    172172 
    173173    unsigned            max, count; 
    174     pj_ioqueue_key_t    hlist; 
     174    //pj_ioqueue_key_t  hlist; 
     175    pj_ioqueue_key_t    active_list;     
    175176    int                 epfd; 
    176     struct epoll_event *events; 
    177     struct queue       *queue; 
     177    //struct epoll_event *events; 
     178    //struct queue       *queue; 
    178179 
    179180#if PJ_IOQUEUE_HAS_SAFE_UNREG 
    180181    pj_mutex_t         *ref_cnt_mutex; 
    181     pj_ioqueue_key_t    active_list; 
    182182    pj_ioqueue_key_t    closing_list; 
    183183    pj_ioqueue_key_t    free_list; 
     
    235235    ioqueue->max = max_fd; 
    236236    ioqueue->count = 0; 
    237     pj_list_init(&ioqueue->hlist); 
     237    pj_list_init(&ioqueue->active_list); 
    238238 
    239239#if PJ_IOQUEUE_HAS_SAFE_UNREG 
     
    254254    pj_list_init(&ioqueue->free_list); 
    255255    pj_list_init(&ioqueue->closing_list); 
    256     pj_list_init(&ioqueue->active_list); 
    257256 
    258257 
     
    292291    } 
    293292     
    294     ioqueue->events = pj_pool_calloc(pool, max_fd, sizeof(struct epoll_event)); 
     293    /*ioqueue->events = pj_pool_calloc(pool, max_fd, sizeof(struct epoll_event)); 
    295294    PJ_ASSERT_RETURN(ioqueue->events != NULL, PJ_ENOMEM); 
    296295 
    297296    ioqueue->queue = pj_pool_calloc(pool, max_fd, sizeof(struct queue)); 
    298297    PJ_ASSERT_RETURN(ioqueue->queue != NULL, PJ_ENOMEM); 
    299  
     298   */ 
    300299    PJ_LOG(4, ("pjlib", "epoll I/O Queue created (%p)", ioqueue)); 
    301300 
     
    432431     
    433432    /* Register */ 
    434     pj_list_insert_before(&ioqueue->hlist, key); 
     433    pj_list_insert_before(&ioqueue->active_list, key); 
    435434    ++ioqueue->count; 
    436435 
     
    608607    int i, count, processed; 
    609608    int msec; 
    610     struct epoll_event *events = ioqueue->events; 
    611     struct queue *queue = ioqueue->queue; 
     609    //struct epoll_event *events = ioqueue->events; 
     610    //struct queue *queue = ioqueue->queue; 
     611    struct epoll_event events[PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL]; 
     612    struct queue queue[PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL]; 
    612613    pj_timestamp t1, t2; 
    613614     
     
    619620    pj_get_timestamp(&t1); 
    620621  
    621     count = os_epoll_wait( ioqueue->epfd, events, ioqueue->max, msec); 
     622    //count = os_epoll_wait( ioqueue->epfd, events, ioqueue->max, msec); 
     623    count = os_epoll_wait( ioqueue->epfd, events, PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL, msec); 
    622624    if (count == 0) { 
    623625#if PJ_IOQUEUE_HAS_SAFE_UNREG 
     
    656658         */ 
    657659        if ((events[i].events & EPOLLIN) &&  
    658             (key_has_pending_read(h) || key_has_pending_accept(h))) { 
     660            (key_has_pending_read(h) || key_has_pending_accept(h)) && !IS_CLOSING(h) ) { 
    659661 
    660662#if PJ_IOQUEUE_HAS_SAFE_UNREG 
     
    669671         * Check for writeability. 
    670672         */ 
    671         if ((events[i].events & EPOLLOUT) && key_has_pending_write(h)) { 
     673        if ((events[i].events & EPOLLOUT) && key_has_pending_write(h) && !IS_CLOSING(h)) { 
    672674 
    673675#if PJ_IOQUEUE_HAS_SAFE_UNREG 
     
    683685         * Check for completion of connect() operation. 
    684686         */ 
    685         if ((events[i].events & EPOLLOUT) && (h->connecting)) { 
     687        if ((events[i].events & EPOLLOUT) && (h->connecting) && !IS_CLOSING(h)) { 
    686688 
    687689#if PJ_IOQUEUE_HAS_SAFE_UNREG 
     
    697699         * Check for error condition. 
    698700         */ 
    699         if (events[i].events & EPOLLERR && (h->connecting)) { 
     701        if (events[i].events & EPOLLERR && (h->connecting) && !IS_CLOSING(h)) { 
    700702                 
    701703#if PJ_IOQUEUE_HAS_SAFE_UNREG 
Note: See TracChangeset for help on using the changeset viewer.