forked from lix-project/lix
* Don't use the non-standard __gnu_cxx::stdio_filebuf class.
This commit is contained in:
parent
3a2bbe7f8a
commit
c7152c8f97
|
@ -88,8 +88,8 @@ LocalStore::~LocalStore()
|
||||||
flushDelayedUpdates();
|
flushDelayedUpdates();
|
||||||
|
|
||||||
foreach (RunningSubstituters::iterator, i, runningSubstituters) {
|
foreach (RunningSubstituters::iterator, i, runningSubstituters) {
|
||||||
i->second.toBuf.reset();
|
i->second.to.close();
|
||||||
i->second.to.reset();
|
i->second.from.close();
|
||||||
i->second.pid.wait(true);
|
i->second.pid.wait(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,23 +526,16 @@ void LocalStore::startSubstituter(const Path & substituter, RunningSubstituter &
|
||||||
|
|
||||||
/* Parent. */
|
/* Parent. */
|
||||||
|
|
||||||
toPipe.readSide.close();
|
run.to = toPipe.writeSide.borrow();
|
||||||
fromPipe.writeSide.close();
|
run.from = fromPipe.readSide.borrow();
|
||||||
|
|
||||||
run.toBuf = boost::shared_ptr<stdio_filebuf>(new stdio_filebuf(toPipe.writeSide.borrow(), std::ios_base::out));
|
|
||||||
run.to = boost::shared_ptr<std::ostream>(new std::ostream(&*run.toBuf));
|
|
||||||
|
|
||||||
run.fromBuf = boost::shared_ptr<stdio_filebuf>(new stdio_filebuf(fromPipe.readSide.borrow(), std::ios_base::in));
|
|
||||||
run.from = boost::shared_ptr<std::istream>(new std::istream(&*run.fromBuf));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T> T getIntLine(std::istream & str)
|
template<class T> T getIntLine(int fd)
|
||||||
{
|
{
|
||||||
string s;
|
string s = readLine(fd);
|
||||||
T res;
|
T res;
|
||||||
getline(str, s);
|
if (!string2Int(s, res)) throw Error("integer expected from stream");
|
||||||
if (!str || !string2Int(s, res)) throw Error("integer expected from stream");
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -552,10 +545,8 @@ bool LocalStore::hasSubstitutes(const Path & path)
|
||||||
foreach (Paths::iterator, i, substituters) {
|
foreach (Paths::iterator, i, substituters) {
|
||||||
RunningSubstituter & run(runningSubstituters[*i]);
|
RunningSubstituter & run(runningSubstituters[*i]);
|
||||||
startSubstituter(*i, run);
|
startSubstituter(*i, run);
|
||||||
|
writeLine(run.to, "have\n" + path);
|
||||||
*run.to << "have\n" << path << "\n" << std::flush;
|
if (getIntLine<int>(run.from)) return true;
|
||||||
|
|
||||||
if (getIntLine<int>(*run.from)) return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -568,19 +559,19 @@ bool LocalStore::querySubstitutablePathInfo(const Path & substituter,
|
||||||
RunningSubstituter & run(runningSubstituters[substituter]);
|
RunningSubstituter & run(runningSubstituters[substituter]);
|
||||||
startSubstituter(substituter, run);
|
startSubstituter(substituter, run);
|
||||||
|
|
||||||
*run.to << "info\n" << path << "\n" << std::flush;
|
writeLine(run.to, "info\n" + path);
|
||||||
|
|
||||||
if (!getIntLine<int>(*run.from)) return false;
|
if (!getIntLine<int>(run.from)) return false;
|
||||||
|
|
||||||
getline(*run.from, info.deriver);
|
info.deriver = readLine(run.from);
|
||||||
if (info.deriver != "") assertStorePath(info.deriver);
|
if (info.deriver != "") assertStorePath(info.deriver);
|
||||||
int nrRefs = getIntLine<int>(*run.from);
|
int nrRefs = getIntLine<int>(run.from);
|
||||||
while (nrRefs--) {
|
while (nrRefs--) {
|
||||||
Path p; getline(*run.from, p);
|
Path p = readLine(run.from);
|
||||||
assertStorePath(p);
|
assertStorePath(p);
|
||||||
info.references.insert(p);
|
info.references.insert(p);
|
||||||
}
|
}
|
||||||
info.downloadSize = getIntLine<long long>(*run.from);
|
info.downloadSize = getIntLine<long long>(run.from);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <ext/stdio_filebuf.h>
|
|
||||||
|
|
||||||
#include "store-api.hh"
|
#include "store-api.hh"
|
||||||
#include "util.hh"
|
#include "util.hh"
|
||||||
|
|
||||||
|
@ -36,15 +34,10 @@ struct OptimiseStats
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef __gnu_cxx::stdio_filebuf<char> stdio_filebuf;
|
|
||||||
|
|
||||||
|
|
||||||
struct RunningSubstituter
|
struct RunningSubstituter
|
||||||
{
|
{
|
||||||
Pid pid;
|
Pid pid;
|
||||||
boost::shared_ptr<stdio_filebuf> toBuf, fromBuf;
|
AutoCloseFD to, from;
|
||||||
boost::shared_ptr<std::ostream> to;
|
|
||||||
boost::shared_ptr<std::istream> from;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue