Show
Ignore:
Timestamp:
01/13/08 09:17:58 (14 years ago)
Author:
ppalmers
Message:

fix single ISO thread operation (1394 stack seems to be thread-unsafe)

Files:

Legend:

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

    r833 r841  
    191191    if(m_Client) { 
    192192        bool result = m_Client->tryWaitForSignal(); 
    193         //debugOutput(DEBUG_LEVEL_VERY_VERBOSE, " returns %d\n", result); 
     193        //debugOutput(DEBUG_LEVEL_VERBOSE, " returns %d\n", result); 
    194194        return result; 
    195195    } else { 
  • trunk/libffado/src/libieee1394/IsoHandlerManager.cpp

    r833 r841  
    9898{ 
    9999    debugOutput( DEBUG_LEVEL_VERY_VERBOSE, "updating shadow vars...\n"); 
    100     unsigned int i; 
    101     m_poll_nfds_shadow = m_IsoHandlers.size(); 
    102     if(m_poll_nfds_shadow > ISOHANDLERMANAGER_MAX_ISO_HANDLERS_PER_PORT) { 
    103         debugWarning("Too much ISO Handlers in manager...\n"); 
    104         m_poll_nfds_shadow = ISOHANDLERMANAGER_MAX_ISO_HANDLERS_PER_PORT; 
    105     } 
    106     for (i = 0; i < m_poll_nfds_shadow; i++) { 
     100    unsigned int i, cnt, max; 
     101    max = m_IsoHandlers.size(); 
     102    for (i = 0, cnt = 0; i < max; i++) { 
    107103        IsoHandler *h = m_IsoHandlers.at(i); 
    108104        assert(h); 
    109         m_IsoHandler_map_shadow[i] = h; 
    110  
    111         m_poll_fds_shadow[i].fd = h->getFileDescriptor(); 
    112         m_poll_fds_shadow[i].revents = 0; 
    113105        if (h->isEnabled()) { 
    114             m_poll_fds_shadow[i].events = POLLIN; 
    115         } else { 
    116             m_poll_fds_shadow[i].events = 0; 
    117         } 
    118     } 
     106            // receive handlers are always poll'ed 
     107            // transmit handlers only when the client is ready 
     108            if (h->getType() == IsoHandler::eHT_Receive || h->tryWaitForClient()) { 
     109                m_IsoHandler_map_shadow[cnt] = h; 
     110                m_poll_fds_shadow[cnt].fd = h->getFileDescriptor(); 
     111                m_poll_fds_shadow[cnt].revents = 0; 
     112                m_poll_fds_shadow[cnt].events = POLLIN; 
     113                cnt++; 
     114            } else { 
     115                debugOutput(DEBUG_LEVEL_VERBOSE, "skipped handler %p\n", h); 
     116            } 
     117        } 
     118        if(cnt > ISOHANDLERMANAGER_MAX_ISO_HANDLERS_PER_PORT) { 
     119            debugWarning("Too much ISO Handlers in manager...\n"); 
     120            break; 
     121        } 
     122    } 
     123    m_poll_nfds_shadow = cnt; 
    119124    debugOutput( DEBUG_LEVEL_VERY_VERBOSE, " updated shadow vars...\n"); 
    120125} 
     
    143148    // bypass if no handlers are registered 
    144149    if (m_poll_nfds_shadow == 0) { 
    145         debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "bypass iterate since no handlers registered\n"); 
     150        debugOutput(DEBUG_LEVEL_VERY_VERBOSE, "bypass iterate since no handlers to poll\n"); 
    146151        usleep(m_poll_timeout * 1000); 
    147152        return true;