Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
eaa1c903
Commit
eaa1c903
authored
Jun 21, 2022
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename struct vmod_open to vmod_import and keep it around.
parent
fbf2c986
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
20 deletions
+32
-20
vcc_vmod.c
lib/libvcc/vcc_vmod.c
+32
-20
No files found.
lib/libvcc/vcc_vmod.c
View file @
eaa1c903
...
...
@@ -42,11 +42,12 @@
#include "vmod_abi.h"
#include "vsb.h"
struct
vmod_
open
{
struct
vmod_
import
{
unsigned
magic
;
#define VMOD_
OPEN_MAGIC 0x9995b1f3
#define VMOD_
IMPORT_MAGIC 0x31803a5d
void
*
hdl
;
const
char
*
err
;
const
struct
vmod_data
*
vmd
;
};
struct
vmod_obj
{
...
...
@@ -60,14 +61,14 @@ struct vmod_obj {
static
int
vcc_path_dlopen
(
void
*
priv
,
const
char
*
fn
)
{
struct
vmod_
open
*
vop
;
struct
vmod_
import
*
vim
;
CAST_OBJ_NOTNULL
(
v
op
,
priv
,
VMOD_OPEN
_MAGIC
);
CAST_OBJ_NOTNULL
(
v
im
,
priv
,
VMOD_IMPORT
_MAGIC
);
AN
(
fn
);
v
op
->
hdl
=
dlopen
(
fn
,
RTLD_NOW
|
RTLD_LOCAL
);
if
(
v
op
->
hdl
==
NULL
)
{
v
op
->
err
=
dlerror
();
v
im
->
hdl
=
dlopen
(
fn
,
RTLD_NOW
|
RTLD_LOCAL
);
if
(
v
im
->
hdl
==
NULL
)
{
v
im
->
err
=
dlerror
();
return
(
-
1
);
}
return
(
0
);
...
...
@@ -377,9 +378,9 @@ vcc_ParseImport(struct vcc *tl)
struct
symbol
*
msym
,
*
vsym
;
const
struct
vmod_data
*
vmd
;
struct
vjsn
*
vj
;
struct
vmod_open
vop
[
1
];
struct
vmod_import
*
vim
;
const
struct
vmod_import
*
vimold
;
INIT_OBJ
(
vop
,
VMOD_OPEN_MAGIC
);
t1
=
tl
->
t
;
SkipToken
(
tl
,
ID
);
/* "import" */
...
...
@@ -425,8 +426,11 @@ vcc_ParseImport(struct vcc *tl)
SkipToken
(
tl
,
';'
);
if
(
VFIL_searchpath
(
tl
->
vmod_path
,
vcc_path_dlopen
,
vop
,
fn
,
&
fnpx
))
{
if
(
vop
->
err
==
NULL
)
{
ALLOC_OBJ
(
vim
,
VMOD_IMPORT_MAGIC
);
AN
(
vim
);
if
(
VFIL_searchpath
(
tl
->
vmod_path
,
vcc_path_dlopen
,
vim
,
fn
,
&
fnpx
))
{
if
(
vim
->
err
==
NULL
)
{
VSB_printf
(
tl
->
sb
,
"Could not find VMOD %.*s
\n
"
,
PF
(
mod
));
}
else
{
...
...
@@ -434,22 +438,25 @@ vcc_ParseImport(struct vcc *tl)
"Could not open VMOD %.*s
\n
"
,
PF
(
mod
));
VSB_printf
(
tl
->
sb
,
"
\t
File name: %s
\n
"
,
fnpx
!=
NULL
?
fnpx
:
fn
);
VSB_printf
(
tl
->
sb
,
"
\t
dlerror: %s
\n
"
,
v
op
->
err
);
VSB_printf
(
tl
->
sb
,
"
\t
dlerror: %s
\n
"
,
v
im
->
err
);
}
vcc_ErrWhere
(
tl
,
mod
);
free
(
fnpx
);
FREE_OBJ
(
vim
);
return
;
}
vmd
=
vcc_VmodSanity
(
tl
,
v
op
->
hdl
,
mod
,
fnpx
);
vmd
=
vcc_VmodSanity
(
tl
,
v
im
->
hdl
,
mod
,
fnpx
);
if
(
vmd
==
NULL
||
tl
->
err
)
{
AZ
(
dlclose
(
v
op
->
hdl
));
AZ
(
dlclose
(
v
im
->
hdl
));
free
(
fnpx
);
FREE_OBJ
(
vim
);
return
;
}
if
(
msym
->
extra
!=
NULL
)
{
if
(
!
strcmp
(
msym
->
extra
,
vmd
->
file_id
))
{
CAST_OBJ
(
vimold
,
(
const
void
*
)(
msym
->
extra
),
VMOD_IMPORT_MAGIC
);
if
(
vimold
!=
NULL
)
{
if
(
!
strcmp
(
vimold
->
vmd
->
file_id
,
vmd
->
file_id
))
{
/* Identical import is OK */
}
else
{
VSB_printf
(
tl
->
sb
,
...
...
@@ -457,8 +464,9 @@ vcc_ParseImport(struct vcc *tl)
PF
(
tmod
));
vcc_ErrWhere2
(
tl
,
t1
,
tl
->
t
);
}
AZ
(
dlclose
(
v
op
->
hdl
));
AZ
(
dlclose
(
v
im
->
hdl
));
free
(
fnpx
);
FREE_OBJ
(
vim
);
return
;
}
msym
->
def_b
=
t1
;
...
...
@@ -466,14 +474,17 @@ vcc_ParseImport(struct vcc *tl)
VTAILQ_FOREACH
(
vsym
,
&
tl
->
sym_vmods
,
sideways
)
{
assert
(
vsym
->
kind
==
SYM_VMOD
);
if
(
!
strcmp
(
vsym
->
extra
,
vmd
->
file_id
))
{
CAST_OBJ_NOTNULL
(
vimold
,
(
const
void
*
)(
vsym
->
extra
),
VMOD_IMPORT_MAGIC
);
if
(
!
strcmp
(
vimold
->
vmd
->
file_id
,
vmd
->
file_id
))
{
/* Already loaded under different name */
msym
->
eval_priv
=
vsym
->
eval_priv
;
msym
->
extra
=
vsym
->
extra
;
msym
->
vmod_name
=
vsym
->
vmod_name
;
vcc_VmodSymbols
(
tl
,
msym
);
AZ
(
dlclose
(
v
op
->
hdl
));
AZ
(
dlclose
(
v
im
->
hdl
));
free
(
fnpx
);
FREE_OBJ
(
vim
);
return
;
}
}
...
...
@@ -516,7 +527,8 @@ vcc_ParseImport(struct vcc *tl)
XXXAZ
(
p
);
AN
(
vj
);
msym
->
eval_priv
=
vj
;
msym
->
extra
=
TlDup
(
tl
,
vmd
->
file_id
);
vim
->
vmd
=
vmd
;
msym
->
extra
=
(
const
char
*
)
vim
;
msym
->
vmod_name
=
TlDup
(
tl
,
vmd
->
name
);
vcc_VmodSymbols
(
tl
,
msym
);
...
...
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