summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2023-02-17 15:28:22 +0100
committerFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2023-02-17 15:29:35 +0100
commite5bd2dcf493a11f42967d094102567a46b9a66e7 (patch)
tree9143b81358dcb245cc43a0b5ea9dcd93e117a506
parent6008cb83b72a8fafe9c69f6955f4bdffbc049a09 (diff)
downloadtcpdump-e5bd2dcf493a11f42967d094102567a46b9a66e7.tar.gz
instrument functions: Minimize stat() calls
This change decreases the execution time when the file indicating that instrumentation is "off" exists. [skip ci]
-rw-r--r--instrument-functions.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/instrument-functions.c b/instrument-functions.c
index a8e07d9d..fb2314dd 100644
--- a/instrument-functions.c
+++ b/instrument-functions.c
@@ -86,12 +86,19 @@ static void print_debug(void *this_fn, void *call_site, action_type action)
static long symcount;
static asection *text;
static bfd_vma vma;
+ static int instrument_off;
static int print_only_global;
symbol_info syminfo;
struct stat statbuf;
int i;
- if (!stat(ND_FILE_FLAG_OFF, &statbuf))
+ if (!instrument_off) {
+ /* one-time test */
+ if (!stat(ND_FILE_FLAG_OFF, &statbuf)) {
+ instrument_off = 1;
+ return;
+ }
+ } else
return;
/* If no errors, this block should be executed one time */