int rotate_truncate_stream(struct relay_stream *stream)
{
int ret, new_fd;
+ off_t lseek_ret;
uint64_t diff, pos = 0;
char buf[FILE_COPY_BUFFER_SIZE];
* Rewind the current tracefile to the position at which the rotation
* should have occured.
*/
- ret = lseek(stream->stream_fd->fd,
+ lseek_ret = lseek(stream->stream_fd->fd,
stream->pos_after_last_complete_data_index, SEEK_SET);
- if (ret < 0) {
+ if (lseek_ret < 0) {
PERROR("seek truncate stream");
+ ret = -1;
goto end;
}
goto end;
}
- if (stream->prev_seq < stream->rotate_at_seq_num) {
+ if (stream->prev_seq < stream->rotate_at_seq_num ||
+ stream->prev_seq == -1ULL) {
DBG("Stream %" PRIu64 " no yet ready for rotation",
stream->stream_handle);
goto end;
{
struct relay_session *session = conn->session;
struct lttcomm_relayd_rotate_pending msg;
- struct lttcomm_relayd_generic_reply reply;
+ struct lttcomm_relayd_rotate_pending_reply reply;
struct lttng_ht_iter iter;
struct relay_stream *stream;
int ret = 0;
send_reply:
rcu_read_unlock();
memset(&reply, 0, sizeof(reply));
- reply.ret_code = htobe32(rotate_pending ? 1 : 0);
+ reply.generic.ret_code = htobe32((uint32_t) LTTNG_OK);
+ reply.is_pending = (uint8_t) !!rotate_pending;
network_ret = conn->sock->ops->sendmsg(conn->sock, &reply,
sizeof(reply), 0);
if (network_ret < (ssize_t) sizeof(reply)) {