+2014-04-01 Richard Biener <rguenther@suse.de>
+
+ * simple-object.c (simple_object_internal_write): Handle
+ EINTR and short writes.
+
2014-03-28 Richard Biener <rguenther@suse.de>
* simple-object.c (simple_object_internal_read): Handle
const unsigned char *buffer, size_t size,
const char **errmsg, int *err)
{
- ssize_t wrote;
-
if (lseek (descriptor, offset, SEEK_SET) < 0)
{
*errmsg = "lseek";
return 0;
}
- wrote = write (descriptor, buffer, size);
- if (wrote < 0)
+ do
{
- *errmsg = "write";
- *err = errno;
- return 0;
+ ssize_t wrote = write (descriptor, buffer, size);
+ if (wrote == 0)
+ break;
+ else if (wrote > 0)
+ {
+ buffer += wrote;
+ size -= wrote;
+ }
+ else if (errno != EINTR)
+ {
+ *errmsg = "write";
+ *err = errno;
+ return 0;
+ }
}
+ while (size > 0);
- if ((size_t) wrote < size)
+ if (size > 0)
{
*errmsg = "short write";
*err = 0;