{
int ret;
- ret = write(wpipe, "!", 1);
+ do {
+ ret = write(wpipe, "!", 1);
+ } while (ret < 0 && errno == EINTR);
if (ret < 0) {
PERROR("write poll pipe");
}
* call is blocking so we can be assured that the data will be read
* at some point in time or wait to the end of the world :)
*/
- ret = write(relay_cmd_pipe[1], relay_cmd,
- sizeof(struct relay_command));
+ do {
+ ret = write(relay_cmd_pipe[1], relay_cmd,
+ sizeof(struct relay_command));
+ } while (ret < 0 && errno == EINTR);
free(relay_cmd);
if (ret < 0) {
PERROR("write cmd pipe");
goto end;
}
- ret = write(metadata_stream->fd, metadata_struct->payload,
- payload_size);
+ do {
+ ret = write(metadata_stream->fd, metadata_struct->payload,
+ payload_size);
+ } while (ret < 0 && errno == EINTR);
if (ret < (payload_size)) {
ERR("Relay error writing metadata on file");
ret = -1;
goto end;
}
- ret = write(stream->fd, data_buffer, data_size);
+ do {
+ ret = write(stream->fd, data_buffer, data_size);
+ } while (ret < 0 && errno == EINTR);
if (ret < data_size) {
ERR("Relay error writing data to file");
ret = -1;
{
int ret;
- ret = write(wpipe, "!", 1);
+ do {
+ ret = write(wpipe, "!", 1);
+ } while (ret < 0 && errno == EINTR);
if (ret < 0) {
PERROR("write poll pipe");
}
{
int ret;
consumer_quit = 1;
- ret = write(ctx->consumer_should_quit[1], "4", 1);
+ do {
+ ret = write(ctx->consumer_should_quit[1], "4", 1);
+ } while (ret < 0 && errno == EINTR);
if (ret < 0) {
perror("write consumer quit");
}
*/
do {
ret = write(ctx->consumer_poll_pipe[1], "", 1);
- } while (ret == -1UL && errno == EINTR);
+ } while (ret < 0 && errno == EINTR);
rcu_unregister_thread();
return NULL;
}
do {
ret = write(outfd, (void *) &metadata_id,
sizeof(stream->relayd_stream_id));
- if (ret < 0) {
- PERROR("write metadata stream id");
- written = ret;
- goto end;
- }
- } while (errno == EINTR);
+ } while (ret < 0 && errno == EINTR);
+ if (ret < 0) {
+ PERROR("write metadata stream id");
+ written = ret;
+ goto end;
+ }
DBG("Metadata stream id %zu written before data",
stream->relayd_stream_id);
/*
}
while (len > 0) {
- ret = write(outfd, stream->mmap_base + mmap_offset, len);
+ do {
+ ret = write(outfd, stream->mmap_base + mmap_offset, len);
+ } while (ret < 0 && errno == EINTR);
if (ret < 0) {
- if (errno == EINTR) {
- /* restart the interrupted system call */
- continue;
- } else {
- perror("Error in file write");
- if (written == 0) {
- written = ret;
- }
- goto end;
+ perror("Error in file write");
+ if (written == 0) {
+ written = ret;
}
+ goto end;
} else if (ret > len) {
perror("Error in file write");
written += ret;
*/
pthread_mutex_lock(&relayd->ctrl_sock_mutex);
+ metadata_id = htobe64(stream->relayd_stream_id);
do {
- metadata_id = htobe64(stream->relayd_stream_id);
ret = write(ctx->consumer_thread_pipe[1],
(void *) &metadata_id,
sizeof(stream->relayd_stream_id));
- if (ret < 0) {
- PERROR("write metadata stream id");
- written = ret;
- goto end;
- }
- } while (errno == EINTR);
+ } while (ret < 0 && errno == EINTR);
+ if (ret < 0) {
+ PERROR("write metadata stream id");
+ written = ret;
+ goto end;
+ }
DBG("Metadata stream id %zu written before data",
stream->relayd_stream_id);
}
*/
do {
ret = write(ctx->consumer_poll_pipe[1], "", 1);
- } while (ret == -1UL && errno == EINTR);
+ } while (ret < 0 && errno == EINTR);
end_nosignal:
return 0;
}
writeleft = sizeof(sendret);
index = 0;
do {
- writelen = write(data->retval_pipe, &sendret.c[index],
- writeleft);
+ do {
+ writelen = write(data->retval_pipe, &sendret.c[index],
+ writeleft);
+ } while (writelen < 0 && errno == EINTR);
if (writelen < 0) {
PERROR("write");
return EXIT_FAILURE;
do {
ret = write(outfd, (void *) &metadata_id,
sizeof(stream->relayd_stream_id));
- if (ret < 0) {
- PERROR("write metadata stream id");
- written = ret;
- goto end;
- }
- } while (errno == EINTR);
+ } while (ret < 0 && errno == EINTR);
+ if (ret < 0) {
+ PERROR("write metadata stream id");
+ written = ret;
+ goto end;
+ }
DBG("Metadata stream id %zu written before data",
stream->relayd_stream_id);
}
}
while (len > 0) {
- ret = write(outfd, stream->mmap_base + mmap_offset, len);
+ do {
+ ret = write(outfd, stream->mmap_base + mmap_offset, len);
+ } while (ret < 0 && errno == EINTR);
if (ret < 0) {
- if (errno == EINTR) {
- /* restart the interrupted system call */
- continue;
- } else {
- PERROR("Error in file write");
- if (written == 0) {
- written = ret;
- }
- goto end;
+ PERROR("Error in file write");
+ if (written == 0) {
+ written = ret;
}
+ goto end;
} else if (ret > len) {
PERROR("ret %ld > len %lu", ret, len);
written += ret;
*/
do {
ret = write(ctx->consumer_poll_pipe[1], "", 1);
- } while (ret == -1UL && errno == EINTR);
+ } while (ret < 0 && errno == EINTR);
end_nosignal:
return 0;
}