Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
def13d18
提交
def13d18
authored
3月 29, 2018
作者:
Andrey Volk
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-11074: [Core, Build-System] Add PostgreSQL to the Freeswitch Core on Windows.
上级
0dc3cd40
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
121 行增加
和
3 行删除
+121
-3
.gitignore
libs/.gitignore
+2
-0
switch_pgsql.c
src/switch_pgsql.c
+27
-3
FreeSwitchCore.2015.vcxproj
w32/Library/FreeSwitchCore.2015.vcxproj
+1
-0
libpq-version.props
w32/libpq-version.props
+19
-0
libpq.props
w32/libpq.props
+72
-0
没有找到文件。
libs/.gitignore
浏览文件 @
def13d18
...
...
@@ -844,3 +844,5 @@ tiff-4.0.2/configure
unimrcp/configure
zlib-*/
zlib-*
libpq-*/
libpq-*
src/switch_pgsql.c
浏览文件 @
def13d18
...
...
@@ -39,7 +39,12 @@
#ifdef SWITCH_HAVE_PGSQL
#include <libpq-fe.h>
#ifndef _WIN32
#include <poll.h>
#else
#include <winsock2.h>
#endif
struct
switch_pgsql_handle
{
...
...
@@ -253,6 +258,7 @@ SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_send_query(switch_pgsql_handl
if
(
!
PQsendQuery
(
handle
->
con
,
sql
))
{
err_str
=
switch_pgsql_handle_get_error
(
handle
);
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"Failed to send query (%s) to database: %s
\n
"
,
sql
,
err_str
);
switch_safe_free
(
err_str
);
switch_pgsql_finish_results
(
handle
);
goto
error
;
}
...
...
@@ -292,7 +298,11 @@ SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_next_result_timed(switch_pgsq
switch_time_t
ctime
;
unsigned
int
usec
=
msec
*
1000
;
char
*
err_str
;
struct
pollfd
fds
[
2
]
=
{
{
0
}
};
#ifndef _WIN32
struct
pollfd
fds
[
2
]
=
{
{
0
}
};
#else
fd_set
rs
,
es
;
#endif
int
poll_res
=
0
;
if
(
!
handle
)
{
...
...
@@ -309,6 +319,8 @@ SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_next_result_timed(switch_pgsq
start
=
switch_micro_time_now
();
while
((
ctime
=
switch_micro_time_now
())
-
start
<=
usec
)
{
int
wait_time
=
(
usec
-
(
ctime
-
start
))
/
1000
;
/* Wait for the PostgreSQL socket to be ready for data reads. */
#ifndef _WIN32
fds
[
0
].
fd
=
handle
->
sock
;
fds
[
0
].
events
|=
POLLIN
;
fds
[
0
].
events
|=
POLLERR
;
...
...
@@ -318,8 +330,17 @@ SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_next_result_timed(switch_pgsq
fds
[
0
].
events
|=
POLLRDNORM
;
fds
[
0
].
events
|=
POLLRDBAND
;
/* Wait for the PostgreSQL socket to be ready for data reads. */
if
((
poll_res
=
poll
(
&
fds
[
0
],
1
,
wait_time
))
>
0
)
{
poll_res
=
poll
(
&
fds
[
0
],
1
,
wait_time
);
#else
struct
timeval
wait
=
{
wait_time
*
1000
,
0
};
FD_ZERO
(
&
rs
);
FD_SET
(
handle
->
sock
,
&
rs
);
FD_ZERO
(
&
es
);
FD_SET
(
handle
->
sock
,
&
es
);
poll_res
=
select
(
0
,
&
rs
,
0
,
&
es
,
&
wait
);
#endif
if
(
poll_res
>
0
)
{
#ifndef _WIN32
if
(
fds
[
0
].
revents
&
POLLHUP
||
fds
[
0
].
revents
&
POLLNVAL
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"PGSQL socket closed or invalid while waiting for result for query (%s)
\n
"
,
handle
->
sql
);
goto
error
;
...
...
@@ -327,6 +348,9 @@ SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_next_result_timed(switch_pgsq
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_CRIT
,
"Poll error trying to read PGSQL socket for query (%s)
\n
"
,
handle
->
sql
);
goto
error
;
}
else
if
(
fds
[
0
].
revents
&
POLLIN
||
fds
[
0
].
revents
&
POLLPRI
||
fds
[
0
].
revents
&
POLLRDNORM
||
fds
[
0
].
revents
&
POLLRDBAND
)
{
#else
if
(
FD_ISSET
(
handle
->
sock
,
&
rs
))
{
#endif
/* Then try to consume any input waiting. */
if
(
PQconsumeInput
(
handle
->
con
))
{
if
(
PQstatus
(
handle
->
con
)
==
CONNECTION_BAD
)
{
...
...
w32/Library/FreeSwitchCore.2015.vcxproj
浏览文件 @
def13d18
...
...
@@ -47,6 +47,7 @@
<PlatformToolset>
v140
</PlatformToolset>
</PropertyGroup>
<Import
Project=
"$(VCTargetsPath)\Microsoft.Cpp.props"
/>
<Import
Project=
"$(SolutionDir)\w32\libpq.props"
/>
<Import
Project=
"$(SolutionDir)\w32\openssl.props"
/>
<Import
Project=
"$(SolutionDir)\w32\curl.props"
/>
<ImportGroup
Label=
"ExtensionSettings"
>
...
...
w32/libpq-version.props
0 → 100644
浏览文件 @
def13d18
<?xml version="1.0" encoding="utf-8"?>
<Project
ToolsVersion=
"4.0"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<ImportGroup
Label=
"PropertySheets"
>
<Import
Project=
"basedir.props"
Condition=
" '$(BaseDirImported)' == ''"
/>
</ImportGroup>
<PropertyGroup
Label=
"UserMacros"
>
<libpqVersion>
10.3
</libpqVersion>
</PropertyGroup>
<PropertyGroup>
<libpqVersionImported>
true
</libpqVersionImported>
</PropertyGroup>
<PropertyGroup
/>
<ItemDefinitionGroup
/>
<ItemGroup>
<BuildMacro
Include=
"libpqVersion"
>
<Value>
$(libpqVersion)
</Value>
</BuildMacro>
</ItemGroup>
</Project>
w32/libpq.props
0 → 100644
浏览文件 @
def13d18
<?xml version="1.0" encoding="utf-8"?>
<Project
DefaultTargets=
"Build"
ToolsVersion=
"4.0"
xmlns=
"http://schemas.microsoft.com/developer/msbuild/2003"
>
<ImportGroup
Label=
"PropertySheets"
>
<Import
Project=
"libpq-version.props"
Condition=
" '$(libpqVersionImported)' == '' "
/>
<Import
Project=
"downloadpackage.task"
Condition=
" '$(downloadpackagetask_Imported)' == '' "
/>
</ImportGroup>
<PropertyGroup
Label=
"UserMacros"
>
<libpqlibDir>
$(BaseDir)libs\libpq-$(libpqVersion)
</libpqlibDir>
</PropertyGroup>
<!--
Download Target.
Name must be unique.
By design, targets are executed only once per project.
Usage:
package: URI
expectfileordirectory: Skips the download and extraction if exists
outputfolder: Folder to store a downloaded file.
By default "$(BaseDir)libs", if empty
outputfilename: If not empty, overrides filename from URI.
.exe files don't get extracted
extractto: Folder to extract an archive to
-->
<Target
Name=
"libpqBinariesDownloadTarget"
BeforeTargets=
"CustomBuild"
DependsOnTargets=
"7za"
>
<DownloadPackageTask
package=
"http://files.freeswitch.org/windows/packages/libpq/$(libpqVersion)/libpq-$(libpqVersion)-binaries-$(Platform.ToLower())-$(Configuration.ToLower()).zip"
expectfileordirectory=
"$(libpqlibDir)\binaries\$(Platform)\$(Configuration)\libpq.dll"
outputfolder=
""
outputfilename=
""
extractto=
"$(BaseDir)libs\"
/>
</Target>
<Target
Name=
"libpqHeadersDownloadTarget"
BeforeTargets=
"CustomBuild"
DependsOnTargets=
"7za"
>
<DownloadPackageTask
package=
"http://files.freeswitch.org/windows/packages/libpq/$(libpqVersion)/libpq-$(libpqVersion)-headers.zip"
expectfileordirectory=
"$(libpqlibDir)\include\libpq-fe.h"
outputfolder=
""
outputfilename=
""
extractto=
"$(BaseDir)libs\"
/>
</Target>
<Target
Name=
"libpqcopyTarget"
AfterTargets=
"Build"
DependsOnTargets=
"Build"
>
<ItemGroup>
<libpqFiles
Include=
"$(libpqlibDir)\binaries\$(Platform)\$(Configuration)\*.dll"
/>
</ItemGroup>
<Copy
Condition=
"!exists('$(BaseDir)\$(Platform)\$(Configuration)\libpq.dll')"
SourceFiles=
"@(libpqFiles)"
DestinationFiles=
"@(libpqFiles->'$(BaseDir)\$(Platform)\$(Configuration)\%(Filename)%(Extension)')"
/>
</Target>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>
$(libpqlibDir)\include;%(AdditionalIncludeDirectories)
</AdditionalIncludeDirectories>
<PreprocessorDefinitions>
SWITCH_HAVE_PGSQL;%(PreprocessorDefinitions)
</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalLibraryDirectories>
$(libpqlibDir)\binaries\$(Platform)\$(Configuration)\;%(AdditionalLibraryDirectories)
</AdditionalLibraryDirectories>
<AdditionalDependencies>
libpq.lib;Secur32.lib;%(AdditionalDependencies)
</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
</Project>
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论