Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
3f8a50c0
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3f8a50c0
编写于
10月 04, 2001
作者:
T
Tom Lane
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Plug memory leaks introduced by dynamic-search-path changes.
From Teodor Sigaev.
上级
38633cf8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
47 addition
and
29 deletion
+47
-29
src/backend/utils/fmgr/dfmgr.c
src/backend/utils/fmgr/dfmgr.c
+47
-29
未找到文件。
src/backend/utils/fmgr/dfmgr.c
浏览文件 @
3f8a50c0
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.5
1 2001/09/16 16:11:11 petere
Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.5
2 2001/10/04 19:13:55 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -24,7 +24,7 @@
/*
* List of dynamically loaded files.
* List of dynamically loaded files
(kept in malloc'd memory)
.
*/
typedef
struct
df_files
...
...
@@ -71,25 +71,25 @@ load_external_function(char *filename, char *funcname,
char
*
fullname
;
fullname
=
expand_dynamic_library_name
(
filename
);
if
(
fullname
)
filename
=
fullname
;
if
(
!
fullname
)
fullname
=
pstrdup
(
filename
);
/* at this point fullname is always freshly palloc'd */
/*
* Scan the list of loaded FILES to see if the file has been loaded.
*/
for
(
file_scanner
=
file_list
;
file_scanner
!=
(
DynamicFileList
*
)
NULL
&&
strcmp
(
f
ile
name
,
file_scanner
->
filename
)
!=
0
;
strcmp
(
f
ull
name
,
file_scanner
->
filename
)
!=
0
;
file_scanner
=
file_scanner
->
next
)
;
if
(
file_scanner
==
(
DynamicFileList
*
)
NULL
)
{
/*
* Check for same files - different paths (ie, symlink or link)
*/
if
(
stat
(
f
ile
name
,
&
stat_buf
)
==
-
1
)
elog
(
ERROR
,
"stat failed on file '%s': %m"
,
f
ile
name
);
if
(
stat
(
f
ull
name
,
&
stat_buf
)
==
-
1
)
elog
(
ERROR
,
"stat failed on file '%s': %m"
,
f
ull
name
);
for
(
file_scanner
=
file_list
;
file_scanner
!=
(
DynamicFileList
*
)
NULL
&&
...
...
@@ -100,27 +100,26 @@ load_external_function(char *filename, char *funcname,
if
(
file_scanner
==
(
DynamicFileList
*
)
NULL
)
{
/*
* File not loaded yet.
*/
file_scanner
=
(
DynamicFileList
*
)
malloc
(
sizeof
(
DynamicFileList
)
+
strlen
(
f
ile
name
));
malloc
(
sizeof
(
DynamicFileList
)
+
strlen
(
f
ull
name
));
if
(
file_scanner
==
NULL
)
elog
(
ERROR
,
"Out of memory in load_external_function"
);
MemSet
((
char
*
)
file_scanner
,
0
,
sizeof
(
DynamicFileList
));
strcpy
(
file_scanner
->
filename
,
f
ile
name
);
strcpy
(
file_scanner
->
filename
,
f
ull
name
);
file_scanner
->
device
=
stat_buf
.
st_dev
;
file_scanner
->
inode
=
stat_buf
.
st_ino
;
file_scanner
->
next
=
(
DynamicFileList
*
)
NULL
;
file_scanner
->
handle
=
pg_dlopen
(
f
ile
name
);
file_scanner
->
handle
=
pg_dlopen
(
f
ull
name
);
if
(
file_scanner
->
handle
==
(
void
*
)
NULL
)
{
load_error
=
(
char
*
)
pg_dlerror
();
free
((
char
*
)
file_scanner
);
elog
(
ERROR
,
"Load of file %s failed: %s"
,
f
ile
name
,
load_error
);
elog
(
ERROR
,
"Load of file %s failed: %s"
,
f
ull
name
,
load_error
);
}
/* OK to link it into list */
...
...
@@ -135,13 +134,17 @@ load_external_function(char *filename, char *funcname,
* If funcname is NULL, we only wanted to load the file.
*/
if
(
funcname
==
(
char
*
)
NULL
)
{
pfree
(
fullname
);
return
(
PGFunction
)
NULL
;
}
retval
=
pg_dlsym
(
file_scanner
->
handle
,
funcname
);
if
(
retval
==
(
PGFunction
)
NULL
&&
signalNotFound
)
elog
(
ERROR
,
"Can't find function %s in file %s"
,
funcname
,
f
ile
name
);
elog
(
ERROR
,
"Can't find function %s in file %s"
,
funcname
,
f
ull
name
);
pfree
(
fullname
);
return
retval
;
}
...
...
@@ -159,16 +162,17 @@ load_file(char *filename)
char
*
fullname
;
fullname
=
expand_dynamic_library_name
(
filename
);
if
(
fullname
)
filename
=
fullname
;
if
(
!
fullname
)
fullname
=
pstrdup
(
filename
);
/* at this point fullname is always freshly palloc'd */
/*
* We need to do stat() in order to determine whether this is the same
* file as a previously loaded file; it's also handy so as to give a
* good error message if bogus file name given.
*/
if
(
stat
(
f
ile
name
,
&
stat_buf
)
==
-
1
)
elog
(
ERROR
,
"LOAD: could not open file '%s': %m"
,
f
ile
name
);
if
(
stat
(
f
ull
name
,
&
stat_buf
)
==
-
1
)
elog
(
ERROR
,
"LOAD: could not open file '%s': %m"
,
f
ull
name
);
if
(
file_list
!=
(
DynamicFileList
*
)
NULL
)
{
...
...
@@ -197,7 +201,9 @@ load_file(char *filename)
}
}
load_external_function
(
filename
,
(
char
*
)
NULL
,
false
);
load_external_function
(
fullname
,
(
char
*
)
NULL
,
false
);
pfree
(
fullname
);
}
...
...
@@ -235,6 +241,8 @@ file_exists(const char *name)
* find_in_dynamic_libpath below); if that works, return the fully
* expanded file name. If the previous failed, append DLSUFFIX and
* try again. If all fails, return NULL.
*
* A non-NULL result will always be freshly palloc'd.
*/
static
char
*
expand_dynamic_library_name
(
const
char
*
name
)
...
...
@@ -258,6 +266,7 @@ expand_dynamic_library_name(const char *name)
full
=
substitute_libpath_macro
(
name
);
if
(
file_exists
(
full
))
return
full
;
pfree
(
full
);
}
new
=
palloc
(
strlen
(
name
)
+
strlen
(
DLSUFFIX
)
+
1
);
...
...
@@ -274,15 +283,20 @@ expand_dynamic_library_name(const char *name)
else
{
full
=
substitute_libpath_macro
(
new
);
pfree
(
new
);
if
(
file_exists
(
full
))
return
full
;
pfree
(
full
);
}
return
NULL
;
}
/*
* Substitute for any macros appearing in the given string.
* Result is always freshly palloc'd.
*/
static
char
*
substitute_libpath_macro
(
const
char
*
name
)
{
...
...
@@ -302,7 +316,7 @@ substitute_libpath_macro(const char * name)
elog
(
ERROR
,
"invalid macro name in dynamic library path"
);
if
(
name
[
macroname_len
]
==
'\0'
)
return
replacement
;
return
pstrdup
(
replacement
)
;
else
{
char
*
new
;
...
...
@@ -319,15 +333,14 @@ substitute_libpath_macro(const char * name)
/*
* Search for a file called 'basename' in the colon-separated search
* path 'path'. If the file is found, the full file name is returned
* in palloced memory. The the file is not found, return NULL.
* path Dynamic_library_path. If the file is found, the full file name
* is returned in freshly palloc'd memory. If the file is not found,
* return NULL.
*/
static
char
*
find_in_dynamic_libpath
(
const
char
*
basename
)
{
const
char
*
p
;
char
*
full
;
size_t
len
;
size_t
baselen
;
AssertArg
(
basename
!=
NULL
);
...
...
@@ -340,9 +353,12 @@ find_in_dynamic_libpath(const char * basename)
baselen
=
strlen
(
basename
);
do
{
for
(;;)
{
size_t
len
;
char
*
piece
;
const
char
*
mangled
;
char
*
mangled
;
char
*
full
;
len
=
strcspn
(
p
,
":"
);
...
...
@@ -354,6 +370,7 @@ find_in_dynamic_libpath(const char * basename)
piece
[
len
]
=
'\0'
;
mangled
=
substitute_libpath_macro
(
piece
);
pfree
(
piece
);
/* only absolute paths */
if
(
mangled
[
0
]
!=
'/'
)
...
...
@@ -361,6 +378,7 @@ find_in_dynamic_libpath(const char * basename)
full
=
palloc
(
strlen
(
mangled
)
+
1
+
baselen
+
1
);
sprintf
(
full
,
"%s/%s"
,
mangled
,
basename
);
pfree
(
mangled
);
if
(
DebugLvl
>
1
)
elog
(
DEBUG
,
"find_in_dynamic_libpath: trying %s"
,
full
);
...
...
@@ -368,13 +386,13 @@ find_in_dynamic_libpath(const char * basename)
if
(
file_exists
(
full
))
return
full
;
pfree
(
piece
);
pfree
(
full
);
if
(
p
[
len
]
==
'\0'
)
break
;
else
p
+=
len
+
1
;
}
while
(
1
);
}
return
NULL
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录