diff options
author | Josh Stone <jistone@redhat.com> | 2010-03-01 18:42:18 -0800 |
---|---|---|
committer | Josh Stone <jistone@redhat.com> | 2010-03-02 16:05:18 -0800 |
commit | 9b3c54b2fc836e20a0a7895aa759938e62eaacf9 (patch) | |
tree | a9db703d81f4fbabe886c5acb77d6c5cb0964a07 /cache.cxx | |
parent | 6b067d7d20c10acb68d768003bf8031f155e5f39 (diff) | |
download | systemtap-steved-9b3c54b2fc836e20a0a7895aa759938e62eaacf9.tar.gz systemtap-steved-9b3c54b2fc836e20a0a7895aa759938e62eaacf9.tar.xz systemtap-steved-9b3c54b2fc836e20a0a7895aa759938e62eaacf9.zip |
PR11246 cont'd: Separate script/stapconf caching
I'm separating the caching and creation logic for stapconf, so it can be
conditionalized on s.use_cache instead of s.use_script_cache.
* session.h (systemtap_session): Store base_hash for better reuse.
* hash.cxx (get_base_hash): Get the base from the session, or build it.
(find_hash): Split into separate script/stapconf versions.
* cache.cxx (add_to_cache, get_from_cache): Ditto.
* main.cxx (main): Adapt caller, and delay stapconf until pass-4.
Diffstat (limited to 'cache.cxx')
-rw-r--r-- | cache.cxx | 44 |
1 files changed, 30 insertions, 14 deletions
@@ -46,14 +46,10 @@ static void clean_cache(systemtap_session& s); void -add_to_cache(systemtap_session& s) +add_stapconf_to_cache(systemtap_session& s) { bool verbose = s.verbose > 1; - // PR10543: clean the cache *before* we try putting something new into it. - // We don't want to risk having the brand new contents being erased again. - clean_cache(s); - string stapconf_src_path = s.tmpdir + "/" + s.stapconf_name; if (!copy_file(stapconf_src_path, s.stapconf_path, verbose)) { @@ -63,6 +59,17 @@ add_to_cache(systemtap_session& s) // s.use_script_cache = false; // return; } +} + + +void +add_script_to_cache(systemtap_session& s) +{ + bool verbose = s.verbose > 1; + + // PR10543: clean the cache *before* we try putting something new into it. + // We don't want to risk having the brand new contents being erased again. + clean_cache(s); string module_src_path = s.tmpdir + "/" + s.module_name + ".ko"; STAP_PROBE2(stap, cache__add__module, module_src_path.c_str(), s.hash_path.c_str()); @@ -92,16 +99,10 @@ add_to_cache(systemtap_session& s) bool -get_from_cache(systemtap_session& s) +get_stapconf_from_cache(systemtap_session& s) { string stapconf_dest_path = s.tmpdir + "/" + s.stapconf_name; - string module_dest_path = s.tmpdir + "/" + s.module_name + ".ko"; - string c_src_path = s.hash_path; - int fd_stapconf, fd_module, fd_c; - - if (c_src_path.rfind(".ko") == (c_src_path.size() - 3)) - c_src_path.resize(c_src_path.size() - 3); - c_src_path += ".c"; + int fd_stapconf; // See if stapconf exists fd_stapconf = open(s.stapconf_path.c_str(), O_RDONLY); @@ -122,7 +123,22 @@ get_from_cache(systemtap_session& s) close(fd_stapconf); if (s.verbose > 1) - clog << "Pass 3: using cached " << s.stapconf_path << endl; + clog << "Pass 4: using cached " << s.stapconf_path << endl; + + return true; +} + + +bool +get_script_from_cache(systemtap_session& s) +{ + string module_dest_path = s.tmpdir + "/" + s.module_name + ".ko"; + string c_src_path = s.hash_path; + int fd_module, fd_c; + + if (c_src_path.rfind(".ko") == (c_src_path.size() - 3)) + c_src_path.resize(c_src_path.size() - 3); + c_src_path += ".c"; // See if module exists fd_module = open(s.hash_path.c_str(), O_RDONLY); |