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
6024ac1b
Commit
6024ac1b
authored
Mar 05, 2002
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Back out old version and update with newer patch of:
Fix for non-blocking connections in libpq Bernhard Herzog
parent
66cd6a0f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
60 deletions
+42
-60
src/interfaces/libpq/fe-exec.c
src/interfaces/libpq/fe-exec.c
+1
-1
src/interfaces/libpq/fe-misc.c
src/interfaces/libpq/fe-misc.c
+39
-53
src/interfaces/libpq/libpq-fe.h
src/interfaces/libpq/libpq-fe.h
+1
-5
src/interfaces/libpq/libpq-int.h
src/interfaces/libpq/libpq-int.h
+1
-1
No files found.
src/interfaces/libpq/fe-exec.c
View file @
6024ac1b
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.11
5 2002/03/05 05:20:12
momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.11
6 2002/03/05 06:07:26
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
src/interfaces/libpq/fe-misc.c
View file @
6024ac1b
...
...
@@ -25,7 +25,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.6
6 2002/03/05 05:20:12
momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.6
7 2002/03/05 06:07:26
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -110,20 +110,18 @@ pqPutc(char c, PGconn *conn)
static
int
pqPutBytes
(
const
char
*
s
,
size_t
nbytes
,
PGconn
*
conn
)
{
/*
* Strategy to handle blocking and non-blocking connections: Fill the
* output buffer and flush it repeatedly until either all data has
* been sent or is at least queued in the buffer.
/* Strategy to handle blocking and non-blocking connections: Fill
* the output buffer and flush it repeatedly until either all data
* has been sent or is at least queued in the buffer.
*
* For non-blocking connections, grow the buffer if not all data
fits
*
into it and the buffer can't be sent because the socket would
* block.
* For non-blocking connections, grow the buffer if not all data
*
fits into it and the buffer can't be sent because the socket
*
would
block.
*/
while
(
nbytes
)
{
size_t
avail
,
remaining
;
size_t
avail
,
remaining
;
/* fill the output buffer */
avail
=
Max
(
conn
->
outBufSize
-
conn
->
outCount
,
0
);
...
...
@@ -133,10 +131,8 @@ pqPutBytes(const char *s, size_t nbytes, PGconn *conn)
s
+=
remaining
;
nbytes
-=
remaining
;
/*
* if the data didn't fit completely into the buffer, try to flush
* the buffer
*/
/* if the data didn't fit completely into the buffer, try to
* flush the buffer */
if
(
nbytes
)
{
int
send_result
=
pqSendSome
(
conn
);
...
...
@@ -145,23 +141,21 @@ pqPutBytes(const char *s, size_t nbytes, PGconn *conn)
if
(
send_result
<
0
)
return
EOF
;
/*
*
if not all data could be sent, increase the output buffer,
*
put the rest of s into it and return successfully. This
*
case will only happen in a
non-blocking connection
/*
if not all data could be sent, increase the output
*
buffer, put the rest of s into it and return
*
successfully. This case will only happen in a
* non-blocking connection
*/
if
(
send_result
>
0
)
{
/*
*
try to grow the buffer. FIXME: The new size could b
e
*
chosen more
intelligently.
/*
try to grow the buffer.
*
FIXME: The new size could be chosen mor
e
* intelligently.
*/
size_t
buflen
=
conn
->
outCount
+
nbytes
;
if
(
buflen
>
conn
->
outBufSize
)
{
char
*
newbuf
=
realloc
(
conn
->
outBuffer
,
buflen
);
char
*
newbuf
=
realloc
(
conn
->
outBuffer
,
buflen
);
if
(
!
newbuf
)
{
/* realloc failed. Probably out of memory */
...
...
@@ -181,10 +175,8 @@ pqPutBytes(const char *s, size_t nbytes, PGconn *conn)
}
}
/*
* pqSendSome was able to send all data. Continue with the next
* chunk of s.
*/
/* pqSendSome was able to send all data. Continue with the next
* chunk of s. */
}
/* while */
return
0
;
...
...
@@ -631,19 +623,11 @@ definitelyFailed:
return
-
1
;
}
/* pqSendSome: send any data waiting in the output buffer and return 0
* if all data was sent, -1 if an error occurred or 1 if not all data
* could be written because the socket would have blocked.
*
* For a blocking connection all data will be sent unless an error
* occurrs. -1 will only be returned if the connection is non-blocking.
*
* Internally, the case of data remaining in the buffer after pqSendSome
* could be determined by looking at outCount, but this function also
* serves as the implementation of the new API function PQsendsome.
/*
* pqSendSome: send any data waiting in the output buffer.
*
*
FIXME: perhaps it would be more useful to return the number of bytes
*
remaining?
*
Return 0 on sucess, -1 on failure and 1 when data remains because the
*
socket would block and the connection is non-blocking.
*/
int
pqSendSome
(
PGconn
*
conn
)
...
...
@@ -655,7 +639,7 @@ pqSendSome(PGconn *conn)
{
printfPQExpBuffer
(
&
conn
->
errorMessage
,
libpq_gettext
(
"connection not open
\n
"
));
return
EOF
;
return
-
1
;
}
/*
...
...
@@ -778,6 +762,7 @@ pqSendSome(PGconn *conn)
}
/*
* pqFlush: send any data waiting in the output buffer
*
...
...
@@ -790,7 +775,9 @@ int
pqFlush
(
PGconn
*
conn
)
{
if
(
pqSendSome
(
conn
))
{
return
EOF
;
}
return
0
;
}
...
...
@@ -812,7 +799,7 @@ pqWait(int forRead, int forWrite, PGconn *conn)
{
printfPQExpBuffer
(
&
conn
->
errorMessage
,
libpq_gettext
(
"connection not open
\n
"
));
return
-
1
;
return
EOF
;
}
if
(
forRead
||
forWrite
)
...
...
@@ -919,7 +906,6 @@ const char *
winsock_strerror
(
int
eno
)
{
static
char
err_buf
[
512
];
#define WSSE_MAXLEN (sizeof(err_buf)-1-13)
/* 13 for " (0x00000000)" */
int
length
;
...
...
src/interfaces/libpq/libpq-fe.h
View file @
6024ac1b
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: libpq-fe.h,v 1.8
2 2002/03/05 05:20:12
momjian Exp $
* $Id: libpq-fe.h,v 1.8
3 2002/03/05 06:07:26
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -282,10 +282,6 @@ extern int PQisnonblocking(const PGconn *conn);
/* Force the write buffer to be written (or at least try) */
extern
int
PQflush
(
PGconn
*
conn
);
/*
* Force the write buffer to be written (or at least try)
* (better than PQflush)
*/
extern
int
PQsendSome
(
PGconn
*
conn
);
/*
...
...
src/interfaces/libpq/libpq-int.h
View file @
6024ac1b
...
...
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: libpq-int.h,v 1.4
5 2002/03/05 05:20:12
momjian Exp $
* $Id: libpq-int.h,v 1.4
6 2002/03/05 06:07:27
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
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