* of bytes. The callback will continue to be
* invoked until it indicates the end of the source
* has been reached by returning 0. A return value
- * of -1 at any time will abort the send operation
+ * of -1 at any time will abort the send operation.
+ *
+ * Please note that for more accurate error reporting the
+ * callback should set appropriate errno on failure.
*
* Returns the number of bytes filled, 0 upon end
* of file, or -1 upon error
* This function should not adjust the current position within
* the file.
*
+ * Please note that for more accurate error reporting the
+ * callback should set appropriate errno on failure.
+ *
* Returns 0 on success,
* -1 upon error
*/
* processing the hole in the stream source and then return.
* A return value of -1 at any time will abort the send operation.
*
+ * Please note that for more accurate error reporting the
+ * callback should set appropriate errno on failure.
+ *
* Returns 0 on success,
* -1 upon error.
*/
* has been reached. A return value of -1 at any time
* will abort the receive operation
*
+ * Please note that for more accurate error reporting the
+ * callback should set appropriate errno on failure.
+ *
* Returns the number of bytes consumed or -1 upon
* error
*/
* hole in the stream target and then return. A return value of
* -1 at any time will abort the receive operation.
*
+ * Please note that for more accurate error reporting the
+ * callback should set appropriate errno on failure.
+ *
* Returns 0 on success,
* -1 upon error
*/
*
* Returns -1 upon any error, with virStreamAbort() already
* having been called, so the caller need only call
- * virStreamFree()
+ * virStreamFree().
*/
int
virStreamSendAll(virStreamPtr stream,
if (VIR_ALLOC_N(bytes, want) < 0)
goto cleanup;
+ errno = 0;
for (;;) {
int got, offset = 0;
+
got = (handler)(stream, bytes, want, opaque);
- if (got < 0)
+ if (got < 0) {
+ if (errno == 0)
+ errno = EIO;
+ virReportSystemError(errno, "%s", _("send handler failed"));
goto cleanup;
+ }
if (got == 0)
break;
while (offset < got) {
if (VIR_ALLOC_N(bytes, bufLen) < 0)
goto cleanup;
+ errno = 0;
for (;;) {
int inData, got, offset = 0;
long long sectionLen;
const unsigned int skipFlags = 0;
if (!dataLen) {
- if (holeHandler(stream, &inData, §ionLen, opaque) < 0)
+ if (holeHandler(stream, &inData, §ionLen, opaque) < 0) {
+ if (errno == 0)
+ errno = EIO;
+ virReportSystemError(errno, "%s", _("send holeHandler failed"));
goto cleanup;
+ }
if (!inData && sectionLen) {
if (virStreamSendHole(stream, sectionLen, skipFlags) < 0)
goto cleanup;
if (skipHandler(stream, sectionLen, opaque) < 0) {
+ if (errno == 0)
+ errno = EIO;
virReportSystemError(errno, "%s",
- _("unable to skip hole"));
+ _("send skipHandler failed"));
goto cleanup;
}
continue;
want = dataLen;
got = (handler)(stream, bytes, want, opaque);
- if (got < 0)
+ if (got < 0) {
+ if (errno == 0)
+ errno = EIO;
+ virReportSystemError(errno, "%s",
+ _("send handler failed"));
goto cleanup;
+ }
if (got == 0)
break;
while (offset < got) {
if (VIR_ALLOC_N(bytes, want) < 0)
goto cleanup;
+ errno = 0;
for (;;) {
int got, offset = 0;
+
got = virStreamRecv(stream, bytes, want);
if (got < 0)
goto cleanup;
while (offset < got) {
int done;
done = (handler)(stream, bytes + offset, got - offset, opaque);
- if (done < 0)
+ if (done < 0) {
+ if (errno == 0)
+ errno = EIO;
+ virReportSystemError(errno, "%s",
+ _("recv handler failed"));
goto cleanup;
+ }
offset += done;
}
}
if (VIR_ALLOC_N(bytes, want) < 0)
goto cleanup;
+ errno = 0;
for (;;) {
int got, offset = 0;
long long holeLen;
if (virStreamRecvHole(stream, &holeLen, holeFlags) < 0)
goto cleanup;
- if (holeHandler(stream, holeLen, opaque) < 0)
+ if (holeHandler(stream, holeLen, opaque) < 0) {
+ if (errno == 0)
+ errno = EIO;
+ virReportSystemError(errno, "%s", _("recv holeHandler failed"));
goto cleanup;
+ }
continue;
} else if (got < 0) {
goto cleanup;
while (offset < got) {
int done;
done = (handler)(stream, bytes + offset, got - offset, opaque);
- if (done < 0)
+ if (done < 0) {
+ if (errno == 0)
+ errno = EIO;
+ virReportSystemError(errno, "%s", _("recv handler failed"));
goto cleanup;
+ }
offset += done;
}
}