send_msg = &_send_msg;
recv_msg = &_recv_msg;
- result = ustcomm_pack_buffer_info(send_hdr, send_msg,
+ result = ustcomm_pack_buffer_info(send_hdr, send_msg, buf->trace,
buf->channel, buf->channel_cpu);
if (result < 0) {
return result;
recv_hdr = &_recv_hdr;
send_msg = &_send_msg;
- result = ustcomm_pack_buffer_info(send_hdr, send_msg,
+ result = ustcomm_pack_buffer_info(send_hdr, send_msg, buf->trace,
buf->channel, buf->channel_cpu);
if (result < 0) {
return result;
send_msg = &_send_msg;
recv_msg = &_recv_msg;
- result = ustcomm_pack_buffer_info(send_hdr, send_msg,
+ result = ustcomm_pack_buffer_info(send_hdr, send_msg, buf->trace,
buf->channel, buf->channel_cpu);
if (result < 0) {
ERR("Failed to pack buffer info");
send_msg = &_send_msg;
recv_msg = &_recv_msg;
- result = ustcomm_pack_channel_info(send_hdr, send_msg,
+ result = ustcomm_pack_channel_info(send_hdr, send_msg, buf->trace,
buf->channel);
if (result < 0) {
return result;
recv_hdr = &_recv_hdr;
send_msg = &_send_msg;
- result = ustcomm_pack_buffer_info(send_hdr, send_msg,
+ result = ustcomm_pack_buffer_info(send_hdr, send_msg, buf->trace,
buf->channel, buf->channel_cpu);
if (result < 0) {
return result;
struct buffer_info *connect_buffer(struct libustd_instance *instance, pid_t pid,
- const char *channel, int channel_cpu)
+ const char *trace, const char *channel,
+ int channel_cpu)
{
struct buffer_info *buf;
int result;
return NULL;
}
+ buf->trace = strdup(trace);
+ if (!buf->trace) {
+ goto free_buf;
+ }
+
buf->channel = strdup(channel);
if (!buf->channel) {
- goto free_buf;
+ goto free_buf_trace;
}
result = asprintf(&buf->name, "%s_%d", channel, channel_cpu);
free_buf_channel:
free(buf->channel);
+free_buf_trace:
+ free(buf->trace);
+
free_buf:
free(buf);
return NULL;
struct consumer_thread_args {
pid_t pid;
+ const char *trace;
const char *channel;
int channel_cpu;
struct libustd_instance *instance;
goto end;
}
- buf = connect_buffer(args->instance, args->pid,
+ buf = connect_buffer(args->instance, args->pid, args->trace,
args->channel, args->channel_cpu);
if(buf == NULL) {
ERR("failed to connect to buffer");
}
int start_consuming_buffer(struct libustd_instance *instance, pid_t pid,
- const char *channel, int channel_cpu)
+ const char *trace, const char *channel,
+ int channel_cpu)
{
pthread_t thr;
struct consumer_thread_args *args;
}
args->pid = pid;
+ args->trace = strdup(trace);
args->channel = strdup(channel);
args->channel_cpu = channel_cpu;
args->instance = instance;
- DBG("beginning2 of start_consuming_buffer: args: pid %d bufname %s_%d",
- args->pid, args->channel, args->channel_cpu);
+ DBG("beginning2 of start_consuming_buffer: args: pid %d trace %s"
+ " bufname %s_%d", args->pid, args->channel, args->channel_cpu);
result = pthread_create(&thr, NULL, consumer_thread, args);
if(result == -1) {
ERR("pthread_detach failed");
return -1;
}
- DBG("end of start_consuming_buffer: args: pid %d bufname %s_%d",
- args->pid, args->channel, args->channel_cpu);
+ DBG("end of start_consuming_buffer: args: pid %d trace %s "
+ "bufname %s_%d", args->pid, args->channel, args->channel_cpu);
return 0;
}
return;
}
- DBG("Going to consume buffer %s_%d in process %d",
- buf_inf->channel, buf_inf->ch_cpu, buf_inf->pid);
+ DBG("Going to consume trace %s buffer %s_%d in process %d",
+ buf_inf->trace, buf_inf->channel, buf_inf->ch_cpu,
+ buf_inf->pid);
result = start_consuming_buffer(instance, buf_inf->pid,
+ buf_inf->trace,
buf_inf->channel,
buf_inf->ch_cpu);
if (result < 0) {
goto close_epoll;
}
- INIT_LIST_HEAD(&instance->connections);
+ CDS_INIT_LIST_HEAD(&instance->connections);
free(name);