mirror of
https://gitlab.freedesktop.org/monado/monado.git
synced 2025-02-09 15:28:03 +00:00
ipc/server: Improve error messages
This commit is contained in:
parent
6d770336b7
commit
a4dcdf1f0b
|
@ -373,7 +373,10 @@ client_loop(volatile struct ipc_client_state *cs)
|
||||||
// We use epoll here to be able to timeout.
|
// We use epoll here to be able to timeout.
|
||||||
int ret = epoll_wait(epoll_fd, &event, 1, half_a_second_ms);
|
int ret = epoll_wait(epoll_fd, &event, 1, half_a_second_ms);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr, "ERROR: Failed epoll_wait '%i'\n", ret);
|
fprintf(stderr,
|
||||||
|
"ERROR: Failed epoll_wait '%i', disconnecting "
|
||||||
|
"client.\n",
|
||||||
|
ret);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,13 +387,16 @@ client_loop(volatile struct ipc_client_state *cs)
|
||||||
|
|
||||||
// Detect clients disconnecting gracefully.
|
// Detect clients disconnecting gracefully.
|
||||||
if (ret > 0 && (event.events & EPOLLHUP) != 0) {
|
if (ret > 0 && (event.events & EPOLLHUP) != 0) {
|
||||||
|
fprintf(stderr, "SERVER: Client disconnected\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally get the data that is waiting for us.
|
// Finally get the data that is waiting for us.
|
||||||
ssize_t len = recv(cs->ipc_socket_fd, &buf, IPC_BUF_SIZE, 0);
|
ssize_t len = recv(cs->ipc_socket_fd, &buf, IPC_BUF_SIZE, 0);
|
||||||
if (len < 4) {
|
if (len < 4) {
|
||||||
fprintf(stderr, "ERROR: Invalid packet received\n");
|
fprintf(stderr,
|
||||||
|
"ERROR: Invalid packet received, disconnecting "
|
||||||
|
"client.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -398,13 +404,13 @@ client_loop(volatile struct ipc_client_state *cs)
|
||||||
ipc_command_t *ipc_command = (uint32_t *)buf;
|
ipc_command_t *ipc_command = (uint32_t *)buf;
|
||||||
ret = ipc_dispatch(cs, ipc_command);
|
ret = ipc_dispatch(cs, ipc_command);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
fprintf(stderr, "ERROR: Failed to dispatch packet\n");
|
fprintf(stderr,
|
||||||
|
"ERROR: During packet handling, disconnecting "
|
||||||
|
"client.\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stderr, "SERVER: Client disconnected\n");
|
|
||||||
|
|
||||||
close(epoll_fd);
|
close(epoll_fd);
|
||||||
epoll_fd = -1;
|
epoll_fd = -1;
|
||||||
|
|
||||||
|
|
|
@ -498,5 +498,7 @@ ipc_server_main(int argc, char **argv)
|
||||||
teardown_all(s);
|
teardown_all(s);
|
||||||
free(s);
|
free(s);
|
||||||
|
|
||||||
|
fprintf(stderr, "SERVER: Exiting! '%i'\n", ret);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,10 +41,10 @@ ipc_reply(int socket, void *data, size_t len)
|
||||||
|
|
||||||
ssize_t ret = sendmsg(socket, &msg, MSG_NOSIGNAL);
|
ssize_t ret = sendmsg(socket, &msg, MSG_NOSIGNAL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf(
|
fprintf(stderr,
|
||||||
"sending plain message on socket %d failed with error: "
|
"ERROR: Sending plain message on socket %d failed with "
|
||||||
"%s\n",
|
"error: '%i' '%s'\n",
|
||||||
socket, strerror(errno));
|
socket, errno, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -77,8 +77,10 @@ ipc_reply_fds(int socket, void *data, size_t size, int *fds, uint32_t num_fds)
|
||||||
|
|
||||||
ssize_t ret = sendmsg(socket, &msg, MSG_NOSIGNAL);
|
ssize_t ret = sendmsg(socket, &msg, MSG_NOSIGNAL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf("sending %d FDs on socket %d failed with error: %s\n",
|
fprintf(stderr,
|
||||||
num_fds, socket, strerror(errno));
|
"ERROR: sending %d FDs on socket %d failed with error: "
|
||||||
|
"'%i' '%s'\n",
|
||||||
|
num_fds, socket, errno, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in a new issue