Be nice with the CPU in fd_{read,write}_all()
This commit is contained in:
14
glorytun.c
14
glorytun.c
@@ -263,7 +263,14 @@ static ssize_t fd_read_all (int fd, void *data, size_t size)
|
||||
{
|
||||
size_t done = 0;
|
||||
|
||||
struct pollfd pollfd = {
|
||||
.fd = fd,
|
||||
.events = POLLIN,
|
||||
};
|
||||
|
||||
while (done<size) {
|
||||
poll(&pollfd, 1, -1);
|
||||
|
||||
ssize_t ret = fd_read(fd, data+done, size-done);
|
||||
|
||||
if (!ret)
|
||||
@@ -280,7 +287,14 @@ static ssize_t fd_write_all (int fd, const void *data, size_t size)
|
||||
{
|
||||
size_t done = 0;
|
||||
|
||||
struct pollfd pollfd = {
|
||||
.fd = fd,
|
||||
.events = POLLOUT,
|
||||
};
|
||||
|
||||
while (done<size) {
|
||||
poll(&pollfd, 1, -1);
|
||||
|
||||
ssize_t ret = fd_write(fd, data+done, size-done);
|
||||
|
||||
if (!ret)
|
||||
|
||||
Reference in New Issue
Block a user