ssize_t zero_copy_queued;
ssize_t zero_copy_sent;
bool blocking;
- /**
- * This flag indicates whether any new data was successfully sent with
- * zerocopy since the last qio_channel_socket_flush() call.
- */
- bool new_zero_copy_sent_success;
+ bool zero_copy_fallback;
};
* If not implemented, acts as a no-op, and returns 0.
*
* Returns -1 if any error is found,
- * 1 if every send failed to use zero copy.
- * 0 otherwise.
+ * 1 if at least one send failed to use zero copy.
+ * 0 if every send successfully used zero copy.
*/
int qio_channel_flush(QIOChannel *ioc,
sioc->zero_copy_queued = 0;
sioc->zero_copy_sent = 0;
sioc->blocking = false;
- sioc->new_zero_copy_sent_success = false;
+ sioc->zero_copy_fallback = false;
ioc = QIO_CHANNEL(sioc);
qio_channel_set_feature(ioc, QIO_CHANNEL_FEATURE_SHUTDOWN);
/* No errors, count successfully finished sendmsg()*/
sioc->zero_copy_sent += serr->ee_data - serr->ee_info + 1;
- /* If any sendmsg() succeeded using zero copy, mark zerocopy success */
- if (serr->ee_code != SO_EE_CODE_ZEROCOPY_COPIED) {
- sioc->new_zero_copy_sent_success = true;
+ if (serr->ee_code == SO_EE_CODE_ZEROCOPY_COPIED) {
+ /* If any sendmsg() fell back to a copy, mark fallback as true */
+ sioc->zero_copy_fallback = true;
}
}
return ret;
}
- if (sioc->new_zero_copy_sent_success) {
- sioc->new_zero_copy_sent_success = false;
- return 0;
+ if (sioc->zero_copy_fallback) {
+ sioc->zero_copy_fallback = false;
+ return 1;
}
- return 1;
+ return 0;
}
#endif /* QEMU_MSG_ZEROCOPY */