struct tip_subbuf *ts = malloc(sizeof(*ts));
struct stat sb;
- ts->buf = malloc(buf_size);
ts->max_len = maxlen;
ts->buf = NULL;
tip->read_data = read_data_file;
}
-static int start_threads(struct device_information *dip)
+static int tip_open_output(struct device_information *dip,
+ struct thread_information *tip)
{
- struct thread_information *tip;
- int j, pipeline = output_name && !strcmp(output_name, "-");
+ int pipeline = output_name && !strcmp(output_name, "-");
int mode, vbuf_size;
char op[64];
- for_each_tip(dip, tip, j) {
- tip->cpu = j;
- tip->device = dip;
- tip->events_processed = 0;
- memset(&tip->fifo, 0, sizeof(tip->fifo));
- tip->leftover_ts = NULL;
-
- if (pipeline) {
- tip->ofile = fdopen(STDOUT_FILENO, "w");
- tip->ofile_stdout = 1;
- tip->ofile_mmap = 0;
- mode = _IOLBF;
- vbuf_size = 512;
- } else {
- fill_ofname(op, dip->buts_name, tip->cpu);
- tip->ofile = fopen(op, "w+");
- tip->ofile_stdout = 0;
- tip->ofile_mmap = 1;
- mode = _IOFBF;
- vbuf_size = OFILE_BUF;
- }
+ if (net_mode == Net_client) {
+ tip->ofile = NULL;
+ tip->ofile_stdout = 0;
+ tip->ofile_mmap = 0;
+ vbuf_size = 0;
+ } else if (pipeline) {
+ tip->ofile = fdopen(STDOUT_FILENO, "w");
+ tip->ofile_stdout = 1;
+ tip->ofile_mmap = 0;
+ mode = _IOLBF;
+ vbuf_size = 512;
+ } else {
+ fill_ofname(op, dip->buts_name, tip->cpu);
+ tip->ofile = fopen(op, "w+");
+ tip->ofile_stdout = 0;
+ tip->ofile_mmap = 1;
+ mode = _IOFBF;
+ vbuf_size = OFILE_BUF;
+ }
- if (tip->ofile == NULL) {
- perror(op);
- return 1;
- }
+ if (net_mode != Net_client && tip->ofile == NULL) {
+ perror(op);
+ return 1;
+ }
+ if (vbuf_size) {
tip->ofile_buffer = malloc(vbuf_size);
if (setvbuf(tip->ofile, tip->ofile_buffer, mode, vbuf_size)) {
perror("setvbuf");
close_thread(tip);
return 1;
}
+ }
+
+ fill_ops(tip);
+ return 0;
+}
- fill_ops(tip);
+static int start_threads(struct device_information *dip)
+{
+ struct thread_information *tip;
+ int j;
+
+ for_each_tip(dip, tip, j) {
+ tip->cpu = j;
+ tip->device = dip;
+ tip->events_processed = 0;
+ memset(&tip->fifo, 0, sizeof(tip->fifo));
+ tip->leftover_ts = NULL;
+
+ if (tip_open_output(dip, tip))
+ return 1;
if (pthread_create(&tip->thread, NULL, thread_main, tip)) {
perror("pthread_create");
*/
for (i = 0; i < ncpus; i++) {
struct thread_information *tip = &dip->threads[i];
- char op[64];
tip->cpu = i;
- tip->ofile_stdout = 0;
- tip->ofile_mmap = 1;
tip->device = dip;
- fill_ops(tip);
-
- fill_ofname(op, dip->buts_name, tip->cpu);
-
- tip->ofile = fopen(op, "w+");
- if (!tip->ofile) {
- perror("fopen");
+ if (tip_open_output(dip, tip))
return NULL;
- }
}
return dip;