extern void lttng_ring_buffer_client_discard_rt_exit(void);
extern void lttng_ring_buffer_metadata_client_exit(void);
+ssize_t lttng_ust_read(int fd, void *buf, size_t len)
+{
+ ssize_t ret;
+ size_t copied = 0, to_copy = len;
+
+ do {
+ ret = read(fd, buf + copied, to_copy);
+ if (ret > 0) {
+ copied += ret;
+ to_copy -= ret;
+ }
+ } while ((ret > 0 && to_copy > 0)
+ || (ret < 0 && errno == EINTR));
+ if (ret > 0) {
+ ret = copied;
+ }
+ return ret;
+}
/*
* Returns the HOME directory path. Caller MUST NOT free(3) the returned
* pointer.
}
if (str_timeout)
constructor_delay_ms = strtol(str_timeout, NULL, 10);
+ /* All negative values are considered as "-1". */
+ if (constructor_delay_ms < -1)
+ constructor_delay_ms = -1;
return constructor_delay_ms;
}
if (ust_lock()) {
ret = -LTTNG_UST_ERR_EXITING;
- goto end;
+ goto error;
}
ops = objd_ops(lum->handle);
if (!ops) {
ret = -ENOENT;
- goto end;
+ goto error;
}
switch (lum->cmd) {
}
ret = len;
free(bytecode);
- goto end;
+ goto error;
} else {
DBG("incorrect filter data message size: %zd", len);
ret = -EINVAL;
free(bytecode);
- goto end;
+ goto error;
}
}
bytecode->bc.len = lum->u.filter.data_size;
}
ret = len;
free(node);
- goto end;
+ goto error;
} else {
DBG("Incorrect exclusion data message size: %zd", len);
ret = -EINVAL;
free(node);
- goto end;
+ goto error;
}
}
if (ops->cmd) {
goto error;
}
ret = len;
- goto end;
+ goto error;
} else {
DBG("incorrect channel data message size: %zd", len);
ret = -EINVAL;
- goto end;
+ goto error;
}
}
args.channel.chan_data = chan_data;
&args.stream.shm_fd,
&args.stream.wakeup_fd);
if (ret) {
- goto end;
+ goto error;
}
if (ops->cmd)
ret = ops->cmd(lum->handle, lum->cmd,
break;
}
-end:
lur.handle = lum->handle;
lur.cmd = lum->cmd;
lur.ret_val = ret;
long page_size;
page_size = sysconf(_SC_PAGE_SIZE);
- if (page_size > 0) {
+ if (page_size <= 0) {
+ if (!page_size) {
+ errno = EINVAL;
+ }
+ PERROR("Error in sysconf(_SC_PAGE_SIZE)");
+ } else {
ret = munmap(sock_info->wait_shm_mmap, page_size);
if (ret) {
ERR("Error unmapping wait shm");
char *wait_shm_mmap;
page_size = sysconf(_SC_PAGE_SIZE);
- if (page_size < 0) {
+ if (page_size <= 0) {
+ if (!page_size) {
+ errno = EINVAL;
+ }
+ PERROR("Error in sysconf(_SC_PAGE_SIZE)");
goto error;
}
* deals with a killed or broken session daemon.
*/
sleep(5);
+ } else {
+ has_waited = 1;
}
- has_waited = 1;
prev_connect_failed = 0;
}
print_cmd(lum.cmd, lum.handle);
ret = handle_message(sock_info, sock, &lum);
if (ret) {
- ERR("Error handling message for %s socket", sock_info->name);
+ ERR("Error handling message for %s socket",
+ sock_info->name);
+ /*
+ * Close socket if protocol error is
+ * detected.
+ */
+ goto end;
}
continue;
default: