Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
c96d0098
提交
c96d0098
authored
3月 14, 2016
作者:
Michael Giagnocavo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-8932 - Add in process loading via LoadEmbeddedPlugins
上级
566cc419
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
51 行增加
和
4 行删除
+51
-4
Loader.cs
src/mod/languages/mod_managed/managed/Loader.cs
+18
-3
PluginManager.cs
src/mod/languages/mod_managed/managed/PluginManager.cs
+33
-1
没有找到文件。
src/mod/languages/mod_managed/managed/Loader.cs
浏览文件 @
c96d0098
...
...
@@ -141,7 +141,9 @@ namespace FreeSWITCH {
static
void
watcher_Changed
(
object
sender
,
FileSystemEventArgs
e
)
{
Action
<
string
>
queueFile
=
fileName
=>
{
var
currentPi
=
pluginInfos
.
FirstOrDefault
(
p
=>
string
.
Compare
(
fileName
,
p
.
FileName
,
StringComparison
.
OrdinalIgnoreCase
)
==
0
);
var
currentPi
=
pluginInfos
.
Where
(
x
=>
!
string
.
IsNullOrEmpty
(
x
.
FileName
))
.
FirstOrDefault
(
p
=>
string
.
Compare
(
fileName
,
p
.
FileName
,
StringComparison
.
OrdinalIgnoreCase
)
==
0
);
if
(
currentPi
!=
null
)
{
var
noReload
=
currentPi
.
Manager
.
ApiExecutors
.
Any
(
x
=>
(
x
.
PluginOptions
&
PluginOptions
.
NoAutoReload
)
==
PluginOptions
.
NoAutoReload
)
||
currentPi
.
Manager
.
AppExecutors
.
Any
(
x
=>
(
x
.
PluginOptions
&
PluginOptions
.
NoAutoReload
)
==
PluginOptions
.
NoAutoReload
);
...
...
@@ -259,7 +261,7 @@ namespace FreeSWITCH {
System
.
Threading
.
Interlocked
.
Increment
(
ref
appDomainCount
);
setup
.
ApplicationName
=
Path
.
GetFileName
(
fileName
)
+
"_"
+
appDomainCount
;
var
domain
=
AppDomain
.
CreateDomain
(
setup
.
ApplicationName
,
null
,
setup
);
PluginManager
pm
;
try
{
pm
=
(
PluginManager
)
domain
.
CreateInstanceAndUnwrap
(
pmType
.
Assembly
.
FullName
,
pmType
.
FullName
,
null
);
...
...
@@ -276,9 +278,17 @@ namespace FreeSWITCH {
return
;
}
addPlugin
(
fileName
,
domain
,
pm
);
}
static
void
addPlugin
(
string
fileName
,
AppDomain
domain
,
PluginManager
pm
)
{
// Update dictionaries atomically
lock
(
loaderLock
)
{
unloadFile
(
fileName
);
if
(!
string
.
IsNullOrEmpty
(
fileName
))
{
if
(
domain
==
null
)
throw
new
ApplicationException
(
"File based plugins must specify an AppDomain."
);
unloadFile
(
fileName
);
}
if
(
domain
==
null
)
domain
=
AppDomain
.
CurrentDomain
;
var
pi
=
new
PluginInfo
{
FileName
=
fileName
,
Domain
=
domain
,
Manager
=
pm
};
pluginInfos
.
Add
(
pi
);
...
...
@@ -298,6 +308,11 @@ namespace FreeSWITCH {
}
}
public
static
void
LoadEmbeddedPlugins
(
Assembly
asm
)
{
var
pm
=
new
EmbeddedPluginManager
(
asm
);
addPlugin
(
null
,
null
,
pm
);
}
static
void
unloadFile
(
string
fileName
)
{
List
<
PluginInfo
>
pisToRemove
;
lock
(
loaderLock
)
{
...
...
src/mod/languages/mod_managed/managed/PluginManager.cs
浏览文件 @
c96d0098
...
...
@@ -250,7 +250,7 @@ namespace FreeSWITCH {
}
}
public
void
BlockUntilUnloadIsSafe
()
{
public
v
irtual
v
oid
BlockUntilUnloadIsSafe
()
{
if
(
isUnloading
)
throw
new
InvalidOperationException
(
"PluginManager is already unloading."
);
isUnloading
=
true
;
unloadCount
=
ApiExecutors
.
Count
+
AppExecutors
.
Count
;
...
...
@@ -310,4 +310,36 @@ namespace FreeSWITCH {
}
internal
class
EmbeddedPluginManager
:
PluginManager
{
// This is for cases where FreeSWITCH is "embedded", that is a .NET app hosts the FS core lib itself.
// In such a case, there may be plugins defined in the main process that need to share address space
// and be loaded from the main assembly. This class plus changes in Loader.cs (null filenames=embedded)
// work together to allow such plugins to work. These plugins cannot be reloaded.
Assembly
asm
;
public
EmbeddedPluginManager
(
Assembly
asm
)
{
this
.
asm
=
asm
;
var
allTypes
=
asm
.
GetExportedTypes
();
var
opts
=
GetOptions
(
allTypes
);
AddApiPlugins
(
allTypes
,
opts
);
AddAppPlugins
(
allTypes
,
opts
);
}
protected
override
bool
LoadInternal
(
string
fileName
)
{
throw
new
NotImplementedException
(
"EmbeddedPluginManager should not have Load[Internal] called."
);
}
public
override
void
BlockUntilUnloadIsSafe
()
{
throw
new
NotImplementedException
(
"EmbeddedPluginManager should never be unloaded."
);
}
}
public
static
class
EmbeddedLoader
{
public
static
void
LoadEmbeddedPlugins
(
Assembly
asm
)
{
Loader
.
LoadEmbeddedPlugins
(
asm
);
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论