aboutsummaryrefslogtreecommitdiff
path: root/odb/odb.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-01-23 14:54:45 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-01-23 14:54:45 +0200
commitfe9607f417ab68aa5e72448bc6473612432ad4e5 (patch)
treec8c9576ea9f740ec5aa2c346ff9d50a78eb547a8 /odb/odb.cxx
parent1b917d0f48766cf99427181ad11ce84d23a46161 (diff)
Ignore subsequent requests to load the same profile
Diffstat (limited to 'odb/odb.cxx')
-rw-r--r--odb/odb.cxx24
1 files changed, 18 insertions, 6 deletions
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 <io.h> // _open_osfhandle
#endif
+#include <set>
#include <string>
#include <vector>
#include <cstddef> // 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<path> 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 ();
}
//