[Fakeroot-commits] [SCM] fakeroot branch, upstream, updated. 08ed00124d8b6b445d3b91a9aa15eec638b02f05
Timo Savola
tsavola at movial.fi
Sun Nov 15 03:17:07 UTC 2009
The following commit has been merged in the upstream branch:
commit 38f86d230a18cdb0c3a6d00ac31b7cc2b383b81d
Author: Timo Savola <tsavola at movial.fi>
Date: Wed Oct 5 08:37:04 2005 +0000
TCP I/O functions fixed
Patch from Toni Timonen
git-archimport-id: fakeroot at packages.debian.org--fakeroot/fakeroot--main--0.0--patch-90
diff --git a/communicate.c b/communicate.c
index 65f87ed..cbccb23 100644
--- a/communicate.c
+++ b/communicate.c
@@ -548,6 +548,35 @@ void send_get_fakem(struct fake_msg *buf)
#else /* FAKEROOT_FAKENET */
+
+static size_t write_all(int fd,const void*buf,size_t count) {
+ ssize_t rc,remaining=count;
+ while(remaining>0) {
+ rc= write(fd, buf+(count-remaining), remaining);
+ if(rc<=0) {
+ if(remaining==count) return rc;
+ else fail("partial write");
+ } else {
+ remaining-=rc;
+ }
+ }
+ return count-remaining;
+}
+
+static size_t read_all(int fd,void *buf,size_t count) {
+ ssize_t rc,remaining=count;
+ while(remaining>0) {
+ rc = read(fd,buf+(count-remaining),remaining);
+ if(rc<=0) {
+ if(remaining==count) return rc;
+ else fail("partial read");
+ } else {
+ remaining-=rc;
+ }
+ }
+ return count-remaining;
+}
+
static void send_fakem_nr(const struct fake_msg *buf)
{
struct fake_msg fm;
@@ -565,7 +594,7 @@ static void send_fakem_nr(const struct fake_msg *buf)
while (1) {
ssize_t len;
- len = write(comm_sd, &fm, sizeof (fm));
+ len = write_all(comm_sd, &fm, sizeof (fm));
if (len > 0)
break;
@@ -596,7 +625,7 @@ static void get_fakem_nr(struct fake_msg *buf)
while (1) {
ssize_t len;
- len = read(comm_sd, buf, sizeof (struct fake_msg));
+ len = read_all(comm_sd, buf, sizeof (struct fake_msg));
if (len > 0)
break;
if (len == 0) {
--
fakeroot
More information about the Fakeroot-commits
mailing list