mirror of
https://github.com/NixOS/nix.git
synced 2025-11-25 03:39:36 +01:00
* Argh, another short-write problem. Added wrappers around
read()/write() to fix this once and for all.
This commit is contained in:
parent
667a6afb9d
commit
7984cfc7c1
9 changed files with 46 additions and 36 deletions
11
src/store.cc
11
src/store.cc
|
|
@ -15,8 +15,7 @@ struct CopySink : DumpSink
|
|||
int fd;
|
||||
virtual void operator () (const unsigned char * data, unsigned int len)
|
||||
{
|
||||
if (write(fd, (char *) data, len) != (ssize_t) len)
|
||||
throw SysError("writing to child");
|
||||
writeFull(fd, data, len);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -24,13 +23,9 @@ struct CopySink : DumpSink
|
|||
struct CopySource : RestoreSource
|
||||
{
|
||||
int fd;
|
||||
virtual void operator () (const unsigned char * data, unsigned int len)
|
||||
virtual void operator () (unsigned char * data, unsigned int len)
|
||||
{
|
||||
ssize_t res = read(fd, (char *) data, len);
|
||||
if (res == -1)
|
||||
throw SysError("reading from parent");
|
||||
if (res != (ssize_t) len)
|
||||
throw Error("not enough data available on parent");
|
||||
readFull(fd, data, len);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue