Skip to contentSkip to conversation

Remove global input buffer

PATCH Applied Felipe Balbi 2 participants 2 messages Dec 16, 2022 – Jan 4, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Remove global input buffer

When using the library with multiple threads, the global input buffer pointer gets modified concurrently by each thread. An easy fix for the problems that arise is to give each struct tep_handle its own input buffer pointer.

---
 src/event-parse-local.h |  14 +-
 src/event-parse.c       | 368 ++++++++++++++++++++--------------------
 src/parse-filter.c      | 118 ++++++-------
 3 files changed, 254 insertions(+), 246 deletions(-)
src/event-parse-local.h +9 -5
index fd4bbcfbb849..c6bfc611bfbd 100644
@@ -85,6 +85,10 @@ struct tep_handle {
 	struct tep_event *last_event;
 
 	struct tep_plugins_dir *plugins_dir;
+
+	const char *input_buf;
+	unsigned long long input_buf_ptr;
+	unsigned long long input_buf_siz;
 };
 
 enum tep_print_parse_type {
@@ -113,11 +117,11 @@ unsigned int data2host4(struct tep_handle *tep, unsigned int data);
 unsigned long long data2host8(struct tep_handle *tep, unsigned long long data);
 
 /* access to the internal parser */
-int peek_char(void);
-void init_input_buf(const char *buf, unsigned long long size);
-unsigned long long get_input_buf_ptr(void);
-const char *get_input_buf(void);
-enum tep_event_type read_token(char **tok);
+int peek_char(struct tep_handle *tep);
+void init_input_buf(struct tep_handle *tep, const char *buf, unsigned long long size);
+unsigned long long get_input_buf_ptr(struct tep_handle *tep);
+const char *get_input_buf(struct tep_handle *tep);
+enum tep_event_type read_token(struct tep_handle *tep, char **tok);
 void free_token(char *tok);
 
 #endif /* _PARSE_EVENTS_INT_H */
src/event-parse.c +185 -183

1,048 lines not on this page · raw message

src/parse-filter.c +60 -58

424 lines not on this page · raw message

Signature · 1 line
2.38.1
#1 lore raw
Quoted 6 lines · On Fri, 16 Dec 2022 12:27:53 +0200 Felipe Balbi <[email protected]> wrote:

When using the library with multiple threads, the global input buffer pointer gets modified concurrently by each thread. An easy fix for the problems that arise is to give each struct tep_handle its own input buffer pointer.

Applied, thanks Felipe!

-- Steve