Commit Graph

12 Commits

Author SHA1 Message Date
Karel Zak 782cc33a02 build-sys: fix sendfile use
* OSX uses different prototype
* include file is not covered by HAVE_SYS_SENDIFLE_H

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-09 15:30:06 +01:00
Egor Chelak 418eb09482 read_all: return 0 when EOF occurs after 0 bytes
Originally it would return -1 (without setting errno) if the fd was
already at EOF when you called read_all.

This is already fixed in sendfile_all.

Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
2020-11-09 07:19:51 +02:00
Egor Chelak 212bde6cf7 ul_copy_file: handle EAGAIN and EINTR
I did this by implementing a function called sendfile_all() similar to
read_all()/write_all().

The manpage for sendfile doesn't mention EINTR, but I decided to check
it anyway, just in case.

Suggested-by: Karel Zak <kzak@redhat.com>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
2020-11-09 07:19:39 +02:00
Karel Zak b2ce7d5827 include/all-io: remove unnecessary condition [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 16:00:13 +02:00
Karel Zak 34708190d1 include/all-io: const cleanup
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 14:53:25 +02:00
Karel Zak 1e0cd7ae9e include/all-io: read_all() don't retry on EOF
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-20 11:48:09 +02:00
Karel Zak a5bd793996 include/c.h: prefer nanosleep() over usleep()
Let's use nanosleep() although if usleep() exists. The nanosleep
function does no interact with signals and other timers.

The patch introduces xusleep() as replacement to libc (or our fallback)
usleep(). Yes, we don't want to use struct timespec + nanosleep()
everywhere in code as nano-time resolution is useless for us.

The patch also enlarges delays in some busy wait loops. It seems
enough to try read/write 4x per second.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-24 13:04:14 +01:00
Karel Zak 0f23ee0c85 include: cleanup copyright headers
We use the code from include/ and lib/ on many places, so use public
domain if possible or LGPL for code copied from libs.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-08 15:10:17 +01:00
Karel Zak 2a31396a9c include/c: move usleep() fallback to c.h
To make it available everywhere in code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-22 11:03:09 +02:00
Sami Kerola 667d375ea8 include: fix void pointer arithmetics warnings
all-io.h:18:9: warning: pointer of type 'void *' used in arithmetic [-pedantic]
all-io.h:38:9: warning: pointer of type 'void *' used in arithmetic [-pedantic]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 19:51:35 +02:00
Petr Uzel f80e9bc30a libuuid: move read_all to include/all-io.h
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:32:36 +02:00
Petr Uzel e12c9866b5 include: rename writeall.h to all-io.h
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:32:27 +02:00