mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-17 03:42:48 +00:00
28 lines
461 B
C++
28 lines
461 B
C++
#include <Common/IO.h>
|
|
|
|
#include <unistd.h>
|
|
#include <errno.h>
|
|
#include <cstring>
|
|
|
|
bool writeRetry(int fd, const char * data, size_t size)
|
|
{
|
|
if (!size)
|
|
size = strlen(data);
|
|
|
|
while (size != 0)
|
|
{
|
|
ssize_t res = ::write(fd, data, size);
|
|
|
|
if ((-1 == res || 0 == res) && errno != EINTR)
|
|
return false;
|
|
|
|
if (res > 0)
|
|
{
|
|
data += res;
|
|
size -= res;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|