diff options
| -rw-r--r-- | parse-events.h | 1 | ||||
| -rw-r--r-- | trace-input.c | 10 |
2 files changed, 9 insertions, 2 deletions
diff --git a/parse-events.h b/parse-events.h index 400bc4c..bb2fe83 100644 --- a/parse-events.h +++ b/parse-events.h | |||
| @@ -44,6 +44,7 @@ struct record { | |||
| 44 | void *data; | 44 | void *data; |
| 45 | int cpu; | 45 | int cpu; |
| 46 | int ref_count; | 46 | int ref_count; |
| 47 | int locked; /* Do not free, even if ref_count is zero */ | ||
| 47 | void *private; | 48 | void *private; |
| 48 | }; | 49 | }; |
| 49 | 50 | ||
diff --git a/trace-input.c b/trace-input.c index 9db96c7..3a70aec 100644 --- a/trace-input.c +++ b/trace-input.c | |||
| @@ -667,6 +667,9 @@ void free_record(struct record *record) | |||
| 667 | if (record->ref_count) | 667 | if (record->ref_count) |
| 668 | return; | 668 | return; |
| 669 | 669 | ||
| 670 | if (record->locked) | ||
| 671 | die("freeing record when it is locked!"); | ||
| 672 | |||
| 670 | record->data = NULL; | 673 | record->data = NULL; |
| 671 | 674 | ||
| 672 | __free_record(record); | 675 | __free_record(record); |
| @@ -681,6 +684,7 @@ static void free_next(struct tracecmd_input *handle, int cpu) | |||
| 681 | 684 | ||
| 682 | handle->cpu_data[cpu].next = NULL; | 685 | handle->cpu_data[cpu].next = NULL; |
| 683 | 686 | ||
| 687 | record->locked = 0; | ||
| 684 | free_record(record); | 688 | free_record(record); |
| 685 | } | 689 | } |
| 686 | 690 | ||
| @@ -913,7 +917,6 @@ peek_event(struct tracecmd_input *handle, unsigned long long offset, | |||
| 913 | if (record && (record->offset + record->record_size) > offset) | 917 | if (record && (record->offset + record->record_size) > offset) |
| 914 | break; | 918 | break; |
| 915 | free_record(record); | 919 | free_record(record); |
| 916 | |||
| 917 | free_next(handle, cpu); | 920 | free_next(handle, cpu); |
| 918 | } while (record); | 921 | } while (record); |
| 919 | 922 | ||
| @@ -1565,6 +1568,7 @@ read_again: | |||
| 1565 | record->offset = handle->cpu_data[cpu].offset + index; | 1568 | record->offset = handle->cpu_data[cpu].offset + index; |
| 1566 | record->missed_events = missed_events; | 1569 | record->missed_events = missed_events; |
| 1567 | record->ref_count = 2; /* will be returned and stored in page */ | 1570 | record->ref_count = 2; /* will be returned and stored in page */ |
| 1571 | record->locked = 1; | ||
| 1568 | 1572 | ||
| 1569 | ptr += length; | 1573 | ptr += length; |
| 1570 | 1574 | ||
| @@ -1595,8 +1599,10 @@ tracecmd_read_data(struct tracecmd_input *handle, int cpu) | |||
| 1595 | 1599 | ||
| 1596 | record = tracecmd_peek_data(handle, cpu); | 1600 | record = tracecmd_peek_data(handle, cpu); |
| 1597 | handle->cpu_data[cpu].next = NULL; | 1601 | handle->cpu_data[cpu].next = NULL; |
| 1598 | if (record) | 1602 | if (record) { |
| 1599 | record->ref_count--; | 1603 | record->ref_count--; |
| 1604 | record->locked = 0; | ||
| 1605 | } | ||
| 1600 | 1606 | ||
| 1601 | return record; | 1607 | return record; |
| 1602 | } | 1608 | } |
