#include <lib/base/buffer.h>
#include <lib/base/eerror.h>
-#include <stdio.h>
+#include <cerrno>
+#include <cstdio>
+#include <cstring>
#include <unistd.h>
-#include <errno.h>
void eIOBuffer::removeblock()
{
while (len)
{
int tc=len;
- int r;
+ int r=0;
if (buffer.empty() || (allocationsize == buffer.back().len))
addblock();
if (tc > allocationsize-buffer.back().len)
tc=allocationsize-buffer.back().len;
r=::read(fd, buffer.back().data+buffer.back().len, tc);
buffer.back().len+=r;
- len-=r;
if (r < 0)
{
- if (errno != EWOULDBLOCK)
- eDebug("read: %m");
- r=0;
+ if (errno != EWOULDBLOCK && errno != EBUSY && errno != EINTR)
+ eDebug("couldn't read: %m");
+ }
+ else
+ {
+ len-=r;
+ re+=r;
+ if (r != tc)
+ break;
}
- re+=r;
- if (r != tc)
- break;
}
return re;
}
w=::write(fd, buffer.front().data+ptr, tc);
if (w < 0)
{
- if (errno != EWOULDBLOCK)
+ if (errno != EWOULDBLOCK && errno != EBUSY && errno != EINTR)
eDebug("write: %m");
w=0;
}