pthread_mutex_t lock;
struct list_head subbuf_list;
struct tip_subbuf *leftover_ts;
- unsigned int leftover_ts_offset;
};
struct device_information {
struct pollfd pfd = { .fd = tip->fd, .events = POLLIN };
do {
- poll(&pfd, 1, 10);
+ poll(&pfd, 1, 100);
if (pfd.revents & POLLIN)
break;
if (tip->ofile_stdout)
static int get_subbuf(struct thread_information *tip)
{
struct tip_subbuf *ts;
- int ts_size, ret;
-
- /*
- * live tracing should get a lower count to make it more "realtime"
- */
- if (tip->ofile_stdout)
- ts_size = 1024;
- else
- ts_size = buf_size;
+ int ret;
ts = malloc(sizeof(*ts));
- ts->buf = malloc(ts_size);
- ts->max_len = ts_size;
+ ts->buf = malloc(buf_size);
+ ts->max_len = buf_size;
- ret = read_data(tip, ts->buf, ts_size);
+ ret = read_data(tip, ts->buf, ts->max_len);
if (ret > 0) {
ts->len = ret;
tip_fd_lock(tip);
if (tip->leftover_ts) {
struct tip_subbuf *prev_ts = tip->leftover_ts;
- offset = tip->leftover_ts_offset;
- if (offset + prev_ts->len + ts->len > prev_ts->max_len) {
+ if (prev_ts->len + ts->len > prev_ts->max_len) {
prev_ts->max_len += ts->len;
prev_ts->buf = realloc(prev_ts->buf, prev_ts->max_len);
}
- memcpy(prev_ts->buf + offset + ts->len, ts->buf, ts->len);
+ memcpy(prev_ts->buf + prev_ts->len, ts->buf, ts->len);
prev_ts->len += ts->len;
free(ts->buf);
*/
if (offset != ts->len) {
tip->leftover_ts = ts;
- tip->leftover_ts_offset = offset;
+ ts->len -= offset;
+ memmove(ts->buf, ts->buf + offset, ts->len);
} else {
free(ts->buf);
free(ts);
{
struct device_information *dip;
struct thread_information *tip;
- int i, j, events, ret, all_exited;
+ int i, j, events, ret, tips_running;
while (!is_done()) {
events = 0;
*/
do {
events = 0;
- all_exited = 0;
+ tips_running = 0;
for_each_dip(dip, i) {
for_each_tip(dip, tip, j) {
ret = write_tip_events(tip);
if (ret > 0)
events += ret;
- all_exited += !tip->exited;
+ tips_running += !tip->exited;
}
}
usleep(10);
- } while (events || !all_exited);
+ } while (events || tips_running);
}
static int start_threads(struct device_information *dip)
tip->cpu = j;
tip->device = dip;
tip->events_processed = 0;
+ pthread_mutex_init(&tip->lock, NULL);
INIT_LIST_HEAD(&tip->subbuf_list);
tip->leftover_ts = NULL;
- tip->leftover_ts_offset = 0;
if (pipeline) {
tip->ofile = fdopen(STDOUT_FILENO, "w");