Skip to content

Commit e3d83f7

Browse files
committed
Latest MAC versions assigns different tmp directories to different processes. So in order to have same tmp directory for CORBA object reference file we pass the tmp directory of OMClient to OMC via the config flag CORBA_OBJECT_REFERENCE_FILE_PATH. This makes sure that omc dumps the CORBA object reference file in the same directory where OMClient is trying to read from.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@16622 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 5c8ca8f commit e3d83f7

File tree

6 files changed

+59
-8
lines changed

6 files changed

+59
-8
lines changed

Compiler/Util/Corba.mo

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ public function haveCorba
5656
external "C" b=Corba_haveCorba() annotation(Library = {"omcruntime", "OpenModelicaCorba"});
5757
end haveCorba;
5858

59+
public function setObjectReferenceFilePath
60+
input String inObjectReferenceFilePath;
61+
external "C" Corba_setObjectReferenceFilePath(inObjectReferenceFilePath) annotation(Library = {"omcruntime", "OpenModelicaCorba"});
62+
end setObjectReferenceFilePath;
63+
5964
public function setSessionName
6065
input String inSessionName;
6166

Compiler/Util/Flags.mo

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,9 @@ constant ConfigFlag CORRECT_CREF_TYPES = CONFIG_FLAG(48, "correctCrefTypes",
724724
constant ConfigFlag SCALARIZE_BINDINGS = CONFIG_FLAG(49, "scalarizeBindings",
725725
NONE(), EXTERNAL(), BOOL_FLAG(false), NONE(),
726726
Util.gettext("Always scalarizes bindings if set."));
727+
constant ConfigFlag CORBA_OBJECT_REFERENCE_FILE_PATH = CONFIG_FLAG(50, "corbaObjectReferenceFilePath",
728+
NONE(), EXTERNAL(), STRING_FLAG(""), NONE(),
729+
Util.gettext("Sets the path for corba object reference file if +d=interactiveCorba is used."));
727730

728731
// This is a list of all configuration flags. A flag can not be used unless it's
729732
// in this list, and the list is checked at initialization so that all flags are
@@ -777,7 +780,8 @@ constant list<ConfigFlag> allConfigFlags = {
777780
SCALARIZE_MINMAX,
778781
RUNNING_WSM_TESTSUITE,
779782
CORRECT_CREF_TYPES,
780-
SCALARIZE_BINDINGS
783+
SCALARIZE_BINDINGS,
784+
CORBA_OBJECT_REFERENCE_FILE_PATH
781785
};
782786

783787
public function new
@@ -1379,7 +1383,7 @@ algorithm
13791383
_ := matchcontinue(inFlag, inValue)
13801384
local
13811385
Boolean value;
1382-
String corba_name;
1386+
String corba_name, corba_objid_path;
13831387

13841388
// +showErrorMessages needs to be sent to the C runtime.
13851389
case (_, _)
@@ -1389,7 +1393,16 @@ algorithm
13891393
ErrorExt.setShowErrorMessages(value);
13901394
then
13911395
();
1392-
1396+
1397+
// The corba object reference file path needs to be sent to the C runtime.
1398+
case (_, _)
1399+
equation
1400+
true = configFlagsIsEqualIndex(inFlag, CORBA_OBJECT_REFERENCE_FILE_PATH);
1401+
STRING_FLAG(data = corba_objid_path) = inValue;
1402+
Corba.setObjectReferenceFilePath(corba_objid_path);
1403+
then
1404+
();
1405+
13931406
// The corba session name needs to be sent to the C runtime, and if the name
13941407
// is mdt it also enables the MetaModelica grammar.
13951408
case (_, _)

Compiler/runtime/Corba_rml.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,21 @@ RML_BEGIN_LABEL(Corba__haveCorba)
4848
}
4949
RML_END_LABEL
5050

51+
RML_BEGIN_LABEL(Corba__setObjectReferenceFilePath)
52+
{
53+
const char *path = RML_STRINGDATA(rmlA0);
54+
CorbaImpl__setObjectReferenceFilePath(path);
55+
RML_TAILCALLK(rmlSC);
56+
}
57+
RML_END_LABEL
58+
5159
RML_BEGIN_LABEL(Corba__setSessionName)
5260
{
5361
const char *name = RML_STRINGDATA(rmlA0);
5462
CorbaImpl__setSessionName(name);
5563
RML_TAILCALLK(rmlSC);
5664
}
65+
RML_END_LABEL
5766

5867
RML_BEGIN_LABEL(Corba__initialize)
5968
{

Compiler/runtime/corbaimpl.cpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@
4343
extern "C" {
4444
#include <stdio.h>
4545
#include "settingsimpl.h"
46+
#include "systemimpl.h"
4647

48+
char* corbaObjectReferenceFilePath = 0;
4749
char* corbaSessionName = 0;
4850
const char* omc_cmd_message="";
4951
const char* omc_reply_message="";
@@ -68,6 +70,18 @@ OmcCommunication_impl* server;
6870
/* the file in which we have to dump the Corba IOR ID */
6971
std::ostringstream objref_file;
7072

73+
void CorbaImpl__setObjectReferenceFilePath(const char *path)
74+
{
75+
if (strlen(path) == 0) return;
76+
if (corbaObjectReferenceFilePath) free(corbaObjectReferenceFilePath);
77+
78+
if (*path) {
79+
corbaObjectReferenceFilePath = strdup(path);
80+
} else {
81+
corbaObjectReferenceFilePath = NULL;
82+
}
83+
}
84+
7185
void CorbaImpl__setSessionName(const char *name)
7286
{
7387
if (strlen(name) == 0) return;
@@ -227,7 +241,12 @@ Please stop or kill the other OMC process first!\nOpenModelica OMC will now exit
227241
mgr = poa->the_POAManager();
228242

229243
/* get the temporary directory */
230-
const char* tempPath = SettingsImpl__getTempDirectoryPath();
244+
/* if corbaObjectReferenceFilePath value is set and is a valid directory then use it for dumping the object reference file. */
245+
const char* tempPath = NULL;
246+
if (SystemImpl__directoryExists(corbaObjectReferenceFilePath))
247+
tempPath = corbaObjectReferenceFilePath;
248+
else
249+
tempPath = SettingsImpl__getTempDirectoryPath();
231250
/* start omc differently if we have a corba session name */
232251
if (corbaSessionName != NULL) /* yehaa, we have a session name */
233252
{
@@ -247,14 +266,14 @@ Please stop or kill the other OMC process first!\nOpenModelica OMC will now exit
247266
* build the reference to store in the file
248267
*/
249268
ref = omcpoa->id_to_reference (oid->in());
250-
objref_file << tempPath << "openmodelica.objid." << corbaSessionName;
269+
objref_file << tempPath << "/openmodelica.objid." << corbaSessionName;
251270
}
252271
else /* we don't have a session name, start OMC normaly */
253272
{
254273
server = new OmcCommunication_impl();
255274
oid = new PortableServer::ObjectId_var(poa->activate_object(server));
256275
ref = poa->id_to_reference (oid->in());
257-
objref_file << tempPath << "openmodelica.objid";
276+
objref_file << tempPath << "/openmodelica.objid";
258277
}
259278

260279
str = (const char*)orb->object_to_string (ref.in());
@@ -373,7 +392,12 @@ int CorbaImpl__initialize()
373392
mgr = poa->the_POAManager();
374393

375394
/* get temp dir */
376-
const char* tmpDir = SettingsImpl__getTempDirectoryPath();
395+
/* if corbaObjectReferenceFilePath value is set and is a valid directory then use it for dumping the object reference file. */
396+
const char* tmpDir = NULL;
397+
if (SystemImpl__directoryExists(corbaObjectReferenceFilePath))
398+
tmpDir = corbaObjectReferenceFilePath;
399+
else
400+
tmpDir = SettingsImpl__getTempDirectoryPath();
377401
/* get the user name */
378402
char *tmp_user = getenv("USER");
379403
string user = tmp_user ? tmp_user : "nobody";

Compiler/runtime/settingsimpl.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ static char* tempDirectoryPath = 0;
5656
static int echo = 1; //true
5757

5858
extern char* _replace(char* source_str,char* search_str,char* replace_str); //Defined in systemimpl.c
59-
extern int SystemImpl__directoryExists(const char*);
6059

6160
static char* winPath = NULL;
6261

Compiler/runtime/systemimpl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ modelica_ptr_t lookup_ptr(modelica_integer index);
8080
int SystemImpl__regularFileExists(const char* str);
8181
int SystemImpl__regularFileWritable(const char* str);
8282
const char* SystemImpl__basename(const char *str);
83+
int SystemImpl__directoryExists(const char* str);
8384
char* SystemImpl__iconv(const char * str, const char *from, const char *to, int printError);
8485

8586
#endif //__SYSTEMIMPL_H

0 commit comments

Comments
 (0)