Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
facb7200
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
facb7200
编写于
10月 16, 2002
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix connection_timeout to use time() and handle timeout == 1.
Code cleanup.
上级
8a96c50e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
35 deletion
+22
-35
src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/fe-connect.c
+12
-28
src/interfaces/libpq/fe-misc.c
src/interfaces/libpq/fe-misc.c
+7
-5
src/interfaces/libpq/libpq-int.h
src/interfaces/libpq/libpq-int.h
+3
-2
未找到文件。
src/interfaces/libpq/fe-connect.c
浏览文件 @
facb7200
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.21
0 2002/10/15 01:48:25 tgl
Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.21
1 2002/10/16 02:55:30 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1052,10 +1052,7 @@ connectDBComplete(PGconn *conn)
{
PostgresPollingStatusType
flag
=
PGRES_POLLING_WRITING
;
time_t
finish_time
=
0
,
current_time
;
struct
timeval
remains
,
*
rp
=
NULL
;
time_t
finish_time
=
-
1
;
if
(
conn
==
NULL
||
conn
->
status
==
CONNECTION_BAD
)
return
0
;
...
...
@@ -1065,20 +1062,21 @@ connectDBComplete(PGconn *conn)
*/
if
(
conn
->
connect_timeout
!=
NULL
)
{
remains
.
tv_sec
=
atoi
(
conn
->
connect_timeout
);
if
(
!
remains
.
tv_sec
)
int
timeout
=
atoi
(
conn
->
connect_timeout
);
if
(
timeout
==
0
)
{
conn
->
status
=
CONNECTION_BAD
;
return
0
;
}
remains
.
tv_usec
=
0
;
/* We don't use subsecond timing
*/
rp
=
&
remains
;
/* Rounding could cause connection to fail;we need at least 2 secs
*/
if
(
timeout
==
1
)
timeout
++
;
/* calculate the finish time based on start + timeout */
finish_time
=
time
(
(
time_t
*
)
NULL
)
+
remains
.
tv_sec
;
finish_time
=
time
(
NULL
)
+
timeout
;
}
while
(
rp
==
NULL
||
remains
.
tv_sec
>
0
)
while
(
finish_time
==
-
1
||
time
(
NULL
)
>=
finish_time
)
{
/*
* Wait, if necessary. Note that the initial state (just after
...
...
@@ -1094,7 +1092,7 @@ connectDBComplete(PGconn *conn)
return
1
;
/* success! */
case
PGRES_POLLING_READING
:
if
(
pqWaitTimed
(
1
,
0
,
conn
,
rp
))
if
(
pqWaitTimed
(
1
,
0
,
conn
,
finish_time
))
{
conn
->
status
=
CONNECTION_BAD
;
return
0
;
...
...
@@ -1102,7 +1100,7 @@ connectDBComplete(PGconn *conn)
break
;
case
PGRES_POLLING_WRITING
:
if
(
pqWaitTimed
(
0
,
1
,
conn
,
rp
))
if
(
pqWaitTimed
(
0
,
1
,
conn
,
finish_time
))
{
conn
->
status
=
CONNECTION_BAD
;
return
0
;
...
...
@@ -1119,20 +1117,6 @@ connectDBComplete(PGconn *conn)
* Now try to advance the state machine.
*/
flag
=
PQconnectPoll
(
conn
);
/*
* If connecting timeout is set, calculate remaining time.
*/
if
(
rp
!=
NULL
)
{
if
(
time
(
&
current_time
)
==
-
1
)
{
conn
->
status
=
CONNECTION_BAD
;
return
0
;
}
remains
.
tv_sec
=
finish_time
-
current_time
;
}
}
conn
->
status
=
CONNECTION_BAD
;
return
0
;
...
...
src/interfaces/libpq/fe-misc.c
浏览文件 @
facb7200
...
...
@@ -25,7 +25,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.8
3 2002/10/14 18:11:17
momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.8
4 2002/10/16 02:55:30
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -779,11 +779,11 @@ pqFlush(PGconn *conn)
int
pqWait
(
int
forRead
,
int
forWrite
,
PGconn
*
conn
)
{
return
pqWaitTimed
(
forRead
,
forWrite
,
conn
,
(
const
struct
timeval
*
)
NULL
);
return
pqWaitTimed
(
forRead
,
forWrite
,
conn
,
-
1
);
}
int
pqWaitTimed
(
int
forRead
,
int
forWrite
,
PGconn
*
conn
,
const
struct
timeval
*
timeout
)
pqWaitTimed
(
int
forRead
,
int
forWrite
,
PGconn
*
conn
,
time_t
finish_time
)
{
fd_set
input_mask
;
fd_set
output_mask
;
...
...
@@ -820,7 +820,7 @@ retry5:
FD_SET
(
conn
->
sock
,
&
output_mask
);
FD_SET
(
conn
->
sock
,
&
except_mask
);
if
(
NULL
!=
timeout
)
if
(
finish_time
!=
-
1
)
{
/*
* select() may modify timeout argument on some platforms so
...
...
@@ -831,7 +831,9 @@ retry5:
* incorrect timings when select() is interrupted.
* bjm 2002-10-14
*/
tmp_timeout
=
*
timeout
;
if
((
tmp_timeout
.
tv_sec
=
finish_time
-
time
(
NULL
))
<
0
)
tmp_timeout
.
tv_sec
=
0
;
/* possible? */
tmp_timeout
.
tv_usec
=
0
;
ptmp_timeout
=
&
tmp_timeout
;
}
if
(
select
(
conn
->
sock
+
1
,
&
input_mask
,
&
output_mask
,
...
...
src/interfaces/libpq/libpq-int.h
浏览文件 @
facb7200
...
...
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: libpq-int.h,v 1.
59 2002/10/14 17:15:11
momjian Exp $
* $Id: libpq-int.h,v 1.
60 2002/10/16 02:55:30
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -340,7 +340,8 @@ extern int pqReadData(PGconn *conn);
extern
int
pqFlush
(
PGconn
*
conn
);
extern
int
pqSendSome
(
PGconn
*
conn
);
extern
int
pqWait
(
int
forRead
,
int
forWrite
,
PGconn
*
conn
);
extern
int
pqWaitTimed
(
int
forRead
,
int
forWrite
,
PGconn
*
conn
,
const
struct
timeval
*
timeout
);
extern
int
pqWaitTimed
(
int
forRead
,
int
forWrite
,
PGconn
*
conn
,
time_t
finish_time
);
extern
int
pqReadReady
(
PGconn
*
conn
);
extern
int
pqWriteReady
(
PGconn
*
conn
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录