Skip to content

Commit

Permalink
Latest MAC versions assigns different tmp directories to different pr…
Browse files Browse the repository at this point in the history
…ocesses. 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
  • Loading branch information
adeas31 committed Jul 18, 2013
1 parent 5c8ca8f commit e3d83f7
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 8 deletions.
5 changes: 5 additions & 0 deletions Compiler/Util/Corba.mo
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public function haveCorba
external "C" b=Corba_haveCorba() annotation(Library = {"omcruntime", "OpenModelicaCorba"});
end haveCorba;

public function setObjectReferenceFilePath
input String inObjectReferenceFilePath;
external "C" Corba_setObjectReferenceFilePath(inObjectReferenceFilePath) annotation(Library = {"omcruntime", "OpenModelicaCorba"});
end setObjectReferenceFilePath;

public function setSessionName
input String inSessionName;

Expand Down
19 changes: 16 additions & 3 deletions Compiler/Util/Flags.mo
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,9 @@ constant ConfigFlag CORRECT_CREF_TYPES = CONFIG_FLAG(48, "correctCrefTypes",
constant ConfigFlag SCALARIZE_BINDINGS = CONFIG_FLAG(49, "scalarizeBindings",
NONE(), EXTERNAL(), BOOL_FLAG(false), NONE(),
Util.gettext("Always scalarizes bindings if set."));
constant ConfigFlag CORBA_OBJECT_REFERENCE_FILE_PATH = CONFIG_FLAG(50, "corbaObjectReferenceFilePath",
NONE(), EXTERNAL(), STRING_FLAG(""), NONE(),
Util.gettext("Sets the path for corba object reference file if +d=interactiveCorba is used."));

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

public function new
Expand Down Expand Up @@ -1379,7 +1383,7 @@ algorithm
_ := matchcontinue(inFlag, inValue)
local
Boolean value;
String corba_name;
String corba_name, corba_objid_path;

// +showErrorMessages needs to be sent to the C runtime.
case (_, _)
Expand All @@ -1389,7 +1393,16 @@ algorithm
ErrorExt.setShowErrorMessages(value);
then
();


// The corba object reference file path needs to be sent to the C runtime.
case (_, _)
equation
true = configFlagsIsEqualIndex(inFlag, CORBA_OBJECT_REFERENCE_FILE_PATH);
STRING_FLAG(data = corba_objid_path) = inValue;
Corba.setObjectReferenceFilePath(corba_objid_path);
then
();

// The corba session name needs to be sent to the C runtime, and if the name
// is mdt it also enables the MetaModelica grammar.
case (_, _)
Expand Down
9 changes: 9 additions & 0 deletions Compiler/runtime/Corba_rml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,21 @@ RML_BEGIN_LABEL(Corba__haveCorba)
}
RML_END_LABEL

RML_BEGIN_LABEL(Corba__setObjectReferenceFilePath)
{
const char *path = RML_STRINGDATA(rmlA0);
CorbaImpl__setObjectReferenceFilePath(path);
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

RML_BEGIN_LABEL(Corba__setSessionName)
{
const char *name = RML_STRINGDATA(rmlA0);
CorbaImpl__setSessionName(name);
RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

RML_BEGIN_LABEL(Corba__initialize)
{
Expand Down
32 changes: 28 additions & 4 deletions Compiler/runtime/corbaimpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
extern "C" {
#include <stdio.h>
#include "settingsimpl.h"
#include "systemimpl.h"

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

void CorbaImpl__setObjectReferenceFilePath(const char *path)
{
if (strlen(path) == 0) return;
if (corbaObjectReferenceFilePath) free(corbaObjectReferenceFilePath);

if (*path) {
corbaObjectReferenceFilePath = strdup(path);
} else {
corbaObjectReferenceFilePath = NULL;
}
}

void CorbaImpl__setSessionName(const char *name)
{
if (strlen(name) == 0) return;
Expand Down Expand Up @@ -227,7 +241,12 @@ Please stop or kill the other OMC process first!\nOpenModelica OMC will now exit
mgr = poa->the_POAManager();

/* get the temporary directory */
const char* tempPath = SettingsImpl__getTempDirectoryPath();
/* if corbaObjectReferenceFilePath value is set and is a valid directory then use it for dumping the object reference file. */
const char* tempPath = NULL;
if (SystemImpl__directoryExists(corbaObjectReferenceFilePath))
tempPath = corbaObjectReferenceFilePath;
else
tempPath = SettingsImpl__getTempDirectoryPath();
/* start omc differently if we have a corba session name */
if (corbaSessionName != NULL) /* yehaa, we have a session name */
{
Expand All @@ -247,14 +266,14 @@ Please stop or kill the other OMC process first!\nOpenModelica OMC will now exit
* build the reference to store in the file
*/
ref = omcpoa->id_to_reference (oid->in());
objref_file << tempPath << "openmodelica.objid." << corbaSessionName;
objref_file << tempPath << "/openmodelica.objid." << corbaSessionName;
}
else /* we don't have a session name, start OMC normaly */
{
server = new OmcCommunication_impl();
oid = new PortableServer::ObjectId_var(poa->activate_object(server));
ref = poa->id_to_reference (oid->in());
objref_file << tempPath << "openmodelica.objid";
objref_file << tempPath << "/openmodelica.objid";
}

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

/* get temp dir */
const char* tmpDir = SettingsImpl__getTempDirectoryPath();
/* if corbaObjectReferenceFilePath value is set and is a valid directory then use it for dumping the object reference file. */
const char* tmpDir = NULL;
if (SystemImpl__directoryExists(corbaObjectReferenceFilePath))
tmpDir = corbaObjectReferenceFilePath;
else
tmpDir = SettingsImpl__getTempDirectoryPath();
/* get the user name */
char *tmp_user = getenv("USER");
string user = tmp_user ? tmp_user : "nobody";
Expand Down
1 change: 0 additions & 1 deletion Compiler/runtime/settingsimpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ static char* tempDirectoryPath = 0;
static int echo = 1; //true

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

static char* winPath = NULL;

Expand Down
1 change: 1 addition & 0 deletions Compiler/runtime/systemimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ modelica_ptr_t lookup_ptr(modelica_integer index);
int SystemImpl__regularFileExists(const char* str);
int SystemImpl__regularFileWritable(const char* str);
const char* SystemImpl__basename(const char *str);
int SystemImpl__directoryExists(const char* str);
char* SystemImpl__iconv(const char * str, const char *from, const char *to, int printError);

#endif //__SYSTEMIMPL_H

0 comments on commit e3d83f7

Please sign in to comment.