Skip to content

Commit f4ed650

Browse files
committed
load_file() has to remove pre-existing shlibs that match the new file
on either name or inode; otherwise load_external_function() won't do anything. At least on Linux, it appears that recompiling a shlib leads to a new file with a different inode, so the old code failed to detect a match.
1 parent 3e20a72 commit f4ed650

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

src/backend/utils/fmgr/dfmgr.c

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.64 2003/08/04 02:40:06 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.65 2003/09/07 02:18:01 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -96,7 +96,8 @@ load_external_function(char *filename, char *funcname,
9696
if (stat(fullname, &stat_buf) == -1)
9797
ereport(ERROR,
9898
(errcode_for_file_access(),
99-
errmsg("could not access file \"%s\": %m", fullname)));
99+
errmsg("could not access file \"%s\": %m",
100+
fullname)));
100101

101102
for (file_scanner = file_list;
102103
file_scanner != (DynamicFileList *) NULL &&
@@ -177,7 +178,8 @@ void
177178
load_file(char *filename)
178179
{
179180
DynamicFileList *file_scanner,
180-
*p;
181+
*prv,
182+
*nxt;
181183
struct stat stat_buf;
182184
char *fullname;
183185

@@ -196,31 +198,27 @@ load_file(char *filename)
196198
(errcode_for_file_access(),
197199
errmsg("could not access file \"%s\": %m", fullname)));
198200

199-
if (file_list != (DynamicFileList *) NULL)
201+
/*
202+
* We have to zap all entries in the list that match on either filename
203+
* or inode, else load_external_function() won't do anything.
204+
*/
205+
prv = NULL;
206+
for (file_scanner = file_list; file_scanner != NULL; file_scanner = nxt)
200207
{
201-
if (SAME_INODE(stat_buf, *file_list))
208+
nxt = file_scanner->next;
209+
if (strcmp(fullname, file_scanner->filename) == 0 ||
210+
SAME_INODE(stat_buf, *file_scanner))
202211
{
203-
p = file_list;
204-
file_list = p->next;
205-
pg_dlclose(p->handle);
206-
free((char *) p);
212+
if (prv)
213+
prv->next = nxt;
214+
else
215+
file_list = nxt;
216+
pg_dlclose(file_scanner->handle);
217+
free((char *) file_scanner);
218+
/* prv does not change */
207219
}
208220
else
209-
{
210-
for (file_scanner = file_list;
211-
file_scanner->next != (DynamicFileList *) NULL;
212-
file_scanner = file_scanner->next)
213-
{
214-
if (SAME_INODE(stat_buf, *(file_scanner->next)))
215-
{
216-
p = file_scanner->next;
217-
file_scanner->next = p->next;
218-
pg_dlclose(p->handle);
219-
free((char *) p);
220-
break;
221-
}
222-
}
223-
}
221+
prv = file_scanner;
224222
}
225223

226224
load_external_function(fullname, (char *) NULL, false, (void *) NULL);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy