Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
4e723e67
Commit
4e723e67
authored
Aug 27, 2002
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup of libpq connection timeout code.
parent
78a693c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
47 deletions
+47
-47
src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/fe-connect.c
+47
-47
No files found.
src/interfaces/libpq/fe-connect.c
View file @
4e723e67
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.19
4 2002/08/18 01:35:39
momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.19
5 2002/08/27 14:49:52
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1063,34 +1063,33 @@ connectDBComplete(PGconn *conn)
if
(
conn
==
NULL
||
conn
->
status
==
CONNECTION_BAD
)
return
0
;
/*
* Prepare to time calculations, if connect_timeout isn't zero.
*/
if
(
conn
->
connect_timeout
!=
NULL
)
/*
* Prepare to time calculations, if connect_timeout isn't zero.
*/
if
(
conn
->
connect_timeout
!=
NULL
)
{
remains
.
tv_sec
=
atoi
(
conn
->
connect_timeout
);
if
(
!
remains
.
tv_sec
)
{
conn
->
status
=
CONNECTION_BAD
;
return
0
;
}
remains
.
tv_usec
=
0
;
rp
=
&
remains
;
}
remains
.
tv_sec
=
atoi
(
conn
->
connect_timeout
);
if
(
!
remains
.
tv_sec
)
{
conn
->
status
=
CONNECTION_BAD
;
return
0
;
}
remains
.
tv_usec
=
0
;
rp
=
&
remains
;
}
while
(
rp
==
NULL
||
remains
.
tv_sec
>
0
||
(
remains
.
tv_sec
==
0
&&
remains
.
tv_usec
>
0
))
{
/*
* If connecting timeout is set, get current time.
*/
if
(
rp
!=
NULL
&&
gettimeofday
(
&
start_time
,
NULL
)
==
-
1
)
{
conn
->
status
=
CONNECTION_BAD
;
return
0
;
}
while
(
rp
==
NULL
||
remains
.
tv_sec
>
0
||
(
remains
.
tv_sec
==
0
&&
remains
.
tv_usec
>
0
))
{
/*
* If connecting timeout is set, get current time.
*/
if
(
rp
!=
NULL
&&
gettimeofday
(
&
start_time
,
NULL
)
==
-
1
)
{
conn
->
status
=
CONNECTION_BAD
;
return
0
;
}
/*
* Wait, if necessary. Note that the initial state (just after
* PQconnectStart) is to wait for the socket to select for
* writing.
...
...
@@ -1104,7 +1103,7 @@ connectDBComplete(PGconn *conn)
return
1
;
/* success! */
case
PGRES_POLLING_READING
:
if
(
pqWaitTimed
(
1
,
0
,
conn
,
rp
))
if
(
pqWaitTimed
(
1
,
0
,
conn
,
rp
))
{
conn
->
status
=
CONNECTION_BAD
;
return
0
;
...
...
@@ -1130,27 +1129,28 @@ connectDBComplete(PGconn *conn)
*/
flag
=
PQconnectPoll
(
conn
);
/*
* If connecting timeout is set, calculate remain time.
*/
if
(
NULL
!=
rp
)
{
if
(
-
1
==
gettimeofday
(
&
finish_time
,
NULL
))
{
conn
->
status
=
CONNECTION_BAD
;
return
0
;
}
if
(
0
>
(
finish_time
.
tv_usec
-=
start_time
.
tv_usec
))
{
remains
.
tv_sec
++
;
finish_time
.
tv_usec
+=
1000000
;
}
if
(
0
>
(
remains
.
tv_usec
-=
finish_time
.
tv_usec
))
{
remains
.
tv_sec
--
;
remains
.
tv_usec
+=
1000000
;
}
remains
.
tv_sec
-=
finish_time
.
tv_sec
-
start_time
.
tv_sec
;
}
/*
* If connecting timeout is set, calculate remain time.
*/
if
(
NULL
!=
rp
)
{
if
(
gettimeofday
(
&
finish_time
,
NULL
)
==
-
1
)
{
conn
->
status
=
CONNECTION_BAD
;
return
0
;
}
if
((
finish_time
.
tv_usec
-=
start_time
.
tv_usec
)
<
0
)
{
remains
.
tv_sec
++
;
finish_time
.
tv_usec
+=
1000000
;
}
if
((
remains
.
tv_usec
-=
finish_time
.
tv_usec
)
<
0
)
{
remains
.
tv_sec
--
;
remains
.
tv_usec
+=
1000000
;
}
remains
.
tv_sec
-=
finish_time
.
tv_sec
-
start_time
.
tv_sec
;
}
}
conn
->
status
=
CONNECTION_BAD
;
return
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment