I have some source code of vibe.d, it does this in the same way,
and it works .
void read(ubyte[] dst)
{
checkConnected(false);
acquireReader();
scope(exit) releaseReader();
while (dst.length > 0) {
checkConnected(false);
logTrace("evbuffer_read %d bytes (fd %d)", dst.length,
m_ctx.socketfd);
auto nbytes = bufferevent_read(m_ctx.event, dst.ptr,
dst.length);
logTrace(" .. got %d bytes", nbytes);
dst = dst[nbytes .. $];
if( dst.length == 0 ) break;
checkConnected(false);
m_ctx.core.yieldForEvent();
}
logTrace("read data");
}