summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
e8be5f4)
Using clean_exit everywhere in lttng now and adding
the session daemon disconnect to that clean exit function.
Also fix the recv <= 0 for process client msg on the
session daemon side in order to not send back empty data.
Signed-off-by: David Goulet <david.goulet@polymtl.ca>
extern int lttng_create_session(char *name, uuid_t *session_id);
extern int lttng_destroy_session(uuid_t *uuid);
extern int lttng_connect_sessiond(void);
extern int lttng_create_session(char *name, uuid_t *session_id);
extern int lttng_destroy_session(uuid_t *uuid);
extern int lttng_connect_sessiond(void);
+extern int lttng_disconnect_sessiond(void);
extern int lttng_set_tracing_group(const char *name);
extern int lttng_check_session_daemon(void);
extern const char *lttng_get_readable_code(int code);
extern int lttng_set_tracing_group(const char *name);
extern int lttng_check_session_daemon(void);
extern const char *lttng_get_readable_code(int code);
+/*
+ * lttng_disconnect_sessiond
+ *
+ * Clean disconnect the session daemon.
+ */
+int lttng_disconnect_sessiond(void)
+{
+ int ret = 0;
+
+ if (connected) {
+ ret = lttcomm_close_unix_sock(sessiond_socket);
+ sessiond_socket = 0;
+ connected = 0;
+ }
+
+ return ret;
+}
+
/*
* lttng_set_current_session_uuid
*
/*
* lttng_set_current_session_uuid
*
+
+/*
+ * lttcomm_close_unix_sock
+ *
+ * Shutdown cleanly a unix socket.
+ */
+int lttcomm_close_unix_sock(int sock)
+{
+ int ret;
+
+ /* Shutdown receptions and transmissions */
+ ret = shutdown(sock, SHUT_RDWR);
+ if (ret < 0) {
+ perror("shutdown");
+ }
+
+ return ret;
+}
extern int lttcomm_connect_unix_sock(const char *pathname);
extern int lttcomm_accept_unix_sock(int sock);
extern int lttcomm_listen_unix_sock(int sock);
extern int lttcomm_connect_unix_sock(const char *pathname);
extern int lttcomm_accept_unix_sock(int sock);
extern int lttcomm_listen_unix_sock(int sock);
+extern int lttcomm_close_unix_sock(int sock);
extern ssize_t lttcomm_recv_unix_sock(int sock, void *buf, size_t len);
extern ssize_t lttcomm_send_unix_sock(int sock, void *buf, size_t len);
extern const char *lttcomm_get_readable_code(enum lttcomm_return_code code);
extern ssize_t lttcomm_recv_unix_sock(int sock, void *buf, size_t len);
extern ssize_t lttcomm_send_unix_sock(int sock, void *buf, size_t len);
extern const char *lttcomm_get_readable_code(enum lttcomm_return_code code);
* request of the client.
*/
ret = lttcomm_recv_unix_sock(sock, &lsm, sizeof(lsm));
* request of the client.
*/
ret = lttcomm_recv_unix_sock(sock, &lsm, sizeof(lsm));
{
switch (sig) {
case SIGPIPE:
{
switch (sig) {
case SIGPIPE:
case SIGINT:
case SIGTERM:
cleanup();
case SIGINT:
case SIGTERM:
cleanup();
void clean_exit(int code)
{
DBG("Clean exit");
void clean_exit(int code)
{
DBG("Clean exit");
+ if (lttng_disconnect_sessiond() < 0) {
+ ERR("Session daemon disconnect failed.");
+ }
ret = parse_args(argc, (const char **) argv);
if (ret < 0) {
ret = parse_args(argc, (const char **) argv);
if (ret < 0) {
+ clean_exit(EXIT_FAILURE);
}
ret = set_signal_handler();
if (ret < 0) {
}
ret = set_signal_handler();
if (ret < 0) {
}
if (opt_tracing_group != NULL) {
}
if (opt_tracing_group != NULL) {
DBG("Kernel tracing activated");
if (getuid() != 0) {
ERR("%s must be setuid root", progname);
DBG("Kernel tracing activated");
if (getuid() != 0) {
ERR("%s must be setuid root", progname);
* If no, a daemon will be spawned.
*/
if (opt_no_sessiond == 0 && (check_ltt_sessiond() < 0)) {
* If no, a daemon will be spawned.
*/
if (opt_no_sessiond == 0 && (check_ltt_sessiond() < 0)) {
+ clean_exit(EXIT_FAILURE);
}
ret = process_client_opt();
if (ret < 0) {
}
ret = process_client_opt();
if (ret < 0) {