Note that there are some explanatory texts on larger screens.

plurals
  1. POaio_write failing on release builds
    text
    copied!<p>I'm using aio_write it is working in a debug build but not in release. I've checked the constructor that everything is initialized and I'm not getting any warnings about uninitialized variables. The class collects data that is to be written to disc in 16K chunks. If the data is less than 16K, it works, even in release builds. If the data is larger than 16K, only the first chunk is written. WriteBuffer::ContinueWriteToFile returns WriteFileState_Active indefinitely.</p> <p>WriteBuffer_posix.h:</p> <pre><code>class WriteBufferPlatformData { public: WriteBufferPlatformData(); ~WriteBufferPlatformData(); aiocb aioData; WriteBuffer::BufferVector::iterator currentBuffer; }; </code></pre> <p>WriteBuffer_posix.cpp:</p> <pre><code>WriteBufferPlatformData::WriteBufferPlatformData() : aioData(), currentBuffer() { memset(&amp;aioData,0,sizeof(aioData)); aioData.aio_fildes=-1; } WriteBufferPlatformData::~WriteBufferPlatformData() { if (0&lt;=aioData.aio_fildes) { close(aioData.aio_fildes); } } WriteBuffer::WriteFileState WriteBuffer::StartWriteToFile(const char * filename) { NYMPH_ASSERT(0&gt;m_platformData-&gt;aioData.aio_fildes); m_platformData-&gt;aioData.aio_fildes=open(filename,O_WRONLY|O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); NYMPH_ASSERT2(0&lt;=m_platformData-&gt;aioData.aio_fildes,"Could not open file for writing: %s (%d)",filename,errno); if (0&gt;m_platformData-&gt;aioData.aio_fildes) { return WriteFileState_Failed; } if (m_buffers.empty()) { close(m_platformData-&gt;aioData.aio_fildes); m_platformData-&gt;aioData.aio_fildes=-1; return WriteFileState_Complete; } m_isWriting=true; m_platformData-&gt;currentBuffer=m_buffers.begin(); return ContinueWriteToFile(); } WriteBuffer::WriteFileState WriteBuffer::ContinueWriteToFile() { NYMPH_ASSERT(0&lt;=m_platformData-&gt;aioData.aio_fildes); if (0!=m_platformData-&gt;aioData.aio_nbytes) { int writeErrno=aio_error(&amp;(m_platformData-&gt;aioData)); if (EINPROGRESS==writeErrno) { return WriteFileState_Active; } NYMPH_ASSERT(aio_return(&amp;(m_platformData-&gt;aioData))==m_platformData-&gt;aioData.aio_nbytes); m_platformData-&gt;aioData.aio_nbytes=0; ++(m_platformData-&gt;currentBuffer); if (m_buffers.end()==m_platformData-&gt;currentBuffer) { close(m_platformData-&gt;aioData.aio_fildes); m_platformData-&gt;aioData.aio_fildes=-1; return WriteFileState_Complete; } } if (0==m_platformData-&gt;aioData.aio_nbytes) { m_platformData-&gt;aioData.aio_buf=*(m_platformData-&gt;currentBuffer); if (m_buffers.back()==m_platformData-&gt;aioData.aio_buf) { m_platformData-&gt;aioData.aio_nbytes=m_offset; } else { m_platformData-&gt;aioData.aio_nbytes=kBufferSize; } m_platformData-&gt;aioData.aio_offset=lseek(m_platformData-&gt;aioData.aio_fildes,0,SEEK_END); if (0!=aio_write(&amp;(m_platformData-&gt;aioData))) { m_platformData-&gt;aioData.aio_nbytes=0; NYMPH_ASSERT(EAGAIN==errno); if (EAGAIN!=errno) { close(m_platformData-&gt;aioData.aio_fildes); m_platformData-&gt;aioData.aio_fildes=-1; return WriteFileState_Failed; } } } return WriteFileState_Active; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload