X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=libustcomm%2Fustcomm.c;h=2e490b56b7f3b9bde99a3db8ade8b66f99f090da;hb=7958de40dc52ee7b1bda6b74eec7f3e60fbb6591;hp=6e93a0266bc9c7dd68c933fd330b60c6b6f62217;hpb=9ebf7bd4b473a1935bf086d8165c088f778730b7;p=lttng-ust.git diff --git a/libustcomm/ustcomm.c b/libustcomm/ustcomm.c index 6e93a026..2e490b56 100644 --- a/libustcomm/ustcomm.c +++ b/libustcomm/ustcomm.c @@ -390,13 +390,24 @@ static int init_named_socket(const char *name, char **path_out) return -1; } +/* + * Return value: + * 0: Success, but no reply because recv() returned 0 + * 1: Success + * -1: Error + * + * On error, the error message is printed, except on + * ECONNRESET, which is normal when the application dies. + */ + int ustcomm_send_request(struct ustcomm_connection *conn, const char *req, char **reply) { int result; - result = send(conn->fd, req, strlen(req), 0); + result = send(conn->fd, req, strlen(req), MSG_NOSIGNAL); if(result == -1) { - PERROR("send"); + if(errno != EPIPE) + PERROR("send"); return -1; } @@ -406,7 +417,8 @@ int ustcomm_send_request(struct ustcomm_connection *conn, const char *req, char *reply = (char *) malloc(MSG_MAX+1); result = recv(conn->fd, *reply, MSG_MAX, 0); if(result == -1) { - PERROR("recv"); + if(errno != ECONNRESET) + PERROR("recv"); return -1; } else if(result == 0) { @@ -494,7 +506,7 @@ int ustcomm_init_app(pid_t pid, struct ustcomm_app *handle) handle->server.listen_fd = init_named_socket(name, &(handle->server.socketpath)); if(handle->server.listen_fd < 0) { - ERR("error initializing named socket"); + ERR("Error initializing named socket (%s). Check that directory exists and that it is writable.", name); goto free_name; } free(name);