Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcc6a90e

Browse files
committed
Remove dllist.c from libpq. It's overkill for what libpq needs; we can
just stick a list-link into struct PGnotify instead. Result is a smallerfaster and more robust library (mainly because we reduce the number ofmalloc's and free's involved in notify processing), plus less pollutionof application link-symbol namespace.
1 parentb3d58ea commitcc6a90e

File tree

10 files changed

+44
-40
lines changed

10 files changed

+44
-40
lines changed

‎src/include/Makefile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# 'make install' installs whole contents of src/include.
66
#
7-
# $PostgreSQL: pgsql/src/include/Makefile,v 1.14 2004/10/07 16:23:28 momjian Exp $
7+
# $PostgreSQL: pgsql/src/include/Makefile,v 1.15 2004/10/16 22:52:39 tgl Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -33,7 +33,6 @@ install: all installdirs remove-old-headers
3333
$(INSTALL_DATA) $(srcdir)/port.h $(DESTDIR)$(includedir_internal)
3434
$(INSTALL_DATA) $(srcdir)/postgres_fe.h $(DESTDIR)$(includedir_internal)
3535
$(INSTALL_DATA) $(srcdir)/libpq/pqcomm.h $(DESTDIR)$(includedir_internal)/libpq
36-
$(INSTALL_DATA) $(srcdir)/lib/dllist.h $(DESTDIR)$(includedir_internal)/lib
3736
# These headers are needed for server-side development
3837
$(INSTALL_DATA) pg_config.h $(DESTDIR)$(includedir_server)
3938
$(INSTALL_DATA) pg_config_os.h $(DESTDIR)$(includedir_server)
@@ -71,7 +70,7 @@ remove-old-headers:
7170

7271
uninstall:
7372
rm -f$(addprefix$(DESTDIR)$(includedir)/, pg_config.h pg_config_os.h postgres_ext.h libpq/libpq-fs.h)
74-
rm -f$(addprefix$(DESTDIR)$(includedir_internal)/, c.h postgres_fe.hlib/dllist.hlibpq/pqcomm.h)
73+
rm -f$(addprefix$(DESTDIR)$(includedir_internal)/, c.h postgres_fe.h libpq/pqcomm.h)
7574
# heuristic...
7675
rm -rf $(addprefix $(DESTDIR)$(includedir_server)/, $(SUBDIRS) *.h)
7776

‎src/interfaces/libpq/Makefile

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
66
# Portions Copyright (c) 1994, Regents of the University of California
77
#
8-
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.119 2004/10/1620:10:56 tgl Exp $
8+
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.120 2004/10/1622:52:49 tgl Exp $
99
#
1010
#-------------------------------------------------------------------------
1111

@@ -28,7 +28,7 @@ LIBS := $(patsubst -lpgport,, $(LIBS))
2828

2929
OBJS=fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o\
3030
fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o\
31-
dllist.omd5.o ip.o wchar.o encnames.o noblock.o pgstrcasecmp.o thread.o\
31+
md5.o ip.o wchar.o encnames.o noblock.o pgstrcasecmp.o thread.o\
3232
$(filter crypt.o getaddrinfo.o inet_aton.o open.o snprintf.o strerror.o,$(LIBOBJS))
3333

3434
ifeq ($(PORTNAME), win32)
@@ -73,9 +73,6 @@ crypt.c getaddrinfo.c inet_aton.c noblock.c pgstrcasecmp.c snprintf.c strerror.c
7373
md5.cip.c:% :$(backend_src)/libpq/%
7474
rm -f$@&&$(LN_S)$<.
7575

76-
dllist.c:$(backend_src)/lib/dllist.c
77-
rm -f$@&&$(LN_S)$<.
78-
7976
encnames.cwchar.c :% :$(backend_src)/utils/mb/%
8077
rm -f$@&&$(LN_S)$<.
8178

@@ -137,7 +134,7 @@ uninstall: uninstall-lib
137134
rm -f$(DESTDIR)$(includedir)/libpq-fe.h$(DESTDIR)$(includedir_internal)/libpq-int.h$(DESTDIR)$(includedir_internal)/pqexpbuffer.h
138135

139136
cleandistclean: clean-lib
140-
rm -f$(OBJS) crypt.c getaddrinfo.c inet_aton.c noblock.c pgstrcasecmp.c snprintf.c strerror.c open.c thread.cdllist.cmd5.c ip.c encnames.c wchar.c pthread.h
137+
rm -f$(OBJS) crypt.c getaddrinfo.c inet_aton.c noblock.c pgstrcasecmp.c snprintf.c strerror.c open.c thread.c md5.c ip.c encnames.c wchar.c pthread.h
141138

142139
maintainer-clean: distclean
143140
rm -f$(srcdir)/libpqdll.def$(srcdir)/libpqddll.def$(srcdir)/blibpqdll.def

‎src/interfaces/libpq/bcc32.mak

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ LIB32_OBJS= \
6969
"$(INTDIR)\crypt.obj"\
7070
"$(INTDIR)\noblock.obj"\
7171
"$(INTDIR)\pgstrcasecmp.obj"\
72-
"$(INTDIR)\dllist.obj"\
7372
"$(INTDIR)\md5.obj"\
7473
"$(INTDIR)\ip.obj"\
7574
"$(INTDIR)\fe-auth.obj"\
@@ -100,7 +99,6 @@ CLEAN :
10099
-@erase"$(INTDIR)\thread.obj"
101100
-@erase"$(INTDIR)\inet_aton.obj"
102101
-@erase"$(INTDIR)\crypt.obj"
103-
-@erase"$(INTDIR)\dllist.obj"
104102
-@erase"$(INTDIR)\md5.obj"
105103
-@erase"$(INTDIR)\ip.obj"
106104
-@erase"$(INTDIR)\fe-auth.obj"

‎src/interfaces/libpq/fe-connect.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.284 2004/08/29 05:07:00 momjian Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.285 2004/10/16 22:52:49 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1967,7 +1967,6 @@ makeEmptyPGconn(void)
19671967
conn->setenv_state=SETENV_STATE_IDLE;
19681968
conn->client_encoding=PG_SQL_ASCII;
19691969
conn->verbosity=PQERRORS_DEFAULT;
1970-
conn->notifyList=DLNewList();
19711970
conn->sock=-1;
19721971
#ifdefUSE_SSL
19731972
conn->allow_ssl_try= true;
@@ -2013,6 +2012,7 @@ makeEmptyPGconn(void)
20132012
staticvoid
20142013
freePGconn(PGconn*conn)
20152014
{
2015+
PGnotify*notify;
20162016
pgParameterStatus*pstatus;
20172017

20182018
if (!conn)
@@ -2047,8 +2047,14 @@ freePGconn(PGconn *conn)
20472047
if (conn->sslmode)
20482048
free(conn->sslmode);
20492049
/* Note that conn->Pfdebug is not ours to close or free */
2050-
if (conn->notifyList)
2051-
DLFreeList(conn->notifyList);
2050+
notify=conn->notifyHead;
2051+
while (notify!=NULL)
2052+
{
2053+
PGnotify*prev=notify;
2054+
2055+
notify=notify->next;
2056+
free(prev);
2057+
}
20522058
freeaddrinfo_all(conn->addrlist_family,conn->addrlist);
20532059
pstatus=conn->pstatus;
20542060
while (pstatus!=NULL)

‎src/interfaces/libpq/fe-exec.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.162 2004/08/30 02:54:41 momjian Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.163 2004/10/16 22:52:53 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1323,7 +1323,6 @@ PQexecFinish(PGconn *conn)
13231323
PGnotify*
13241324
PQnotifies(PGconn*conn)
13251325
{
1326-
Dlelem*e;
13271326
PGnotify*event;
13281327

13291328
if (!conn)
@@ -1332,12 +1331,14 @@ PQnotifies(PGconn *conn)
13321331
/* Parse any available data to see if we can extract NOTIFY messages. */
13331332
parseInput(conn);
13341333

1335-
/* RemHead returns NULL if list is empty */
1336-
e=DLRemHead(conn->notifyList);
1337-
if (!e)
1338-
returnNULL;
1339-
event= (PGnotify*)DLE_VAL(e);
1340-
DLFreeElem(e);
1334+
event=conn->notifyHead;
1335+
if (event)
1336+
{
1337+
conn->notifyHead=event->next;
1338+
if (!conn->notifyHead)
1339+
conn->notifyTail=NULL;
1340+
event->next=NULL;/* don't let app see the internal state */
1341+
}
13411342
returnevent;
13421343
}
13431344

‎src/interfaces/libpq/fe-protocol2.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.14 2004/08/30 02:54:41 momjian Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.15 2004/10/16 22:52:54 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -937,7 +937,12 @@ getNotify(PGconn *conn)
937937
/* fake up an empty-string extra field */
938938
newNotify->extra=newNotify->relname+nmlen;
939939
newNotify->be_pid=be_pid;
940-
DLAddTail(conn->notifyList,DLNewElem(newNotify));
940+
newNotify->next=NULL;
941+
if (conn->notifyTail)
942+
conn->notifyTail->next=newNotify;
943+
else
944+
conn->notifyHead=newNotify;
945+
conn->notifyTail=newNotify;
941946
}
942947

943948
return0;

‎src/interfaces/libpq/fe-protocol3.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.17 2004/10/12 21:54:45 petere Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.18 2004/10/16 22:52:54 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -791,7 +791,12 @@ getNotify(PGconn *conn)
791791
newNotify->extra=newNotify->relname+nmlen+1;
792792
strcpy(newNotify->extra,conn->workBuffer.data);
793793
newNotify->be_pid=be_pid;
794-
DLAddTail(conn->notifyList,DLNewElem(newNotify));
794+
newNotify->next=NULL;
795+
if (conn->notifyTail)
796+
conn->notifyTail->next=newNotify;
797+
else
798+
conn->notifyHead=newNotify;
799+
conn->notifyTail=newNotify;
795800
}
796801

797802
free(svname);

‎src/interfaces/libpq/libpq-fe.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.110 2004/10/1603:26:43 momjian Exp $
10+
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.111 2004/10/1622:52:55 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -127,6 +127,8 @@ typedef struct pgNotify
127127
char*relname;/* notification condition name */
128128
intbe_pid;/* process ID of server process */
129129
char*extra;/* notification parameter */
130+
/* Fields below here are private to libpq; apps should not use 'em */
131+
structpgNotify*next;/* list link */
130132
}PGnotify;
131133

132134
/* Function types for notice-handling callbacks */

‎src/interfaces/libpq/libpq-int.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.93 2004/10/05 15:09:41 momjian Exp $
15+
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.94 2004/10/16 22:52:55 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -41,7 +41,6 @@ typedef int ssize_t;/* ssize_t doesn't exist in VC (at least
4141
/* include stuff common to fe and be */
4242
#include"getaddrinfo.h"
4343
#include"libpq/pqcomm.h"
44-
#include"lib/dllist.h"
4544
/* include stuff found in fe only */
4645
#include"pqexpbuffer.h"
4746

@@ -272,8 +271,8 @@ struct pg_conn
272271
charcopy_is_binary;/* 1 = copy binary, 0 = copy text */
273272
intcopy_already_done;/* # bytes already returned in
274273
* COPY OUT */
275-
Dllist*notifyList;/*Notify msgs not yet handed to
276-
* application */
274+
PGnotify*notifyHead;/*oldest unreported Notify msg */
275+
PGnotify*notifyTail;/* newest unreported Notify msg */
277276

278277
/* Connection data */
279278
intsock;/* Unix FD for socket, -1 if not connected */

‎src/interfaces/libpq/win32.mak

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ CLEAN :
5050
-@erase"$(INTDIR)\inet_aton.obj"
5151
-@erase"$(INTDIR)\crypt.obj"
5252
-@erase"$(INTDIR)\noblock.obj"
53-
-@erase"$(INTDIR)\dllist.obj"
5453
-@erase"$(INTDIR)\md5.obj"
5554
-@erase"$(INTDIR)\ip.obj"
5655
-@erase"$(INTDIR)\fe-auth.obj"
@@ -117,7 +116,6 @@ LIB32_OBJS= \
117116
"$(INTDIR)\inet_aton.obj"\
118117
"$(INTDIR)\crypt.obj"\
119118
"$(INTDIR)\noblock.obj"\
120-
"$(INTDIR)\dllist.obj"\
121119
"$(INTDIR)\md5.obj"\
122120
"$(INTDIR)\ip.obj"\
123121
"$(INTDIR)\fe-auth.obj"\
@@ -192,12 +190,6 @@ LINK32_OBJS= \
192190
$(CPP_PROJ) ..\..\port\noblock.c
193191
<<
194192

195-
"$(INTDIR)\dllist.obj" : ..\..\backend\lib\dllist.c
196-
$(CPP) @<<
197-
$(CPP_PROJ) ..\..\backend\lib\dllist.c
198-
<<
199-
200-
201193
"$(INTDIR)\md5.obj" : ..\..\backend\libpq\md5.c
202194
$(CPP) @<<
203195
$(CPP_PROJ) ..\..\backend\libpq\md5.c

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp