From fe9607f417ab68aa5e72448bc6473612432ad4e5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 23 Jan 2011 14:54:45 +0200 Subject: Ignore subsequent requests to load the same profile --- odb/odb.cxx | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'odb/odb.cxx') diff --git a/odb/odb.cxx b/odb/odb.cxx index 6fcb2fc..52954ce 100644 --- a/odb/odb.cxx +++ b/odb/odb.cxx @@ -24,6 +24,7 @@ # include // _open_osfhandle #endif +#include #include #include #include // size_t @@ -125,6 +126,7 @@ struct profile_data profile_data (paths const& p, char const* n): search_paths (p), name (n) {} paths const& search_paths; + set loaded; char const* name; }; @@ -790,8 +792,9 @@ profile_search (char const* prof, void* arg) p += ".options"; struct stat info; + paths::const_iterator i (ps.begin ()), end (ps.end ()); - for (paths::const_iterator i (ps.begin ()), end (ps.end ()); i != end; ++i) + for (; i != end; ++i) { // First check in the search directory itself and then try the odb/ // subdirectory. @@ -801,17 +804,26 @@ profile_search (char const* prof, void* arg) // Just check that the file exist without checking for permissions, etc. // if (stat (r.string ().c_str (), &info) == 0 && S_ISREG (info.st_mode)) - return r.string (); + break; r = *i / odb / p; if (stat (r.string ().c_str (), &info) == 0 && S_ISREG (info.st_mode)) - return r.string (); + break; } - cerr << pd->name << ": error: unable to locate options file for profile '" - << prof << "'" << endl; - throw profile_failure (); + if (i == end) + { + cerr << pd->name << ": error: unable to locate options file for profile '" + << prof << "'" << endl; + throw profile_failure (); + } + + if (pd->loaded.find (r) != pd->loaded.end ()) + return string (); + + pd->loaded.insert (r); + return r.string (); } // -- cgit v1.1