Show
Ignore:
Timestamp:
03/24/08 10:10:24 (16 years ago)
Author:
ppalmers
Message:

try to detect and survive ISO thread hangup

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/libieee1394/IsoHandlerManager.cpp

    r967 r978  
    5959    } 
    6060    m_poll_nfds_shadow = 0; 
     61 
     62    #ifdef DEBUG 
     63    m_last_loop_entry = 0; 
     64    m_successive_short_loops = 0; 
     65    #endif 
     66 
    6167    return true; 
    6268} 
     
    128134    unsigned int m_poll_timeout = 10; 
    129135 
     136    #ifdef DEBUG 
     137    uint64_t now = m_manager.get1394Service().getCurrentTimeAsUsecs(); 
     138    int diff = now - m_last_loop_entry; 
     139    if(diff < 100) { 
     140        debugOutputExtreme(DEBUG_LEVEL_VERY_VERBOSE, 
     141                           "(%p) short loop detected (%d usec), cnt: %d\n", 
     142                           this, diff, m_successive_short_loops); 
     143        m_successive_short_loops++; 
     144        if(m_successive_short_loops > 100) { 
     145            debugError("Shutting down runaway thread\n"); 
     146            return false; 
     147        } 
     148    } else { 
     149        // reset the counter 
     150        m_successive_short_loops = 0; 
     151    } 
     152    m_last_loop_entry = now; 
     153    #endif 
     154 
    130155    // if some other thread requested a shadow map update, do it 
    131156    if(request_update) { 
    132157        updateShadowMapHelper(); 
    133158        DEC_ATOMIC(&request_update); // ack the update 
     159        assert(request_update >= 0); 
    134160    } 
    135161 
     
    217243        if(m_poll_fds_shadow[i].revents) { 
    218244            debugOutput(DEBUG_LEVEL_VERY_VERBOSE, 
    219                         "received events: %08X for (%d/%d, %p, %s)\n", 
    220                         m_poll_fds_shadow[i].revents, 
     245                        "(%p) received events: %08X for (%d/%d, %p, %s)\n", 
     246                        this, m_poll_fds_shadow[i].revents, 
    221247                        i, m_poll_nfds_shadow, 
    222248                        m_IsoHandler_map_shadow[i], 
     
    233259            // there might be some error condition 
    234260            if (m_poll_fds_shadow[i].revents & POLLERR) { 
    235                 debugWarning("error on fd for %d\n",i); 
     261                debugWarning("(%p) error on fd for %d\n", this, i); 
    236262            } 
    237263            if (m_poll_fds_shadow[i].revents & POLLHUP) { 
    238                 debugWarning("hangup on fd for %d\n",i); 
     264                debugWarning("(%p) hangup on fd for %d\n", this, i); 
    239265            } 
    240266        } 
  • trunk/libffado/src/libieee1394/IsoHandlerManager.h

    r967 r978  
    8787        void updateShadowMapHelper(); 
    8888 
     89#ifdef DEBUG 
     90        uint64_t m_last_loop_entry; 
     91        int m_successive_short_loops; 
     92#endif 
     93 
    8994        // debug stuff 
    9095        DECLARE_DEBUG_MODULE;