X-Git-Url: http://git.lttng.org/?p=ust.git;a=blobdiff_plain;f=libustcomm%2Fustcomm.c;h=3b53471ac6d69c81acd1379351d985b9b8ed177b;hp=e773f7189fe313f78f0704f1ad907730a715aa38;hb=803a4f584bbc64ff44173ced627636f9e6db6618;hpb=79cb25368d3d2069c7189c45ccb751c9f9fcc59d diff --git a/libustcomm/ustcomm.c b/libustcomm/ustcomm.c index e773f71..3b53471 100644 --- a/libustcomm/ustcomm.c +++ b/libustcomm/ustcomm.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -378,8 +379,7 @@ static int init_named_socket(const char *name, char **path_out) } if(path_out) { - *path_out = ""; - *path_out = strdupa(addr.sun_path); + *path_out = strdup(addr.sun_path); } return fd; @@ -539,6 +539,32 @@ free_name: return retval; } +void ustcomm_fini_app(struct ustcomm_app *handle) +{ + int result; + struct stat st; + + /* Destroy socket */ + ERR("socket path is: %s", handle->server.socketpath); + result = stat(handle->server.socketpath, &st); + if(result == -1) { + PERROR("stat (%s)", handle->server.socketpath); + return; + } + + /* Paranoid check before deleting. */ + result = S_ISSOCK(st.st_mode); + if(!result) { + ERR("The socket we are about to delete is not a socket."); + return; + } + + result = unlink(handle->server.socketpath); + if(result == -1) { + PERROR("unlink"); + } +} + static char *find_tok(char *str) { while(*str == ' ') {