Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
06b6e6bd
提交
06b6e6bd
authored
4月 11, 2014
作者:
Travis Cross
浏览文件
操作
浏览文件
下载
差异文件
Merge in change to use system libmemcached
FS-353
上级
23fe7f5c
a60fa670
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
121 行增加
和
54 行删除
+121
-54
configure.ac
configure.ac
+16
-0
control-modules
debian/control-modules
+1
-0
Makefile.am
src/mod/applications/mod_memcache/Makefile.am
+9
-22
mod_memcache.c
src/mod/applications/mod_memcache/mod_memcache.c
+95
-32
没有找到文件。
configure.ac
浏览文件 @
06b6e6bd
...
...
@@ -1129,6 +1129,22 @@ PKG_CHECK_MODULES([YAML], [yaml-0.1 >= 0.1.4],[
AM_CONDITIONAL([HAVE_YAML],[true])],[
AC_MSG_RESULT([no]); AM_CONDITIONAL([HAVE_YAML],[false])])
PKG_CHECK_MODULES([MEMCACHED], [libmemcached >= 0.31],[
AM_CONDITIONAL([HAVE_MEMCACHED],[true])
MEMCACHED_LIBS="${MEMCACHED_LIBS} -lpthread"
save_LIBS="${LIBS}"
save_CPPFLAGS="${CPPFLAGS}"
LIBS="${MEMCACHED_LIBS}"
CPPFLAGS="${MEMCACHED_CFLAGS}"
AC_CHECK_FUNCS([memcached_server_name memcached_stat_execute])
AC_CHECK_TYPES([memcached_instance_st*],,, [[#include <libmemcached/memcached.h>]])
LIBS="${save_LIBS}"
CPPFLAGS="${save_CPPFLAGS}"
],[
AC_MSG_RESULT([no])
AM_CONDITIONAL([HAVE_MEMCACHED],[false])
])
AC_ARG_ENABLE(core-libedit-support,
[AS_HELP_STRING([--disable-core-libedit-support], [Compile without libedit Support])])
...
...
debian/control-modules
浏览文件 @
06b6e6bd
...
...
@@ -126,6 +126,7 @@ Description: Limit compatibility module
Module: applications/mod_memcache
Description: Memcache
This module provides an interface to memcache servers.
Build-Depends: libmemcached-dev
Module: applications/mod_mongo
Description: MongoDB
...
...
src/mod/applications/mod_memcache/Makefile.am
浏览文件 @
06b6e6bd
include
$(top_srcdir)/build/modmake.rulesam
MODNAME
=
mod_memcache
MEMCACHED
=
libmemcached-0.32
MEMCACHED_DIR
=
$(switch_srcdir)
/libs/
$(MEMCACHED)
MEMCACHED_BUILDDIR
=
$(switch_builddir)
/libs/
$(MEMCACHED)
MEMCACHEDLA
=
$(MEMCACHED_BUILDDIR)
/libmemcached/libmemcached.la
if
HAVE_MEMCACHED
mod_LTLIBRARIES
=
mod_memcache.la
mod_memcache_la_SOURCES
=
mod_memcache.c
mod_memcache_la_CFLAGS
=
$(AM_CFLAGS)
-I
$(MEMCACHED_DIR)
-I
$(MEMCACHED_BUILDDIR
)
mod_memcache_la_LIBADD
=
$(switch_builddir)
/libfreeswitch.la
$(MEMCACHED
LA
)
mod_memcache_la_CFLAGS
=
$(AM_CFLAGS)
$(MEMCACHED_CFLAGS
)
mod_memcache_la_LIBADD
=
$(switch_builddir)
/libfreeswitch.la
$(MEMCACHED
_LIBS
)
mod_memcache_la_LDFLAGS
=
-avoid-version
-module
-no-undefined
-shared
MY_DEFAULT_ARGS
=
--build
=
$(build)
--host
=
$(host)
--target
=
$(target)
--disable-shared
--with-pic
BUILT_SOURCES
=
$(MEMCACHEDLA)
$(MEMCACHED_DIR)
:
$(GETLIB)
$(MEMCACHED)
.tar.gz
$(MEMCACHED_BUILDDIR)/Makefile
:
$(MEMCACHED_DIR)
mkdir
-p
$(MEMCACHED_BUILDDIR)
echo
$(MY_DEFAULT_ARGS)
cd
$(MEMCACHED_BUILDDIR)
&&
$(DEFAULT_VARS)
$(MEMCACHED_DIR)
/configure
$(MY_DEFAULT_ARGS)
--with-memcached
=
no
--srcdir
=
$(MEMCACHED_DIR)
CPPFLAGS
=
LDFLAGS
=
$(TOUCH_TARGET)
$(MEMCACHEDLA)
:
$(MEMCACHED_BUILDDIR)/Makefile
cd
$(MEMCACHED_BUILDDIR)
&&
$(MAKE)
$(TOUCH_TARGET)
else
install
:
error
all
:
error
error
:
$
(
error You must
install
libmemcached-dev to build mod_memcache
)
endif
src/mod/applications/mod_memcache/mod_memcache.c
浏览文件 @
06b6e6bd
...
...
@@ -29,6 +29,7 @@
*
*/
#include <switch.h>
#include <switch_private.h>
#include <libmemcached/memcached.h>
/* Prototypes */
...
...
@@ -138,6 +139,81 @@ static void event_handler(switch_event_t *event)
do_config
(
SWITCH_TRUE
);
}
#if HAVE_MEMCACHED_SERVER_NAME
#if HAVE_MEMCACHED_INSTANCE_STP
#define MCD_SERVER memcached_instance_st*
#else
#define MCD_SERVER memcached_server_instance_st
#endif
#define MCD_SERVER_NAME memcached_server_name(server)
#define MCD_SERVER_PORT memcached_server_port(server)
#else
#define MCD_SERVER memcached_server_st*
#define MCD_SERVER_NAME memcached_server_name(ptr, *server)
#define MCD_SERVER_PORT memcached_server_port(ptr, *server)
#endif
struct
stream_server
{
switch_stream_handle_t
*
stream
;
MCD_SERVER
server
;
};
static
memcached_return
server_show
(
const
memcached_st
*
ptr
,
const
MCD_SERVER
server
,
void
*
context
)
{
struct
stream_server
*
ss
=
(
struct
stream_server
*
)
context
;
ss
->
stream
->
write_function
(
ss
->
stream
,
" %s (%u)
\n
"
,
MCD_SERVER_NAME
,
MCD_SERVER_PORT
);
return
MEMCACHED_SUCCESS
;
}
static
memcached_return
server_stat
(
const
MCD_SERVER
server
,
const
char
*
key
,
size_t
key_length
,
const
char
*
value
,
size_t
value_length
,
void
*
context
)
{
struct
stream_server
*
ss
=
(
struct
stream_server
*
)
context
;
if
(
ss
->
server
!=
server
)
{
server_show
(
NULL
,
server
,
context
);
ss
->
server
=
(
MCD_SERVER
)
server
;
}
ss
->
stream
->
write_function
(
ss
->
stream
,
" %s: %s
\n
"
,
key
,
value
);
return
MEMCACHED_SUCCESS
;
}
#if !HAVE_MEMCACHED_STAT_EXECUTE
static
memcached_return
server_stats
(
memcached_st
*
ptr
,
MCD_SERVER
server
,
void
*
context
)
{
char
**
keys
,
**
key
,
*
value
;
memcached_stat_st
stat
;
memcached_return
rc
;
struct
stream_server
*
ss
=
(
struct
stream_server
*
)
context
;
rc
=
memcached_stat_servername
(
&
stat
,
NULL
,
MCD_SERVER_NAME
,
MCD_SERVER_PORT
);
if
(
rc
!=
MEMCACHED_SUCCESS
)
goto
mcache_error
;
keys
=
memcached_stat_get_keys
(
ptr
,
&
stat
,
&
rc
);
if
(
rc
!=
MEMCACHED_SUCCESS
)
goto
mcache_error
;
for
(
key
=
keys
;
*
key
;
key
++
)
{
value
=
memcached_stat_get_value
(
ptr
,
&
stat
,
*
key
,
&
rc
);
if
(
rc
==
MEMCACHED_SUCCESS
&&
value
)
{
server_stat
(
server
,
*
key
,
0
,
value
,
0
,
context
);
switch_safe_free
(
value
);
}
else
{
server_stat
(
server
,
*
key
,
0
,
"N/A"
,
0
,
context
);
}
}
switch_safe_free
(
keys
);
return
MEMCACHED_SUCCESS
;
mcache_error:
ss
->
stream
->
write_function
(
ss
->
stream
,
"-ERR %s
\n
"
,
memcached_strerror
(
ptr
,
rc
));
return
MEMCACHED_SUCCESS
;
}
#endif
SWITCH_STANDARD_API
(
memcache_function
)
{
switch_status_t
status
;
...
...
@@ -157,7 +233,6 @@ SWITCH_STANDARD_API(memcache_function)
memcached_return
rc
;
memcached_st
*
memcached
=
NULL
;
memcached_stat_st
*
stat
=
NULL
;
memcached_server_st
*
server_list
;
if
(
zstr
(
cmd
))
{
goto
usage
;
...
...
@@ -303,41 +378,29 @@ SWITCH_STANDARD_API(memcache_function)
switch_goto_status
(
SWITCH_STATUS_SUCCESS
,
mcache_error
);
}
}
else
if
(
!
strcasecmp
(
subcmd
,
"status"
))
{
switch_bool_t
verbose
=
SWITCH_FALSE
;
int
x
;
if
(
argc
>
1
)
{
if
(
!
strcasecmp
(
argv
[
1
],
"verbose"
))
{
verbose
=
SWITCH_TRUE
;
}
}
struct
stream_server
ss
;
ss
.
stream
=
stream
;
ss
.
server
=
NULL
;
stream
->
write_function
(
stream
,
"Lib version: %s
\n
"
,
memcached_lib_version
());
stat
=
memcached_stat
(
memcached
,
NULL
,
&
rc
);
if
(
rc
!=
MEMCACHED_SUCCESS
&&
rc
!=
MEMCACHED_SOME_ERRORS
)
{
stream
->
write_function
(
stream
,
"-ERR Error communicating with servers (%s)
\n
"
,
memcached_strerror
(
memcached
,
rc
));
}
server_list
=
memcached_server_list
(
memcached
);
server_count
=
memcached_server_count
(
memcached
);
stream
->
write_function
(
stream
,
"Servers: %d
\n
"
,
server_count
);
for
(
x
=
0
;
x
<
server_count
;
x
++
)
{
stream
->
write_function
(
stream
,
" %s (%u)
\n
"
,
memcached_server_name
(
memcached
,
server_list
[
x
]),
memcached_server_port
(
memcached
,
server_list
[
x
]));
if
(
verbose
==
SWITCH_TRUE
)
{
char
**
list
;
char
**
ptr
;
char
*
value
;
memcached_return
rc2
;
list
=
memcached_stat_get_keys
(
memcached
,
&
stat
[
x
],
&
rc
);
for
(
ptr
=
list
;
*
ptr
;
ptr
++
)
{
value
=
memcached_stat_get_value
(
memcached
,
&
stat
[
x
],
*
ptr
,
&
rc2
);
stream
->
write_function
(
stream
,
" %s: %s
\n
"
,
*
ptr
,
value
);
switch_safe_free
(
value
);
}
switch_safe_free
(
list
);
stream
->
write_function
(
stream
,
"
\n
"
);
}
if
(
argc
>
1
&&
!
strcasecmp
(
argv
[
1
],
"verbose"
))
{
#if HAVE_MEMCACHED_STAT_EXECUTE
rc
=
memcached_stat_execute
(
memcached
,
NULL
,
server_stat
,
(
void
*
)
&
ss
);
#else
memcached_server_function
callbacks
[]
=
{
(
memcached_server_function
)
server_stats
};
rc
=
memcached_server_cursor
(
memcached
,
callbacks
,
(
void
*
)
&
ss
,
1
);
#endif
}
else
{
memcached_server_function
callbacks
[]
=
{
(
memcached_server_function
)
server_show
};
rc
=
memcached_server_cursor
(
memcached
,
callbacks
,
(
void
*
)
&
ss
,
1
);
}
if
(
rc
!=
MEMCACHED_SUCCESS
)
{
switch_goto_status
(
SWITCH_STATUS_SUCCESS
,
mcache_error
);
}
}
else
{
goto
usage
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论