Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save j0sh/1129102 to your computer and use it in GitHub Desktop.
Save j0sh/1129102 to your computer and use it in GitHub Desktop.
[PATCH] Try to load statically linked applications first, then dynamic ones.
From b3522c2d16b9424b2978b1c8a2fd1fddb6212d07 Mon Sep 17 00:00:00 2001
From: Josh Allmann <joshua.allmann@gmail.com>
Date: Fri, 5 Aug 2011 20:46:54 -1000
Subject: [PATCH] Try to load statically linked applications first, then dynamic ones.
This has two benefits:
1. Avoids specifying the link type in lua configuration
2. Enables statically linking core dependencies and applications
(such as appselector), while also dynamically loading user
created modules.
The problem with (2) is it leads to multiple copies of the core
libraries being in use, one for crtmpserver and one for
every dynamically linked user applications.
---
sources/thelib/src/configuration/configfile.cpp | 32 ++++++++---------------
1 files changed, 11 insertions(+), 21 deletions(-)
diff --git a/sources/thelib/src/configuration/configfile.cpp b/sources/thelib/src/configuration/configfile.cpp
index ea8c587..1baf031 100644
--- a/sources/thelib/src/configuration/configfile.cpp
+++ b/sources/thelib/src/configuration/configfile.cpp
@@ -694,9 +694,9 @@ bool ConfigFile::ConfigureAcceptor(Variant &node, BaseClientApplication *pApplic
}
bool ConfigFile::ConfigureApplication(Variant &node) {
- if (node[CONF_PROTOCOL] == CONF_PROTOCOL_DYNAMICLINKLIBRARY) {
- Normalize(node);
- if (_pFunction == NULL) {
+ BaseClientApplication *pApplication = NULL;
+ Normalize(node);
+ if (_pFunction == NULL || !(pApplication = _pFunction(node))) {
_libDescriptor.libraryPath = (string) node[CONF_APPLICATION_LIBRARY];
_libDescriptor.libHandler = LOAD_LIBRARY(STR(_libDescriptor.libraryPath), LOAD_LIBRARY_FLAGS);
@@ -732,9 +732,15 @@ bool ConfigFile::ConfigureApplication(Variant &node) {
STR(strError));
return false;
}
- } else {
- _libDescriptor.libHandler = NULL;
+
+ pApplication = _libDescriptor.GetApplication(node);
+ if (pApplication == NULL) {
+ FATAL("Unable to configure application. Function returned NULL");
+ return false;
}
+ } else {
+ _libDescriptor.libHandler = NULL;
+ }
if (node.HasKey(CONF_APPLICATION_ALIASES) && node[CONF_APPLICATION_ALIASES] != V_NULL) {
Variant temp = node[CONF_APPLICATION_ALIASES];
@@ -792,17 +798,6 @@ bool ConfigFile::ConfigureApplication(Variant &node) {
node[CONF_APPLICATION_CLIENTSIDEBUFFER] = (int32_t) 5;
}
- BaseClientApplication *pApplication = NULL;
- if (_pFunction == NULL) {
- pApplication = _libDescriptor.GetApplication(node);
- } else {
- pApplication = _pFunction(node);
- }
- if (pApplication == NULL) {
- FATAL("Unable to configure application. Function returned NULL");
- return false;
- }
-
pApplication->GetConfiguration()["id"] = (uint32_t) pApplication->GetId();
if (!ClientApplicationManager::RegisterApplication(pApplication)) {
@@ -845,11 +840,6 @@ bool ConfigFile::ConfigureApplication(Variant &node) {
}
return true;
- } else {
- FATAL("Configuration for %s protocol not yet implemented",
- STR(node[CONF_PROTOCOL]));
- return false;
- }
}
void ConfigFile::InitServiceInfo() {
--
1.7.3.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment