ret_len = send(ctx->control_sock, &cmd, sizeof(cmd), 0);
} while (ret_len < 0 && errno == EINTR);
if (ret_len < 0) {
- fprintf(stderr, "[error] Error sending cmd\n");
+ perror("[error] Error sending cmd");
ret = ret_len;
goto error;
}
ret_len = send(ctx->control_sock, &connect, sizeof(connect), 0);
} while (ret_len < 0 && errno == EINTR);
if (ret_len < 0) {
- fprintf(stderr, "[error] Error sending version\n");
+ perror("[error] Error sending version");
ret = ret_len;
goto error;
}
do {
ret_len = recv(ctx->control_sock, &connect, sizeof(connect), 0);
} while (ret_len < 0 && errno == EINTR);
+ if (ret_len == 0) {
+ fprintf(stderr, "[error] Remote side has closed connection\n");
+ ret = -1;
+ goto error;
+ }
if (ret_len < 0) {
- fprintf(stderr, "[error] Error receiving version\n");
+ perror("[error] Error receiving version");
ret = ret_len;
goto error;
}
ret_len = send(ctx->control_sock, &cmd, sizeof(cmd), 0);
} while (ret_len < 0 && errno == EINTR);
if (ret_len < 0) {
- fprintf(stderr, "[error] Error sending cmd\n");
+ perror("[error] Error sending cmd");
ret = ret_len;
goto error;
}
do {
ret_len = recv(ctx->control_sock, &list, sizeof(list), 0);
} while (ret_len < 0 && errno == EINTR);
+ if (ret_len == 0) {
+ fprintf(stderr, "[error] Remote side has closed connection\n");
+ ret = -1;
+ goto error;
+ }
if (ret_len < 0) {
- fprintf(stderr, "[error] Error receiving session list\n");
+ perror("[error] Error receiving session list");
ret = ret_len;
goto error;
}
do {
ret_len = recv(ctx->control_sock, &lsession, sizeof(lsession), 0);
} while (ret_len < 0 && errno == EINTR);
+ if (ret_len == 0) {
+ fprintf(stderr, "[error] Remote side has closed connection\n");
+ ret = -1;
+ goto error;
+ }
if (ret_len < 0) {
- fprintf(stderr, "[error] Error receiving session\n");
+ perror("[error] Error receiving session");
ret = ret_len;
goto error;
}
ret_len = send(ctx->control_sock, &cmd, sizeof(cmd), 0);
} while (ret_len < 0 && errno == EINTR);
if (ret_len < 0) {
- fprintf(stderr, "[error] Error sending cmd\n");
+ perror("[error] Error sending cmd");
ret = ret_len;
goto error;
}
ret_len = send(ctx->control_sock, &rq, sizeof(rq), 0);
} while (ret_len < 0 && errno == EINTR);
if (ret_len < 0) {
- fprintf(stderr, "[error] Error sending attach request\n");
+ perror("[error] Error sending attach request");
ret = ret_len;
goto error;
}
do {
ret_len = recv(ctx->control_sock, &rp, sizeof(rp), 0);
} while (ret_len < 0 && errno == EINTR);
+ if (ret_len == 0) {
+ fprintf(stderr, "[error] Remote side has closed connection\n");
+ ret = -1;
+ goto error;
+ }
if (ret_len < 0) {
- fprintf(stderr, "[error] Error receiving attach response\n");
+ perror("[error] Error receiving attach response");
ret = ret_len;
goto error;
}
ret = -LTTNG_VIEWER_ATTACH_UNK;
goto end;
case LTTNG_VIEWER_ATTACH_ALREADY:
- fprintf(stderr, "[error] Already a viewer attached\n");
+ fprintf(stderr, "[error] There is already a viewer attached to this session\n");
ret = -1;
goto end;
case LTTNG_VIEWER_ATTACH_NOT_LIVE:
do {
ret_len = recv(ctx->control_sock, &stream, sizeof(stream), 0);
} while (ret_len < 0 && errno == EINTR);
+ if (ret_len == 0) {
+ fprintf(stderr, "[error] Remote side has closed connection\n");
+ ret = -1;
+ goto error;
+ }
if (ret_len < 0) {
- fprintf(stderr, "[error] Error receiving stream\n");
+ perror("[error] Error receiving stream");
ret = ret_len;
goto error;
}
ret_len = send(ctx->control_sock, &cmd, sizeof(cmd), 0);
} while (ret_len < 0 && errno == EINTR);
if (ret_len < 0) {
- fprintf(stderr, "[error] Error sending cmd\n");
+ perror("[error] Error sending cmd");
ret = ret_len;
goto error;
}
ret_len = send(ctx->control_sock, &rq, sizeof(rq), 0);
} while (ret_len < 0 && errno == EINTR);
if (ret_len < 0) {
- fprintf(stderr, "[error] Error sending get_data_packet request\n");
+ perror("[error] Error sending get_data_packet request");
ret = ret_len;
goto error;
}
do {
ret_len = recv(ctx->control_sock, &rp, sizeof(rp), 0);
} while (ret_len < 0 && errno == EINTR);
+ if (ret_len == 0) {
+ fprintf(stderr, "[error] Remote side has closed connection\n");
+ ret = -1;
+ goto error;
+ }
if (ret_len < 0) {
- fprintf(stderr, "[error] Error receiving data response\n");
+ perror("[error] Error receiving data response");
ret = ret_len;
goto error;
}
/* unmap old base */
ret = munmap_align(pos->base_mma);
if (ret) {
- fprintf(stderr, "[error] Unable to unmap old base: %s.\n",
- strerror(errno));
+ perror("[error] Unable to unmap old base");
ret = -1;
goto error;
}
PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (pos->base_mma == MAP_FAILED) {
- fprintf(stderr, "[error] mmap error %s.\n",
- strerror(errno));
+ perror("[error] mmap error");
pos->base_mma = NULL;
ret = -1;
goto error;
mmap_align_addr(pos->base_mma), len,
MSG_WAITALL);
} while (ret_len < 0 && errno == EINTR);
+ if (ret_len == 0) {
+ fprintf(stderr, "[error] Remote side has closed connection\n");
+ ret = -1;
+ goto error;
+ }
if (ret_len < 0) {
- fprintf(stderr, "[error] Error receiving trace packet\n");
+ perror("[error] Error receiving trace packet");
ret = ret_len;
goto error;
}
ret_len = send(ctx->control_sock, &cmd, sizeof(cmd), 0);
} while (ret_len < 0 && errno == EINTR);
if (ret_len < 0) {
- fprintf(stderr, "[error] Error sending cmd\n");
+ perror("[error] Error sending cmd");
ret = ret_len;
goto error;
}
ret_len = send(ctx->control_sock, &rq, sizeof(rq), 0);
} while (ret_len < 0 && errno == EINTR);
if (ret_len < 0) {
- fprintf(stderr, "[error] Error sending get_metadata request\n");
+ perror("[error] Error sending get_metadata request");
ret = ret_len;
goto error;
}
do {
ret_len = recv(ctx->control_sock, &rp, sizeof(rp), 0);
} while (ret_len < 0 && errno == EINTR);
+ if (ret_len == 0) {
+ fprintf(stderr, "[error] Remote side has closed connection\n");
+ ret = -1;
+ goto error;
+ }
if (ret_len < 0) {
- fprintf(stderr, "[error] Error receiving metadata response\n");
+ perror("[error] Error receiving metadata response");
ret = ret_len;
goto error;
}
do {
ret_len = recv(ctx->control_sock, data, len, MSG_WAITALL);
} while (ret_len < 0 && errno == EINTR);
+ if (ret_len == 0) {
+ fprintf(stderr, "[error] Remote side has closed connection\n");
+ ret = -1;
+ free(data);
+ goto error;
+ }
if (ret_len < 0) {
- fprintf(stderr, "[error] Error receiving trace packet\n");
+ perror("[error] Error receiving trace packet");
ret = ret_len;
free(data);
goto error;
ret_len = send(ctx->control_sock, &cmd, sizeof(cmd), 0);
} while (ret_len < 0 && errno == EINTR);
if (ret_len < 0) {
- fprintf(stderr, "[error] Error sending cmd\n");
+ perror("[error] Error sending cmd");
ret = ret_len;
goto error;
}
ret_len = send(ctx->control_sock, &rq, sizeof(rq), 0);
} while (ret_len < 0 && errno == EINTR);
if (ret_len < 0) {
- fprintf(stderr, "[error] Error sending get_next_index request\n");
+ perror("[error] Error sending get_next_index request");
ret = ret_len;
goto error;
}
do {
ret_len = recv(ctx->control_sock, &rp, sizeof(rp), 0);
} while (ret_len < 0 && errno == EINTR);
+ if (ret_len == 0) {
+ fprintf(stderr, "[error] Remote side has closed connection\n");
+ ret = -1;
+ goto error;
+ }
if (ret_len < 0) {
- fprintf(stderr, "[error] Error receiving index response\n");
+ perror("[error] Error receiving index response");
ret = ret_len;
goto error;
}
ret_len = send(ctx->control_sock, &cmd, sizeof(cmd), 0);
} while (ret_len < 0 && errno == EINTR);
if (ret_len < 0) {
- fprintf(stderr, "[error] Error sending cmd\n");
+ perror("[error] Error sending cmd");
ret = ret_len;
goto error;
}
do {
ret_len = recv(ctx->control_sock, &resp, sizeof(resp), 0);
} while (ret_len < 0 && errno == EINTR);
+ if (ret_len == 0) {
+ fprintf(stderr, "[error] Remote side has closed connection\n");
+ ret = -1;
+ goto error;
+ }
if (ret_len < 0) {
- fprintf(stderr, "[error] Error receiving create session reply\n");
+ perror("[error] Error receiving create session reply");
ret = ret_len;
goto error;
}
ret_len = send(ctx->control_sock, &cmd, sizeof(cmd), 0);
} while (ret_len < 0 && errno == EINTR);
if (ret_len < 0) {
- fprintf(stderr, "[error] Error sending cmd\n");
+ perror("[error] Error sending cmd");
ret = ret_len;
goto error;
}
ret_len = send(ctx->control_sock, &rq, sizeof(rq), 0);
} while (ret_len < 0 && errno == EINTR);
if (ret_len < 0) {
- fprintf(stderr, "[error] Error sending get_new_streams request\n");
+ perror("[error] Error sending get_new_streams request");
ret = ret_len;
goto error;
}
do {
ret_len = recv(ctx->control_sock, &rp, sizeof(rp), 0);
} while (ret_len < 0 && errno == EINTR);
+ if (ret_len == 0) {
+ fprintf(stderr, "[error] Remote side has closed connection\n");
+ ret = -1;
+ goto error;
+ }
if (ret_len < 0) {
- fprintf(stderr, "[error] Error receiving get_new_streams response\n");
+ perror("[error] Error receiving get_new_streams response");
ret = ret_len;
goto error;
}
do {
ret_len = recv(ctx->control_sock, &stream, sizeof(stream), 0);
} while (ret_len < 0 && errno == EINTR);
+ if (ret_len == 0) {
+ fprintf(stderr, "[error] Remote side has closed connection\n");
+ ret = -1;
+ goto error;
+ }
if (ret_len < 0) {
- fprintf(stderr, "[error] Error receiving stream\n");
+ perror("[error] Error receiving stream");
ret = ret_len;
goto error;
}