X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=libustcomm%2Fustcomm.c;h=8b459df32975499a4c1137ee379fb9d40600b231;hb=34b460e6b2180ef5e42cdc0455b3ac1a0afd912c;hp=6e93a0266bc9c7dd68c933fd330b60c6b6f62217;hpb=d9ce395d9a7d0d6628d6f495e4bacb912abfcba9;p=lttng-ust.git diff --git a/libustcomm/ustcomm.c b/libustcomm/ustcomm.c index 6e93a026..8b459df3 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 != ECONNRESET) + 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) {