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
60a068b3
Commit
60a068b3
authored
Mar 10, 2004
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move non-blocking code into its own /port file, for code clarity.
parent
ae22a6c1
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
53 additions
and
39 deletions
+53
-39
src/Makefile.global.in
src/Makefile.global.in
+2
-2
src/backend/postmaster/pgstat.c
src/backend/postmaster/pgstat.c
+3
-3
src/backend/postmaster/postmaster.c
src/backend/postmaster/postmaster.c
+2
-7
src/include/c.h
src/include/c.h
+1
-15
src/include/port.h
src/include/port.h
+4
-1
src/interfaces/libpq/Makefile
src/interfaces/libpq/Makefile
+4
-4
src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/fe-connect.c
+2
-7
src/port/noblock.c
src/port/noblock.c
+35
-0
No files found.
src/Makefile.global.in
View file @
60a068b3
# -*-makefile-*-
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.17
5 2004/02/10 03:42:42 tgl
Exp $
# $PostgreSQL: pgsql/src/Makefile.global.in,v 1.17
6 2004/03/10 21:12:46 momjian
Exp $
#------------------------------------------------------------------------------
# All PostgreSQL makefiles include this file and use the variables it sets,
...
...
@@ -339,7 +339,7 @@ endif
#
# substitute implementations of the C library
LIBOBJS
=
@LIBOBJS@ path.o pgsleep.o sprompt.o thread.o
LIBOBJS
=
@LIBOBJS@
noblock.o
path.o pgsleep.o sprompt.o thread.o
ifneq
(,$(LIBOBJS))
LIBS
+=
-lpgport
...
...
src/backend/postmaster/pgstat.c
View file @
60a068b3
...
...
@@ -13,7 +13,7 @@
*
* Copyright (c) 2001-2003, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.
59 2004/03/09 05:11:52
momjian Exp $
* $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.
60 2004/03/10 21:12:46
momjian Exp $
* ----------
*/
#include "postgres.h"
...
...
@@ -327,7 +327,7 @@ pgstat_init(void)
* messages will be discarded; backends won't block waiting to send
* messages to the collector.
*/
if
(
FCNTL_NONBLOCK
(
pgStatSock
)
<
0
)
if
(
!
set_noblock
(
pgStatSock
)
)
{
ereport
(
LOG
,
(
errcode_for_socket_access
(),
...
...
@@ -1819,7 +1819,7 @@ pgstat_recvbuffer(void)
* Set the write pipe to nonblock mode, so that we cannot block when
* the collector falls behind.
*/
if
(
FCNTL_NONBLOCK
(
writePipe
)
<
0
)
if
(
!
set_noblock
(
writePipe
)
)
{
ereport
(
LOG
,
(
errcode_for_socket_access
(),
...
...
src/backend/postmaster/postmaster.c
View file @
60a068b3
...
...
@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.37
2 2004/03/09 05:11:52
momjian Exp $
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.37
3 2004/03/10 21:12:46
momjian Exp $
*
* NOTES
*
...
...
@@ -219,11 +219,6 @@ bool Db_user_namespace = false;
char
*
rendezvous_name
;
/* For FNCTL_NONBLOCK */
#if defined(WIN32) || defined(__BEOS__)
long
ioctlsocket_ret
=
1
;
#endif
/* list of library:init-function to be preloaded */
char
*
preload_libraries_string
=
NULL
;
...
...
@@ -2365,7 +2360,7 @@ report_fork_failure_to_client(Port *port, int errnum)
strerror
(
errnum
));
/* Set port to non-blocking. Don't do send() if this fails */
if
(
FCNTL_NONBLOCK
(
port
->
sock
)
<
0
)
if
(
!
set_noblock
(
port
->
sock
)
)
return
;
send
(
port
->
sock
,
buffer
,
strlen
(
buffer
)
+
1
,
0
);
...
...
src/include/c.h
View file @
60a068b3
...
...
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/c.h,v 1.1
59 2004/01/10 23:39:51 neilc
Exp $
* $PostgreSQL: pgsql/src/include/c.h,v 1.1
60 2004/03/10 21:12:46 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -689,20 +689,6 @@ typedef NameData *Name;
#define PG_BINARY_W "w"
#endif
#if !defined(WIN32) && !defined(__BEOS__)
#define FCNTL_NONBLOCK(sock) fcntl(sock, F_SETFL, O_NONBLOCK)
#else
extern
long
ioctlsocket_ret
;
/* Returns non-0 on failure, while fcntl() returns -1 on failure */
#ifdef WIN32
#define FCNTL_NONBLOCK(sock) ((ioctlsocket(sock, FIONBIO, &ioctlsocket_ret) == 0) ? 0 : -1)
#endif
#ifdef __BEOS__
#define FCNTL_NONBLOCK(sock) ((ioctl(sock, FIONBIO, &ioctlsocket_ret) == 0) ? 0 : -1)
#endif
#endif
#if defined(sun) && defined(__sparc__) && !defined(__SVR4)
#include <unistd.h>
#endif
...
...
src/include/port.h
View file @
60a068b3
...
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/port.h,v 1.2
1 2004/03/09 04:49:02
momjian Exp $
* $PostgreSQL: pgsql/src/include/port.h,v 1.2
2 2004/03/10 21:12:46
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -17,6 +17,9 @@
#include <netdb.h>
#endif
/* non-blocking */
bool
set_noblock
(
int
sock
);
/* Portable path handling for Unix/Win32 */
extern
bool
is_absolute_path
(
const
char
*
filename
);
extern
char
*
first_path_separator
(
const
char
*
filename
);
...
...
src/interfaces/libpq/Makefile
View file @
60a068b3
...
...
@@ -4,7 +4,7 @@
#
# Copyright (c) 1994, Regents of the University of California
#
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.9
7 2004/02/02 00:11:31
momjian Exp $
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.9
8 2004/03/10 21:12:46
momjian Exp $
#
#-------------------------------------------------------------------------
...
...
@@ -23,7 +23,7 @@ override CPPFLAGS := -I$(srcdir) $(CPPFLAGS) $(THREAD_CPPFLAGS) -DFRONTEND -DSYS
OBJS
=
fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o
\
fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o
\
dllist.o md5.o ip.o wchar.o encnames.o
\
$(
filter
crypt.o getaddrinfo.o inet_aton.o snprintf.o strerror.o path.o thread.o,
$(LIBOBJS)
)
$(
filter
crypt.o getaddrinfo.o inet_aton.o
nonblock.o
snprintf.o strerror.o path.o thread.o,
$(LIBOBJS)
)
ifeq
($(PORTNAME), win32)
OBJS
+=
win32.o
endif
...
...
@@ -52,7 +52,7 @@ backend_src = $(top_srcdir)/src/backend
# For port modules, this only happens if configure decides the module
# is needed (see filter hack in OBJS, above).
crypt.c getaddrinfo.c inet_aton.c snprintf.c strerror.c path.c thread.c
:
% : $(top_srcdir)/src/port/%
crypt.c getaddrinfo.c inet_aton.c
nonblock.c
snprintf.c strerror.c path.c thread.c
:
% : $(top_srcdir)/src/port/%
rm
-f
$@
&&
$(LN_S)
$<
.
md5.c ip.c
:
% : $(backend_src)/libpq/%
...
...
@@ -78,4 +78,4 @@ uninstall: uninstall-lib
rm
-f
$(DESTDIR)$(includedir)
/libpq-fe.h
$(DESTDIR)$(includedir_internal)
/libpq-int.h
$(DESTDIR)$(includedir_internal)
/pqexpbuffer.h
clean distclean maintainer-clean
:
clean-lib
rm
-f
$(OBJS)
crypt.c getaddrinfo.c inet_aton.c snprintf.c strerror.c path.c thread.c dllist.c md5.c ip.c encnames.c wchar.c
rm
-f
$(OBJS)
crypt.c getaddrinfo.c inet_aton.c
nonblock.c
snprintf.c strerror.c path.c thread.c dllist.c md5.c ip.c encnames.c wchar.c
src/interfaces/libpq/fe-connect.c
View file @
60a068b3
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.26
7 2004/01/09 02:02:43
momjian Exp $
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.26
8 2004/03/10 21:12:47
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -50,11 +50,6 @@
#include "libpq/ip.h"
#include "mb/pg_wchar.h"
/* For FNCTL_NONBLOCK */
#if defined(WIN32) || defined(__BEOS__)
long
ioctlsocket_ret
=
1
;
#endif
#define PGPASSFILE ".pgpass"
/* fall back options if they are not specified by arguments or defined
...
...
@@ -779,7 +774,7 @@ update_db_info(PGconn *conn)
static
int
connectMakeNonblocking
(
PGconn
*
conn
)
{
if
(
FCNTL_NONBLOCK
(
conn
->
sock
)
<
0
)
if
(
!
set_noblock
(
conn
->
sock
)
)
{
char
sebuf
[
256
];
...
...
src/port/noblock.c
0 → 100644
View file @
60a068b3
/*-------------------------------------------------------------------------
*
* noblock.c
* set a file descriptor as non-blocking
*
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/port/noblock.c,v 1.1 2004/03/10 21:12:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres.h"
#include <sys/types.h>
#include <fcntl.h>
bool
set_noblock
(
int
sock
)
{
#if !defined(WIN32) && !defined(__BEOS__)
return
(
fcntl
(
sock
,
F_SETFL
,
O_NONBLOCK
)
!=
-
1
);
#else
long
ioctlsocket_ret
=
1
;
/* Returns non-0 on failure, while fcntl() returns -1 on failure */
#ifdef WIN32
return
(
ioctlsocket
(
sock
,
FIONBIO
,
&
ioctlsocket_ret
)
==
0
);
#endif
#ifdef __BEOS__
return
(
ioctl
(
sock
,
FIONBIO
,
&
ioctlsocket_ret
)
==
0
);
#endif
#endif
}
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