}
#undef net_Write
-/* Write exact amount requested */
+/**
+ * Writes data to a file descriptor.
+ * This blocks until all data is written or an error occurs.
+ *
+ * This function is a cancellation point if p_vs is NULL.
+ * This function is not cancellation-safe if p_vs is not NULL.
+ *
+ * @return the total number of bytes written, or -1 if an error occurs
+ * before any data is written.
+ */
ssize_t net_Write( vlc_object_t *p_this, int fd, const v_socket_t *p_vs,
const void *restrict p_data, size_t i_data )
{
{ .fd = vlc_object_waitpipe (p_this), .events = POLLIN },
};
- if (ufd[1].fd == -1)
+ if (unlikely(ufd[1].fd == -1))
+ {
+ vlc_testcancel ();
return -1;
+ }
while( i_data > 0 )
{
i_total += val;
}
+ if (unlikely(i_data == 0))
+ vlc_testcancel (); /* corner case */
+
if ((i_total > 0) || (i_data == 0))
return i_total;