Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
a7add335
提交
a7add335
authored
2月 15, 2017
作者:
Shane Bryldt
提交者:
Mike Jerris
3月 22, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-9952: Committing to show problem with ks_pool_resize
上级
d6d8ede6
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
269 行增加
和
136 行删除
+269
-136
blade_identity.c
libs/libblade/src/blade_identity.c
+2
-5
blade_module_wss.c
libs/libblade/src/blade_module_wss.c
+206
-100
blade_stack.c
libs/libblade/src/blade_stack.c
+34
-7
blade_identity.h
libs/libblade/src/include/blade_identity.h
+1
-1
blade_stack.h
libs/libblade/src/include/blade_stack.h
+1
-1
bladec.c
libs/libblade/test/bladec.c
+25
-4
bladec2.cfg
libs/libblade/test/bladec2.cfg
+0
-18
没有找到文件。
libs/libblade/src/blade_identity.c
浏览文件 @
a7add335
...
...
@@ -150,15 +150,12 @@ KS_DECLARE(const char *) blade_identity_uri(blade_identity_t *bi)
return
bi
->
uri
;
}
KS_DECLARE
(
ks_status_t
)
blade_identity_parameter_get
(
blade_identity_t
*
bi
,
const
char
*
key
,
const
char
**
value
)
KS_DECLARE
(
const
char
*
)
blade_identity_parameter_get
(
blade_identity_t
*
bi
,
const
char
*
key
)
{
ks_assert
(
bi
);
ks_assert
(
key
);
ks_assert
(
value
);
*
value
=
(
const
char
*
)
ks_hash_search
(
bi
->
parameters
,
(
void
*
)
key
,
KS_UNLOCKED
);
return
KS_STATUS_SUCCESS
;
return
(
const
char
*
)
ks_hash_search
(
bi
->
parameters
,
(
void
*
)
key
,
KS_UNLOCKED
);
}
...
...
libs/libblade/src/blade_module_wss.c
浏览文件 @
a7add335
差异被折叠。
点击展开。
libs/libblade/src/blade_stack.c
浏览文件 @
a7add335
...
...
@@ -44,11 +44,12 @@ struct blade_handle_s {
ks_pool_t
*
pool
;
ks_thread_pool_t
*
tpool
;
config_setting_t
*
config_
service
;
config_setting_t
*
config_
directory
;
config_setting_t
*
config_datastore
;
ks_hash_t
*
transports
;
blade_identity_t
*
identity
;
blade_datastore_t
*
datastore
;
};
...
...
@@ -164,7 +165,7 @@ KS_DECLARE(ks_status_t) blade_handle_destroy(blade_handle_t **bhP)
ks_status_t
blade_handle_config
(
blade_handle_t
*
bh
,
config_setting_t
*
config
)
{
config_setting_t
*
service
=
NULL
;
config_setting_t
*
directory
=
NULL
;
config_setting_t
*
datastore
=
NULL
;
ks_assert
(
bh
);
...
...
@@ -172,13 +173,13 @@ ks_status_t blade_handle_config(blade_handle_t *bh, config_setting_t *config)
if
(
!
config
)
return
KS_STATUS_FAIL
;
if
(
!
config_setting_is_group
(
config
))
return
KS_STATUS_FAIL
;
service
=
config_setting_get_member
(
config
,
"service
"
);
directory
=
config_setting_get_member
(
config
,
"directory
"
);
datastore
=
config_setting_get_member
(
config
,
"datastore"
);
//if (datastore && !config_setting_is_group(datastore)) return KS_STATUS_FAIL;
bh
->
config_
service
=
service
;
bh
->
config_
directory
=
directory
;
bh
->
config_datastore
=
datastore
;
return
KS_STATUS_SUCCESS
;
...
...
@@ -201,7 +202,11 @@ KS_DECLARE(ks_status_t) blade_handle_startup(blade_handle_t *bh, config_setting_
return
KS_STATUS_FAIL
;
}
}
// @todo load DSOs
// @todo call onload and onstartup callbacks for modules from DSOs
return
KS_STATUS_SUCCESS
;
}
...
...
@@ -209,9 +214,12 @@ KS_DECLARE(ks_status_t) blade_handle_shutdown(blade_handle_t *bh)
{
ks_assert
(
bh
);
// @todo cleanup registered transports
// @todo call onshutdown and onunload callbacks for modules from DSOs
// @todo unload DSOs
if
(
blade_handle_datastore_available
(
bh
))
blade_datastore_destroy
(
&
bh
->
datastore
);
return
KS_STATUS_SUCCESS
;
}
...
...
@@ -279,14 +287,33 @@ KS_DECLARE(ks_status_t) blade_handle_connect(blade_handle_t *bh, blade_connectio
ks_assert
(
bh
);
ks_assert
(
target
);
// @todo this should take a callback, and push this to a queue to be processed async from another thread on the handle
// which will allow the onconnect callback to block while doing things like DNS lookups without having unknown
// impact depending on the caller thread
ks_hash_read_lock
(
bh
->
transports
);
blade_identity_parameter_get
(
target
,
"transport"
,
&
tname
);
tname
=
blade_identity_parameter_get
(
target
,
"transport"
);
if
(
tname
)
{
bhtr
=
ks_hash_search
(
bh
->
transports
,
(
void
*
)
tname
,
KS_UNLOCKED
);
if
(
!
bhtr
)
{
// @todo error logging, target has an explicit transport that is not available in the local transports registry
// discuss later whether this scenario should still attempt other transports when target is explicit
// @note discussions indicate that by default messages should favor relaying through a master service, unless
// an existing direct connection already exists to the target (which if the target is the master node, then there is
// no conflict of proper routing). This also applies to routing for identities which relate to groups, relaying should
// most often occur through a master service, however there may be scenarios that exist where an existing session
// exists dedicated to faster delivery for a group (IE, through an ampq cluster directly, such as master services
// syncing with each other through a pub/sub). There is also the potential that instead of a separate session, the
// current session with a master service may be able to have another connection attached which represents access through
// amqp, which in turn acts as a preferred router for only group identities
// This information does not directly apply to connecting, but should be noted for the next level up where you simply
// send a message which will not actually connect, only check for existing sessions for the target and master service
// @note relaying by master services should take a slightly different path, when they receive something not for the
// master service itself, it should relay this on to all other master services, which in turn all including original
// receiver pass on to any sessions matching an identity that is part of the group, alternatively they can use a pub/sub
// like amqp to relay between the master services more efficiently than using the websocket to send every master service
// session the message individually
}
}
else
{
for
(
ks_hash_iterator_t
*
it
=
ks_hash_first
(
bh
->
transports
,
KS_UNLOCKED
);
it
;
it
=
ks_hash_next
(
&
it
))
{
...
...
libs/libblade/src/include/blade_identity.h
浏览文件 @
a7add335
...
...
@@ -40,7 +40,7 @@ KS_DECLARE(ks_status_t) blade_identity_create(blade_identity_t **biP, ks_pool_t
KS_DECLARE
(
ks_status_t
)
blade_identity_destroy
(
blade_identity_t
**
biP
);
KS_DECLARE
(
ks_status_t
)
blade_identity_parse
(
blade_identity_t
*
bi
,
const
char
*
uri
);
KS_DECLARE
(
const
char
*
)
blade_identity_uri
(
blade_identity_t
*
bi
);
KS_DECLARE
(
ks_status_t
)
blade_identity_parameter_get
(
blade_identity_t
*
bi
,
const
char
*
key
,
const
char
**
value
);
KS_DECLARE
(
const
char
*
)
blade_identity_parameter_get
(
blade_identity_t
*
bi
,
const
char
*
key
);
KS_END_EXTERN_C
#endif
...
...
libs/libblade/src/include/blade_stack.h
浏览文件 @
a7add335
...
...
@@ -50,7 +50,7 @@ KS_DECLARE(ks_thread_pool_t *) blade_handle_tpool_get(blade_handle_t *bh);
KS_DECLARE
(
ks_status_t
)
blade_handle_transport_register
(
blade_handle_t
*
bh
,
blade_module_t
*
bm
,
const
char
*
name
,
blade_transport_callbacks_t
*
callbacks
);
KS_DECLARE
(
ks_status_t
)
blade_handle_transport_unregister
(
blade_handle_t
*
bh
,
const
char
*
name
);
KS_DECLARE
(
ks_status_t
)
blade_handle_connect
(
blade_handle_t
*
bh
,
blade_connection_t
**
bcP
,
blade_identity_t
*
target
);
KS_DECLARE
(
ks_bool_t
)
blade_handle_datastore_available
(
blade_handle_t
*
bh
);
KS_DECLARE
(
ks_status_t
)
blade_handle_datastore_store
(
blade_handle_t
*
bh
,
const
void
*
key
,
int32_t
key_length
,
const
void
*
data
,
int64_t
data_length
);
...
...
libs/libblade/test/bladec.c
浏览文件 @
a7add335
...
...
@@ -30,12 +30,14 @@ void command_test(blade_handle_t *bh, char *args);
void
command_quit
(
blade_handle_t
*
bh
,
char
*
args
);
void
command_store
(
blade_handle_t
*
bh
,
char
*
args
);
void
command_fetch
(
blade_handle_t
*
bh
,
char
*
args
);
void
command_connect
(
blade_handle_t
*
bh
,
char
*
args
);
static
const
struct
command_def_s
command_defs
[]
=
{
{
"test"
,
command_test
},
{
"quit"
,
command_quit
},
{
"store"
,
command_store
},
{
"fetch"
,
command_fetch
},
{
"connect"
,
command_connect
},
{
NULL
,
NULL
}
};
...
...
@@ -47,6 +49,8 @@ int main(int argc, char **argv)
config_setting_t
*
config_blade
=
NULL
;
blade_module_t
*
mod_wss
=
NULL
;
//blade_identity_t *id = NULL;
const
char
*
cfgpath
=
"bladec.cfg"
;
ks_global_set_default_logger
(
KS_LOG_LEVEL_DEBUG
);
...
...
@@ -54,12 +58,10 @@ int main(int argc, char **argv)
blade_handle_create
(
&
bh
,
NULL
,
NULL
);
//blade_identity_create(&id, blade_handle_pool_get(bh));
//blade_identity_parse(id, "test@domain.com/laptop?transport=wss&host=127.0.0.1&port=1234");
if
(
argc
>
1
)
cfgpath
=
argv
[
1
];
// @todo load config file, and lookup "blade" setting to put into config_blade
config_init
(
&
config
);
if
(
!
config_read_file
(
&
config
,
"bladec.cfg"
))
{
if
(
!
config_read_file
(
&
config
,
cfgpath
))
{
ks_log
(
KS_LOG_ERROR
,
"%s:%d - %s
\n
"
,
config_error_file
(
&
config
),
config_error_line
(
&
config
),
config_error_text
(
&
config
));
config_destroy
(
&
config
);
return
EXIT_FAILURE
;
...
...
@@ -91,6 +93,10 @@ int main(int argc, char **argv)
loop
(
bh
);
blade_module_wss_on_shutdown
(
mod_wss
);
blade_module_wss_on_unload
(
mod_wss
);
blade_handle_destroy
(
&
bh
);
blade_shutdown
();
...
...
@@ -236,3 +242,18 @@ void command_fetch(blade_handle_t *bh, char *args)
blade_handle_datastore_fetch
(
bh
,
blade_datastore_fetch_callback
,
key
,
strlen
(
key
),
bh
);
}
void
command_connect
(
blade_handle_t
*
bh
,
char
*
args
)
{
blade_connection_t
*
bc
=
NULL
;
blade_identity_t
*
target
=
NULL
;
ks_assert
(
bh
);
ks_assert
(
args
);
blade_identity_create
(
&
target
,
blade_handle_pool_get
(
bh
));
if
(
blade_identity_parse
(
target
,
args
)
==
KS_STATUS_SUCCESS
)
blade_handle_connect
(
bh
,
&
bc
,
target
);
blade_identity_destroy
(
&
target
);
}
libs/libblade/test/bladec2.cfg
浏览文件 @
a7add335
blade:
{
identity = "peer@domain";
directory:
{
uris = ( "directory@domain?transport=wss&host=127.0.0.1&port=2100" );
};
datastore:
{
database:
...
...
@@ -12,18 +8,4 @@ blade:
path = ":mem:";
};
};
wss:
{
endpoints:
{
ipv4 = ( { address = "0.0.0.0", port = 2101 } );
ipv6 = ( { address = "::", port = 2101 } );
backlog = 128;
};
# SSL group is optional, disabled when absent
ssl:
{
# todo: server SSL stuffs here
};
};
};
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论