aboutsummaryrefslogtreecommitdiff
path: root/src/util/disk.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-07-25 08:40:33 +0000
committerChristian Grothoff <christian@grothoff.org>2012-07-25 08:40:33 +0000
commit130185df47d89b3df36c8371fe18eccd76fca7fc (patch)
tree9caae429babe18d16daeb759edaf99aba0db1a95 /src/util/disk.c
parent1e6a3e621acb5e80fdf6b1ee971b67d24aa4cf03 (diff)
downloadgnunet-130185df47d89b3df36c8371fe18eccd76fca7fc.tar.gz
gnunet-130185df47d89b3df36c8371fe18eccd76fca7fc.zip
-preserve errno
Diffstat (limited to 'src/util/disk.c')
-rw-r--r--src/util/disk.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/util/disk.c b/src/util/disk.c
index 24a33d497..b4674c99b 100644
--- a/src/util/disk.c
+++ b/src/util/disk.c
@@ -843,7 +843,8 @@ GNUNET_DISK_file_read (const struct GNUNET_DISK_FileHandle * h, void *result,
843 */ 843 */
844ssize_t 844ssize_t
845GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle * h, 845GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle * h,
846 void *result, size_t len) 846 void *result,
847 size_t len)
847{ 848{
848 if (h == NULL) 849 if (h == NULL)
849 { 850 {
@@ -891,10 +892,14 @@ GNUNET_DISK_file_read_non_blocking (const struct GNUNET_DISK_FileHandle * h,
891 /* set to non-blocking, read, then set back */ 892 /* set to non-blocking, read, then set back */
892 flags = fcntl (h->fd, F_GETFL); 893 flags = fcntl (h->fd, F_GETFL);
893 if (0 == (flags & O_NONBLOCK)) 894 if (0 == (flags & O_NONBLOCK))
894 fcntl (h->fd, F_SETFL, flags | O_NONBLOCK); 895 (void) fcntl (h->fd, F_SETFL, flags | O_NONBLOCK);
895 ret = read (h->fd, result, len); 896 ret = read (h->fd, result, len);
896 if (0 == (flags & O_NONBLOCK)) 897 if (0 == (flags & O_NONBLOCK))
897 fcntl (h->fd, F_SETFL, flags); 898 {
899 int eno = errno;
900 (void) fcntl (h->fd, F_SETFL, flags);
901 errno = eno;
902 }
898 return ret; 903 return ret;
899#endif 904#endif
900} 905}