Merge branch 'tls-background-eio-thread' into tls-permission-errors
This commit is contained in:
commit
20fe068863
|
@ -996,6 +996,8 @@ void setupNetwork(uint64_t transportId, bool useMetrics) {
|
|||
|
||||
TLS::DisableOpenSSLAtExitHandler();
|
||||
g_network = newNet2(tlsConfig, false, useMetrics || networkOptions.traceDirectory.present());
|
||||
g_network->addStopCallback( Net2FileSystem::stop );
|
||||
g_network->addStopCallback( TLS::DestroyOpenSSLGlobalState );
|
||||
FlowTransport::createInstance(true, transportId);
|
||||
Net2FileSystem::newFileSystem();
|
||||
}
|
||||
|
@ -1020,7 +1022,6 @@ void stopNetwork() {
|
|||
|
||||
g_network->stop();
|
||||
closeTraceFile();
|
||||
TLS::DestroyOpenSSLGlobalState();
|
||||
}
|
||||
|
||||
Reference<ProxyInfo> DatabaseContext::getMasterProxies(bool useProvisionalProxies) {
|
||||
|
|
|
@ -52,6 +52,10 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
static void stop() {
|
||||
eio_set_max_parallel(0);
|
||||
}
|
||||
|
||||
static bool should_poll() { return want_poll; }
|
||||
|
||||
static bool lock_fd( int fd ) {
|
||||
|
|
|
@ -39,6 +39,8 @@ class AsyncFileWinASIO : public IAsyncFile, public ReferenceCounted<AsyncFileWin
|
|||
public:
|
||||
static void init() {}
|
||||
|
||||
static void stop() {}
|
||||
|
||||
static bool should_poll() { return false; }
|
||||
// FIXME: This implementation isn't actually asynchronous - it just does operations synchronously!
|
||||
|
||||
|
|
|
@ -194,6 +194,7 @@ struct YieldMockNetwork : INetwork, ReferenceCounted<YieldMockNetwork> {
|
|||
virtual double now() { return baseNetwork->now(); }
|
||||
virtual double timer() { return baseNetwork->timer(); }
|
||||
virtual void stop() { return baseNetwork->stop(); }
|
||||
virtual void addStopCallback( std::function<void()> fn ) { ASSERT(false); return; }
|
||||
virtual bool isSimulated() const { return baseNetwork->isSimulated(); }
|
||||
virtual void onMainThread(Promise<Void>&& signal, TaskPriority taskID) { return baseNetwork->onMainThread(std::move(signal), taskID); }
|
||||
bool isOnMainThread() const override { return baseNetwork->isOnMainThread(); }
|
||||
|
|
|
@ -114,3 +114,7 @@ Net2FileSystem::Net2FileSystem(double ioTimeout, std::string fileSystemPath)
|
|||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Net2FileSystem::stop() {
|
||||
Net2AsyncFile::stop();
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
virtual Future< std::time_t > lastWriteTime( std::string filename );
|
||||
|
||||
//void init();
|
||||
static void stop();
|
||||
|
||||
Net2FileSystem(double ioTimeout=0.0, std::string fileSystemPath = "");
|
||||
|
||||
|
|
|
@ -870,7 +870,15 @@ public:
|
|||
return emptyConfig;
|
||||
}
|
||||
|
||||
virtual void stop() { isStopped = true; }
|
||||
virtual void stop() {
|
||||
isStopped = true;
|
||||
for ( auto& fn : stopCallbacks ) {
|
||||
fn();
|
||||
}
|
||||
}
|
||||
virtual void addStopCallback( std::function<void()> fn ) {
|
||||
stopCallbacks.emplace_back(std::move(fn));
|
||||
}
|
||||
virtual bool isSimulated() const { return true; }
|
||||
|
||||
struct SimThreadArgs {
|
||||
|
@ -1605,6 +1613,7 @@ public:
|
|||
// Not letting currentProcess be NULL eliminates some annoying special cases
|
||||
currentProcess = new ProcessInfo("NoMachine", LocalityData(Optional<Standalone<StringRef>>(), StringRef(), StringRef(), StringRef()), ProcessClass(), {NetworkAddress()}, this, "", "");
|
||||
g_network = net2 = newNet2(TLSConfig(), false, true);
|
||||
g_network->addStopCallback( Net2FileSystem::stop );
|
||||
Net2FileSystem::newFileSystem();
|
||||
check_yield(TaskPriority::Zero);
|
||||
}
|
||||
|
@ -1703,6 +1712,8 @@ public:
|
|||
//tasks is guarded by ISimulator::mutex
|
||||
std::priority_queue<Task, std::vector<Task>> tasks;
|
||||
|
||||
std::vector<std::function<void()>> stopCallbacks;
|
||||
|
||||
//Sim2Net network;
|
||||
INetwork *net2;
|
||||
|
||||
|
|
|
@ -1551,6 +1551,7 @@ int main(int argc, char* argv[]) {
|
|||
openTraceFile(NetworkAddress(), rollsize, maxLogsSize, logFolder, "trace", logGroup);
|
||||
} else {
|
||||
g_network = newNet2(tlsConfig, useThreadPool, true);
|
||||
g_network->addStopCallback( Net2FileSystem::stop );
|
||||
FlowTransport::createInstance(false, 1);
|
||||
|
||||
const bool expectsPublicAddress = (role == FDBD || role == NetworkTestServer || role == Restore);
|
||||
|
|
|
@ -142,9 +142,14 @@ public:
|
|||
if ( thread_network == this )
|
||||
stopImmediately();
|
||||
else
|
||||
// SOMEDAY: NULL for deferred error, no analysis of correctness (itp)
|
||||
onMainThreadVoid( [this] { this->stopImmediately(); }, NULL );
|
||||
}
|
||||
virtual void addStopCallback( std::function<void()> fn ) {
|
||||
if ( thread_network == this )
|
||||
stopCallbacks.emplace_back(std::move(fn));
|
||||
else
|
||||
onMainThreadVoid( [this, fn] { this->stopCallbacks.emplace_back(std::move(fn)); }, NULL );
|
||||
}
|
||||
|
||||
virtual bool isSimulated() const { return false; }
|
||||
virtual THREAD_HANDLE startThread( THREAD_FUNC_RETURN (*func) (void*), void *arg);
|
||||
|
@ -232,6 +237,7 @@ public:
|
|||
EventMetricHandle<SlowTask> slowTaskMetric;
|
||||
|
||||
std::vector<std::string> blobCredentialFiles;
|
||||
std::vector<std::function<void()>> stopCallbacks;
|
||||
};
|
||||
|
||||
static boost::asio::ip::address tcpAddress(IPAddress const& n) {
|
||||
|
@ -1194,6 +1200,10 @@ void Net2::run() {
|
|||
TraceEvent("SomewhatSlowRunLoopBottom").detail("Elapsed", nnow - now); // This includes the time spent running tasks
|
||||
}
|
||||
|
||||
for ( auto& fn : stopCallbacks ) {
|
||||
fn();
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
timeEndPeriod(1);
|
||||
#endif
|
||||
|
|
|
@ -463,6 +463,10 @@ public:
|
|||
virtual void stop() = 0;
|
||||
// Terminate the program
|
||||
|
||||
virtual void addStopCallback( std::function<void()> fn ) = 0;
|
||||
// Calls `fn` when stop() is called.
|
||||
// addStopCallback can be called more than once, and each added `fn` will be run once.
|
||||
|
||||
virtual bool isSimulated() const = 0;
|
||||
// Returns true if this network is a local simulation
|
||||
|
||||
|
|
Loading…
Reference in New Issue