Commit cc6a90e4 authored by Tom Lane's avatar Tom Lane

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 smaller
faster and more robust library (mainly because we reduce the number of
malloc's and free's involved in notify processing), plus less pollution
of application link-symbol namespace.
parent b3d58ea7
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# #
# 'make install' installs whole contents of src/include. # 'make install' installs whole contents of src/include.
# #
# $PostgreSQL: pgsql/src/include/Makefile,v 1.14 2004/10/07 16:23:28 momjian Exp $ # $PostgreSQL: pgsql/src/include/Makefile,v 1.15 2004/10/16 22:52:39 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -33,7 +33,6 @@ install: all installdirs remove-old-headers ...@@ -33,7 +33,6 @@ install: all installdirs remove-old-headers
$(INSTALL_DATA) $(srcdir)/port.h $(DESTDIR)$(includedir_internal) $(INSTALL_DATA) $(srcdir)/port.h $(DESTDIR)$(includedir_internal)
$(INSTALL_DATA) $(srcdir)/postgres_fe.h $(DESTDIR)$(includedir_internal) $(INSTALL_DATA) $(srcdir)/postgres_fe.h $(DESTDIR)$(includedir_internal)
$(INSTALL_DATA) $(srcdir)/libpq/pqcomm.h $(DESTDIR)$(includedir_internal)/libpq $(INSTALL_DATA) $(srcdir)/libpq/pqcomm.h $(DESTDIR)$(includedir_internal)/libpq
$(INSTALL_DATA) $(srcdir)/lib/dllist.h $(DESTDIR)$(includedir_internal)/lib
# These headers are needed for server-side development # These headers are needed for server-side development
$(INSTALL_DATA) pg_config.h $(DESTDIR)$(includedir_server) $(INSTALL_DATA) pg_config.h $(DESTDIR)$(includedir_server)
$(INSTALL_DATA) pg_config_os.h $(DESTDIR)$(includedir_server) $(INSTALL_DATA) pg_config_os.h $(DESTDIR)$(includedir_server)
...@@ -71,7 +70,7 @@ remove-old-headers: ...@@ -71,7 +70,7 @@ remove-old-headers:
uninstall: uninstall:
rm -f $(addprefix $(DESTDIR)$(includedir)/, pg_config.h pg_config_os.h postgres_ext.h libpq/libpq-fs.h) rm -f $(addprefix $(DESTDIR)$(includedir)/, pg_config.h pg_config_os.h postgres_ext.h libpq/libpq-fs.h)
rm -f $(addprefix $(DESTDIR)$(includedir_internal)/, c.h postgres_fe.h lib/dllist.h libpq/pqcomm.h) rm -f $(addprefix $(DESTDIR)$(includedir_internal)/, c.h postgres_fe.h libpq/pqcomm.h)
# heuristic... # heuristic...
rm -rf $(addprefix $(DESTDIR)$(includedir_server)/, $(SUBDIRS) *.h) rm -rf $(addprefix $(DESTDIR)$(includedir_server)/, $(SUBDIRS) *.h)
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group # Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California # Portions Copyright (c) 1994, Regents of the University of California
# #
# $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.119 2004/10/16 20:10:56 tgl Exp $ # $PostgreSQL: pgsql/src/interfaces/libpq/Makefile,v 1.120 2004/10/16 22:52:49 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -28,7 +28,7 @@ LIBS := $(patsubst -lpgport,, $(LIBS)) ...@@ -28,7 +28,7 @@ LIBS := $(patsubst -lpgport,, $(LIBS))
OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \ 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 \ fe-protocol2.o fe-protocol3.o pqexpbuffer.o pqsignal.o fe-secure.o \
dllist.o md5.o ip.o wchar.o encnames.o noblock.o pgstrcasecmp.o thread.o \ md5.o ip.o wchar.o encnames.o noblock.o pgstrcasecmp.o thread.o \
$(filter crypt.o getaddrinfo.o inet_aton.o open.o snprintf.o strerror.o, $(LIBOBJS)) $(filter crypt.o getaddrinfo.o inet_aton.o open.o snprintf.o strerror.o, $(LIBOBJS))
ifeq ($(PORTNAME), win32) ifeq ($(PORTNAME), win32)
...@@ -73,9 +73,6 @@ crypt.c getaddrinfo.c inet_aton.c noblock.c pgstrcasecmp.c snprintf.c strerror.c ...@@ -73,9 +73,6 @@ crypt.c getaddrinfo.c inet_aton.c noblock.c pgstrcasecmp.c snprintf.c strerror.c
md5.c ip.c: % : $(backend_src)/libpq/% md5.c ip.c: % : $(backend_src)/libpq/%
rm -f $@ && $(LN_S) $< . rm -f $@ && $(LN_S) $< .
dllist.c: $(backend_src)/lib/dllist.c
rm -f $@ && $(LN_S) $< .
encnames.c wchar.c : % : $(backend_src)/utils/mb/% encnames.c wchar.c : % : $(backend_src)/utils/mb/%
rm -f $@ && $(LN_S) $< . rm -f $@ && $(LN_S) $< .
...@@ -137,7 +134,7 @@ uninstall: uninstall-lib ...@@ -137,7 +134,7 @@ uninstall: uninstall-lib
rm -f $(DESTDIR)$(includedir)/libpq-fe.h $(DESTDIR)$(includedir_internal)/libpq-int.h $(DESTDIR)$(includedir_internal)/pqexpbuffer.h rm -f $(DESTDIR)$(includedir)/libpq-fe.h $(DESTDIR)$(includedir_internal)/libpq-int.h $(DESTDIR)$(includedir_internal)/pqexpbuffer.h
clean distclean: clean-lib clean distclean: clean-lib
rm -f $(OBJS) crypt.c getaddrinfo.c inet_aton.c noblock.c pgstrcasecmp.c snprintf.c strerror.c open.c thread.c dllist.c md5.c ip.c encnames.c wchar.c pthread.h 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
maintainer-clean: distclean maintainer-clean: distclean
rm -f $(srcdir)/libpqdll.def $(srcdir)/libpqddll.def $(srcdir)/blibpqdll.def rm -f $(srcdir)/libpqdll.def $(srcdir)/libpqddll.def $(srcdir)/blibpqdll.def
...@@ -69,7 +69,6 @@ LIB32_OBJS= \ ...@@ -69,7 +69,6 @@ LIB32_OBJS= \
"$(INTDIR)\crypt.obj" \ "$(INTDIR)\crypt.obj" \
"$(INTDIR)\noblock.obj" \ "$(INTDIR)\noblock.obj" \
"$(INTDIR)\pgstrcasecmp.obj" \ "$(INTDIR)\pgstrcasecmp.obj" \
"$(INTDIR)\dllist.obj" \
"$(INTDIR)\md5.obj" \ "$(INTDIR)\md5.obj" \
"$(INTDIR)\ip.obj" \ "$(INTDIR)\ip.obj" \
"$(INTDIR)\fe-auth.obj" \ "$(INTDIR)\fe-auth.obj" \
...@@ -100,7 +99,6 @@ CLEAN : ...@@ -100,7 +99,6 @@ CLEAN :
-@erase "$(INTDIR)\thread.obj" -@erase "$(INTDIR)\thread.obj"
-@erase "$(INTDIR)\inet_aton.obj" -@erase "$(INTDIR)\inet_aton.obj"
-@erase "$(INTDIR)\crypt.obj" -@erase "$(INTDIR)\crypt.obj"
-@erase "$(INTDIR)\dllist.obj"
-@erase "$(INTDIR)\md5.obj" -@erase "$(INTDIR)\md5.obj"
-@erase "$(INTDIR)\ip.obj" -@erase "$(INTDIR)\ip.obj"
-@erase "$(INTDIR)\fe-auth.obj" -@erase "$(INTDIR)\fe-auth.obj"
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.284 2004/08/29 05:07:00 momjian Exp $ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.285 2004/10/16 22:52:49 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1967,7 +1967,6 @@ makeEmptyPGconn(void) ...@@ -1967,7 +1967,6 @@ makeEmptyPGconn(void)
conn->setenv_state = SETENV_STATE_IDLE; conn->setenv_state = SETENV_STATE_IDLE;
conn->client_encoding = PG_SQL_ASCII; conn->client_encoding = PG_SQL_ASCII;
conn->verbosity = PQERRORS_DEFAULT; conn->verbosity = PQERRORS_DEFAULT;
conn->notifyList = DLNewList();
conn->sock = -1; conn->sock = -1;
#ifdef USE_SSL #ifdef USE_SSL
conn->allow_ssl_try = true; conn->allow_ssl_try = true;
...@@ -2013,6 +2012,7 @@ makeEmptyPGconn(void) ...@@ -2013,6 +2012,7 @@ makeEmptyPGconn(void)
static void static void
freePGconn(PGconn *conn) freePGconn(PGconn *conn)
{ {
PGnotify *notify;
pgParameterStatus *pstatus; pgParameterStatus *pstatus;
if (!conn) if (!conn)
...@@ -2047,8 +2047,14 @@ freePGconn(PGconn *conn) ...@@ -2047,8 +2047,14 @@ freePGconn(PGconn *conn)
if (conn->sslmode) if (conn->sslmode)
free(conn->sslmode); free(conn->sslmode);
/* Note that conn->Pfdebug is not ours to close or free */ /* Note that conn->Pfdebug is not ours to close or free */
if (conn->notifyList) notify = conn->notifyHead;
DLFreeList(conn->notifyList); while (notify != NULL)
{
PGnotify *prev = notify;
notify = notify->next;
free(prev);
}
freeaddrinfo_all(conn->addrlist_family, conn->addrlist); freeaddrinfo_all(conn->addrlist_family, conn->addrlist);
pstatus = conn->pstatus; pstatus = conn->pstatus;
while (pstatus != NULL) while (pstatus != NULL)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.162 2004/08/30 02:54:41 momjian Exp $ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-exec.c,v 1.163 2004/10/16 22:52:53 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1323,7 +1323,6 @@ PQexecFinish(PGconn *conn) ...@@ -1323,7 +1323,6 @@ PQexecFinish(PGconn *conn)
PGnotify * PGnotify *
PQnotifies(PGconn *conn) PQnotifies(PGconn *conn)
{ {
Dlelem *e;
PGnotify *event; PGnotify *event;
if (!conn) if (!conn)
...@@ -1332,12 +1331,14 @@ PQnotifies(PGconn *conn) ...@@ -1332,12 +1331,14 @@ PQnotifies(PGconn *conn)
/* Parse any available data to see if we can extract NOTIFY messages. */ /* Parse any available data to see if we can extract NOTIFY messages. */
parseInput(conn); parseInput(conn);
/* RemHead returns NULL if list is empty */ event = conn->notifyHead;
e = DLRemHead(conn->notifyList); if (event)
if (!e) {
return NULL; conn->notifyHead = event->next;
event = (PGnotify *) DLE_VAL(e); if (!conn->notifyHead)
DLFreeElem(e); conn->notifyTail = NULL;
event->next = NULL; /* don't let app see the internal state */
}
return event; return event;
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.14 2004/08/30 02:54:41 momjian Exp $ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol2.c,v 1.15 2004/10/16 22:52:54 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -937,7 +937,12 @@ getNotify(PGconn *conn) ...@@ -937,7 +937,12 @@ getNotify(PGconn *conn)
/* fake up an empty-string extra field */ /* fake up an empty-string extra field */
newNotify->extra = newNotify->relname + nmlen; newNotify->extra = newNotify->relname + nmlen;
newNotify->be_pid = be_pid; newNotify->be_pid = be_pid;
DLAddTail(conn->notifyList, DLNewElem(newNotify)); newNotify->next = NULL;
if (conn->notifyTail)
conn->notifyTail->next = newNotify;
else
conn->notifyHead = newNotify;
conn->notifyTail = newNotify;
} }
return 0; return 0;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.17 2004/10/12 21:54:45 petere Exp $ * $PostgreSQL: pgsql/src/interfaces/libpq/fe-protocol3.c,v 1.18 2004/10/16 22:52:54 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -791,7 +791,12 @@ getNotify(PGconn *conn) ...@@ -791,7 +791,12 @@ getNotify(PGconn *conn)
newNotify->extra = newNotify->relname + nmlen + 1; newNotify->extra = newNotify->relname + nmlen + 1;
strcpy(newNotify->extra, conn->workBuffer.data); strcpy(newNotify->extra, conn->workBuffer.data);
newNotify->be_pid = be_pid; newNotify->be_pid = be_pid;
DLAddTail(conn->notifyList, DLNewElem(newNotify)); newNotify->next = NULL;
if (conn->notifyTail)
conn->notifyTail->next = newNotify;
else
conn->notifyHead = newNotify;
conn->notifyTail = newNotify;
} }
free(svname); free(svname);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.110 2004/10/16 03:26:43 momjian Exp $ * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.111 2004/10/16 22:52:55 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -127,6 +127,8 @@ typedef struct pgNotify ...@@ -127,6 +127,8 @@ typedef struct pgNotify
char *relname; /* notification condition name */ char *relname; /* notification condition name */
int be_pid; /* process ID of server process */ int be_pid; /* process ID of server process */
char *extra; /* notification parameter */ char *extra; /* notification parameter */
/* Fields below here are private to libpq; apps should not use 'em */
struct pgNotify *next; /* list link */
} PGnotify; } PGnotify;
/* Function types for notice-handling callbacks */ /* Function types for notice-handling callbacks */
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.93 2004/10/05 15:09:41 momjian Exp $ * $PostgreSQL: pgsql/src/interfaces/libpq/libpq-int.h,v 1.94 2004/10/16 22:52:55 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -41,7 +41,6 @@ typedef int ssize_t; /* ssize_t doesn't exist in VC (at least ...@@ -41,7 +41,6 @@ typedef int ssize_t; /* ssize_t doesn't exist in VC (at least
/* include stuff common to fe and be */ /* include stuff common to fe and be */
#include "getaddrinfo.h" #include "getaddrinfo.h"
#include "libpq/pqcomm.h" #include "libpq/pqcomm.h"
#include "lib/dllist.h"
/* include stuff found in fe only */ /* include stuff found in fe only */
#include "pqexpbuffer.h" #include "pqexpbuffer.h"
...@@ -272,8 +271,8 @@ struct pg_conn ...@@ -272,8 +271,8 @@ struct pg_conn
char copy_is_binary; /* 1 = copy binary, 0 = copy text */ char copy_is_binary; /* 1 = copy binary, 0 = copy text */
int copy_already_done; /* # bytes already returned in int copy_already_done; /* # bytes already returned in
* COPY OUT */ * COPY OUT */
Dllist *notifyList; /* Notify msgs not yet handed to PGnotify *notifyHead; /* oldest unreported Notify msg */
* application */ PGnotify *notifyTail; /* newest unreported Notify msg */
/* Connection data */ /* Connection data */
int sock; /* Unix FD for socket, -1 if not connected */ int sock; /* Unix FD for socket, -1 if not connected */
......
...@@ -50,7 +50,6 @@ CLEAN : ...@@ -50,7 +50,6 @@ CLEAN :
-@erase "$(INTDIR)\inet_aton.obj" -@erase "$(INTDIR)\inet_aton.obj"
-@erase "$(INTDIR)\crypt.obj" -@erase "$(INTDIR)\crypt.obj"
-@erase "$(INTDIR)\noblock.obj" -@erase "$(INTDIR)\noblock.obj"
-@erase "$(INTDIR)\dllist.obj"
-@erase "$(INTDIR)\md5.obj" -@erase "$(INTDIR)\md5.obj"
-@erase "$(INTDIR)\ip.obj" -@erase "$(INTDIR)\ip.obj"
-@erase "$(INTDIR)\fe-auth.obj" -@erase "$(INTDIR)\fe-auth.obj"
...@@ -117,7 +116,6 @@ LIB32_OBJS= \ ...@@ -117,7 +116,6 @@ LIB32_OBJS= \
"$(INTDIR)\inet_aton.obj" \ "$(INTDIR)\inet_aton.obj" \
"$(INTDIR)\crypt.obj" \ "$(INTDIR)\crypt.obj" \
"$(INTDIR)\noblock.obj" \ "$(INTDIR)\noblock.obj" \
"$(INTDIR)\dllist.obj" \
"$(INTDIR)\md5.obj" \ "$(INTDIR)\md5.obj" \
"$(INTDIR)\ip.obj" \ "$(INTDIR)\ip.obj" \
"$(INTDIR)\fe-auth.obj" \ "$(INTDIR)\fe-auth.obj" \
...@@ -192,12 +190,6 @@ LINK32_OBJS= \ ...@@ -192,12 +190,6 @@ LINK32_OBJS= \
$(CPP_PROJ) ..\..\port\noblock.c $(CPP_PROJ) ..\..\port\noblock.c
<< <<
"$(INTDIR)\dllist.obj" : ..\..\backend\lib\dllist.c
$(CPP) @<<
$(CPP_PROJ) ..\..\backend\lib\dllist.c
<<
"$(INTDIR)\md5.obj" : ..\..\backend\libpq\md5.c "$(INTDIR)\md5.obj" : ..\..\backend\libpq\md5.c
$(CPP) @<< $(CPP) @<<
$(CPP_PROJ) ..\..\backend\libpq\md5.c $(CPP_PROJ) ..\..\backend\libpq\md5.c
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment