forked from Kitware/ParaView
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpvserver_common.h
104 lines (88 loc) · 3.08 KB
/
pvserver_common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*=========================================================================
Program: ParaView
Module: pvserver.cxx
Copyright (c) Kitware, Inc.
All rights reserved.
See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkPVConfig.h"
#include "vtkInitializationHelper.h"
#include "vtkMultiProcessController.h"
#include "vtkNetworkAccessManager.h"
#include "vtkPVPluginTracker.h"
#include "vtkPVServerOptions.h"
#include "vtkPVSessionServer.h"
#include "vtkProcessModule.h"
#ifdef PARAVIEW_ENABLE_PYTHON
extern "C" {
void vtkPVInitializePythonModules();
}
#endif
#include "ParaView_paraview_plugins.h"
static bool RealMain(int argc, char* argv[], vtkProcessModule::ProcessTypes type)
{
// Marking this static avoids the false leak messages from vtkDebugLeaks when
// using mpich. It appears that the root process which spawns all the
// main processes waits in MPI_Init() and calls exit() when
// the others are done, causing apparent memory leaks for any non-static objects
// created before MPI_Init().
static vtkSmartPointer<vtkPVServerOptions> options = vtkSmartPointer<vtkPVServerOptions>::New();
// Init current process type
vtkInitializationHelper::Initialize(argc, argv, type, options);
if (options->GetTellVersion() || options->GetHelpSelected() || options->GetPrintMonitors())
{
vtkInitializationHelper::Finalize();
return 1;
}
#ifdef PARAVIEW_ENABLE_PYTHON
// register callback to initialize modules statically. The callback is
// empty when BUILD_SHARED_LIBS is ON.
vtkPVInitializePythonModules();
#endif
// load static plugins
ParaView_paraview_plugins_initialize();
vtkPVPluginTracker::GetInstance()->LoadPluginConfigurationXMLs("paraview");
vtkProcessModule* pm = vtkProcessModule::GetProcessModule();
vtkMultiProcessController* controller = pm->GetGlobalController();
vtkPVSessionServer* session = vtkPVSessionServer::New();
session->SetMultipleConnection(options->GetMultiClientMode() != 0);
session->SetDisableFurtherConnections(options->GetDisableFurtherConnections() != 0);
int process_id = controller->GetLocalProcessId();
if (process_id == 0)
{
// Report status:
if (options->GetReverseConnection())
{
cout << "Connecting to client (reverse connection requested)..." << endl;
}
else
{
cout << "Waiting for client..." << endl;
}
}
bool success = false;
if (session->Connect())
{
success = true;
pm->RegisterSession(session);
if (controller->GetLocalProcessId() == 0)
{
while (pm->GetNetworkAccessManager()->ProcessEvents(0) != -1)
{
}
}
else
{
controller->ProcessRMIs();
}
pm->UnRegisterSession(session);
}
cout << "Exiting..." << endl;
session->Delete();
// Exit application
vtkInitializationHelper::Finalize();
return success;
}