Skip to content

Commit

Permalink
1) Added global option JVX_DEBUG which mirrors the CMAKE build option…
Browse files Browse the repository at this point in the history
… - Debug or Release

2) Added option to pass ini file in jvxComponentLib - to allow others than just a default
3) Allowed to decode component with <slotid-subslotid> rather than <slotid,subslotid> - some situations do not allow the , at every place
4) Better handling of fail in webserver start for the console web host. This often happens if the port is already in use. Now, an error state will always be shown
  • Loading branch information
hkbinaurics committed Apr 13, 2024
1 parent 187b9c3 commit 971b528
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 14 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ if(JVX_NO_SYSTEM_EXTENSIONS)
set(GLOBAL_COMPILE_DEFINITIONS "${GLOBAL_COMPILE_DEFINITIONS};JVX_NO_SYSTEM_EXTENSIONS")
endif()

if(${CMAKE_BUILD_TYPE} MATCHES "^(Debug)$")
set(GLOBAL_COMPILE_DEFINITIONS "${GLOBAL_COMPILE_DEFINITIONS};JVX_DEBUG")
endif()

# path to binaries for adding dependencies later
set(JVX_PCG ${CMAKE_INSTALL_PREFIX}/${INSTALL_PATH_RELEASE_ROOT}/bin/jvxExPropC${JVX_EXECUTABLE_EXTENSION_OPERATE} CACHE PATH "Set the path to the Javox PCG binary (external path for cross-compilation)")
set(JVX_PCG_MATLAB ${CMAKE_INSTALL_PREFIX}/${INSTALL_PATH_RELEASE_ROOT}/bin/jvxExPropMat${JVX_EXECUTABLE_EXTENSION_OPERATE} CACHE PATH "Set the path to the Javox PCG Mat binary (external path for cross-compilation)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class CayfComponentLib :
static jvxErrorType populateBindingRefs(
const std::string& myRegisterName,
const std::string& rootPath,
ayfHostBindingReferences*& bindOnReturn);
ayfHostBindingReferences*& bindOnReturn, const char* fNameIniDirect);
static jvxErrorType unpopulateBindingRefs();

virtual jvxErrorType JVX_CALLINGCONVENTION initialize(IjvxHiddenInterface* hostRef) override;
Expand Down
17 changes: 15 additions & 2 deletions sources/jvxLibraries/ayf-component-lib/src/CayfComponentLib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,23 @@ jvxSize idRegisterGlobal = 0;
jvxSize refCntGlobal = 0;

jvxErrorType
CayfComponentLib::populateBindingRefs(const std::string &myRegisterName, const std::string& rootPath, ayfHostBindingReferences*& bindOnReturn)
CayfComponentLib::populateBindingRefs(const std::string &myRegisterName, const std::string& rootPath, ayfHostBindingReferences*& bindOnReturn, const char* fNameIniDirect)
{
if (proxyLibHandleGlobal == JVX_HMODULE_INVALID)
{
std::string fNameDll = AYF_EMBEDDING_PROXY_HOST;
std::string fNameIni;
const char* fNameIniPtr = nullptr;

if (fNameIniDirect)
{
fNameIni = fNameIniDirect;
if (!fNameIni.empty())
{
fNameIniPtr = fNameIni.c_str();
}

}
proxyLibHandleGlobal = JVX_LOADLIBRARY(fNameDll.c_str());
if (proxyLibHandleGlobal != JVX_HMODULE_INVALID)
{
Expand All @@ -89,7 +101,8 @@ CayfComponentLib::populateBindingRefs(const std::string &myRegisterName, const s

if (proxyReferencesGlobal.ayf_embedding_proxy_init_call)
{
proxyReferencesGlobal.ayf_embedding_proxy_init_call(myRegisterName.c_str(), &idRegisterGlobal, &bindingGlobal, rootPath.c_str());

proxyReferencesGlobal.ayf_embedding_proxy_init_call(myRegisterName.c_str(), &idRegisterGlobal, &bindingGlobal, rootPath.c_str(), fNameIniPtr);
}

refCntGlobal = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ CayfComponentLibContainer::stopBinding()
jvxErrorType
CayfComponentLibContainer::invite_external_components(IjvxHiddenInterface* hostRefIf, jvxBool inviteToJoin)
{
IjvxHost* hostRef = reqInterface<IjvxHost>(hostRefIf);
IjvxHost* hostRef = reqInterface<IjvxHost>(hostRefIf);
if (hostRef)
{
if (inviteToJoin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

extern "C"
{
jvxErrorType ayf_embedding_proxy_init(const char* nm, jvxSize* idRegistered, ayfHostBindingReferences* retReferences, const char* fNameIni);
jvxErrorType ayf_embedding_proxy_init(const char* nm, jvxSize* idRegistered, ayfHostBindingReferences* retReferences, const char* fNameIni, const char* fNameIniDirect);
jvxErrorType ayf_embedding_proxy_terminate(jvxSize idRegistered, ayfHostBindingReferences* bindings);

jvxErrorType ayf_embedding_proxy_host_set(IjvxHost* hostRefOnInit);
Expand All @@ -14,7 +14,7 @@ extern "C"

#else

typedef jvxErrorType (*ayf_embedding_proxy_init)(const char* nm, jvxSize* idRegistered, ayfHostBindingReferences** retReferences, const char* fNameIni);
typedef jvxErrorType (*ayf_embedding_proxy_init)(const char* nm, jvxSize* idRegistered, ayfHostBindingReferences** retReferences, const char* fNameIni, const char* fNameIniDirect);
typedef jvxErrorType (*ayf_embedding_proxy_terminate)(jvxSize idRegistered, ayfHostBindingReferences* bindings);
typedef jvxErrorType (*ayf_embedding_proxy_host_set)(IjvxHost* hostRefOnInit);
typedef jvxErrorType (*ayf_embedding_proxy_host_reset)();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void reset_entries(ayfHostBindingReferencesEmbHost* retReferences)
}
extern "C"
{
jvxErrorType ayf_embedding_proxy_init(const char* nm, jvxSize* idRegistered, ayfHostBindingReferences** retReferences, const char* fNameIniPath)
jvxErrorType ayf_embedding_proxy_init(const char* nm, jvxSize* idRegistered, ayfHostBindingReferences** retReferences, const char* fNameIniPath, const char* fNameIniDirect)
{
std::list<std::string> messagesConsole;

Expand Down Expand Up @@ -102,6 +102,11 @@ extern "C"
fNameIni += JVX_SEPARATOR_DIR;
fNameIni += "ayf-proxy.ini";

if (fNameIniDirect != nullptr)
{
fNameIni = fNameIniDirect;
}

#ifdef JVX_OS_WINDOWS
fNameIni = jvx_replaceDirectorySeparators_toWindows(fNameIni, JVX_SEPARATOR_DIR_CHAR, JVX_SEPARATOR_DIR_CHAR_THE_OTHER);
#endif
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,17 @@ CjvxWebServerHost::start_webserver(IjvxWebServer* server, IjvxHost* hostRef,
right_before_start();

resL = hdl->start();
if (resL != JVX_NO_ERROR)
{
std::cout << "FATAL ERROR: Failed to start web server!!" << std::endl;
JVX_SLEEP_S(5);
#ifdef JVX_DEBUG
// assert(0);
return JVX_ERROR_INVALID_SETTING;
#else
exit(0);
#endif
}
}
}
return resL;
Expand Down
6 changes: 6 additions & 0 deletions sources/jvxLibraries/jvx-helpers/src/HjvxMisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6109,7 +6109,13 @@ jvxComponentIdentification_decode(jvxComponentIdentification& cpTp, const std::s
tp = in.substr(0, pos);
token = in.substr(pos + 1, std::string::npos);

// There might be a , or a - between slotid and slotsubid
pos = token.find(",");
if (pos == std::string::npos)
{
pos = token.find("-");
}

if (pos != std::string::npos)
{
sslotid = token.substr(0, pos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CjvxConsoleHost_be_print: public IjvxEventLoop_backend_ctrl

jvxBool config_noquit = false;


jvxErrorType startupErrorCode = JVX_NO_ERROR;
public:

CjvxConsoleHost_be_print();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,12 @@ CjvxConsoleHost_be_drivehost::boot_activate_specific(jvxApiString* errloc)
}
else
{
assert(0);
// Startup error code - print on every line
startupErrorCode = resL;
std::string token = jvxErrorType_descr(startupErrorCode);
linestart = token + linestart;
elm->st = JVX_STATE_ACTIVE;
// assert(0);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ CjvxWebControl_fe::report_process_event(TjvxEventLoopElement* theQueueElement)
jvxSize i;
jvxErrorType res = JVX_NO_ERROR;
jvxErrorType resL = JVX_NO_ERROR;
jvxErrorType resStart = JVX_NO_ERROR;
oneThreadReturnType* myPrivateMem = NULL;
jvxWebContext* ctxt = NULL;

Expand Down Expand Up @@ -301,8 +302,7 @@ CjvxWebControl_fe::report_process_event(TjvxEventLoopElement* theQueueElement)
}

assert(myWebServer.hdl);
resL = start_webserver(myWebServer.hdl, myHostRef, static_cast<IjvxWebServerHost_hooks*>(this));
assert(resL == JVX_NO_ERROR);
resStart = start_webserver(myWebServer.hdl, myHostRef, static_cast<IjvxWebServerHost_hooks*>(this));

// Request log file stream
jvx_init_text_log(jvxrtst_bkp);
Expand All @@ -322,6 +322,12 @@ CjvxWebControl_fe::report_process_event(TjvxEventLoopElement* theQueueElement)
res = config.hostRefConfigExtender->register_extension(static_cast<IjvxConfigurationExtender_report*>(this), JVX_WEBCONTROL_SECTION);
}

// Report the failed startup to caller
if (resStart != JVX_NO_ERROR)
{
res =JVX_ERROR_INVALID_SETTING;
}

break;
case JVX_EVENTLOOP_EVENT_DEACTIVATE:

Expand Down
23 changes: 20 additions & 3 deletions sources/jvxTools/jvxTWebServer/src/CjvxWebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,26 @@ CjvxWebServer::start()
}
options[i] = NULL;

myServer = NULL;
JVX_SAFE_NEW_OBJ(myServer, CivetServer(options));
assert(myServer);
myServer = nullptr;

try
{
JVX_SAFE_NEW_OBJ(myServer, CivetServer(options));
}
catch (CivetException exc)
{
std::cout << "Exception when activating webserver: " << exc.what() << std::endl;
std::cout << "Web server started with arguments: " << std::endl;
for (auto& elm : lst)
{
std::cout << " --> " << elm << std::endl;
}
}

if (myServer == nullptr)
{
return JVX_ERROR_INTERNAL;
}

for(i = 0; i < coendpoints.size(); i++)
{
Expand Down

0 comments on commit 971b528

Please sign in to comment.