Beispiel #1
0
int BufferedOS::writevEx(IOVec &vec, int avoidCache)
{
    assert(m_pOS != NULL);
    int ret;
    if (!m_buf.empty())
    {
        int oldLen = vec.len();
        m_buf.iovInsert(vec);
        //TEST: DEBUG Code
        //ret = 0;
        ret = m_pOS->writev(vec.get(), vec.len());
        vec.pop_front(vec.len() - oldLen);
        if (ret > 0)
        {
            int pop = ret;
            if (pop > m_buf.size())
                pop = m_buf.size();
            m_buf.pop_front(pop);
            ret -= pop;
        }
    }
    else
        //TEST: DEBUG Code
        //ret = 0;
        ret = m_pOS->writev(vec.get(), vec.len());
    if (ret >= avoidCache)
        ret = m_buf.cache(vec.get(), vec.len(), ret);
    //LS_DBG_H( "bufferedOS::writev() return %d, %d bytes in cache\n", ret, m_buf.size());
    return ret;
}
int BufferedOS::writevEx( IOVec &vec, int avoidCache )
{
    assert( m_pOS != NULL );
    int ret;
    if ( !m_buf.empty() )
    {
        int oldLen = vec.len();
        m_buf.iov_insert( vec );
        //FIXME: DEBUG Code
        //ret = 0;
        ret = m_pOS->writev( vec );
        vec.pop_front( vec.len() - oldLen );
        if ( ret > 0 )
        {
            int pop = ret;
            if ( pop > m_buf.size() )
                pop = m_buf.size();
            m_buf.pop_front( pop );
            ret -= pop;
        }
    }
    else
        //FIXME: DEBUG Code
        //ret = 0;
        ret = m_pOS->writev( vec );
    if ( ret >= avoidCache )
    {
        ret = m_buf.cache( vec.get(), vec.len(), ret );
    }
    //if ( D_ENABLED( DL_MORE ) )
    //    LOG_D(( "bufferedOS::writev() return %d, %d bytes in cache\n", ret, m_buf.size() ));
    return ret;
}