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
63619877
Commit
63619877
authored
May 01, 2013
by
Martin Blix Grydeland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a static jump table for the cursors.
parent
b4f9d546
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
27 deletions
+55
-27
vsl_api.h
lib/libvarnishapi/vsl_api.h
+9
-5
vsl_cursor.c
lib/libvarnishapi/vsl_cursor.c
+28
-18
vsl_dispatch.c
lib/libvarnishapi/vsl_dispatch.c
+18
-4
No files found.
lib/libvarnishapi/vsl_api.h
View file @
63619877
...
...
@@ -51,11 +51,7 @@ typedef int vslc_skip_f(void *, ssize_t words);
typedef
int
vslc_ref_f
(
void
*
,
struct
vslc_shmptr
*
ptr
);
typedef
int
vslc_check_f
(
const
void
*
,
const
struct
VSLC_ptr
*
ptr
);
struct
vslc
{
struct
VSL_cursor
c
;
unsigned
magic
;
#define VSLC_MAGIC 0x5007C0DE
struct
vslc_tbl
{
vslc_delete_f
*
delete
;
vslc_next_f
*
next
;
vslc_reset_f
*
reset
;
...
...
@@ -63,6 +59,14 @@ struct vslc {
vslc_check_f
*
check
;
};
struct
vslc
{
struct
VSL_cursor
c
;
unsigned
magic
;
#define VSLC_MAGIC 0x5007C0DE
const
struct
vslc_tbl
*
tbl
;
};
struct
VSL_data
{
unsigned
magic
;
#undef VSL_MAGIC
...
...
lib/libvarnishapi/vsl_cursor.c
View file @
63619877
...
...
@@ -212,6 +212,14 @@ vslc_vsm_skip(void *cursor, ssize_t words)
return
(
0
);
}
static
struct
vslc_tbl
vslc_vsm_tbl
=
{
.
delete
=
vslc_vsm_delete
,
.
next
=
vslc_vsm_next
,
.
reset
=
vslc_vsm_reset
,
.
skip
=
vslc_vsm_skip
,
.
check
=
vslc_vsm_check
,
};
struct
VSL_cursor
*
VSL_CursorVSM
(
struct
VSL_data
*
vsl
,
struct
VSM_data
*
vsm
,
int
tail
)
{
...
...
@@ -245,11 +253,7 @@ VSL_CursorVSM(struct VSL_data *vsl, struct VSM_data *vsm, int tail)
c
->
c
.
c
.
vxid
=
-
1
;
/* N/A to this cursor type */
c
->
c
.
c
.
shmptr_ok
=
1
;
c
->
c
.
magic
=
VSLC_MAGIC
;
c
->
c
.
delete
=
vslc_vsm_delete
;
c
->
c
.
next
=
vslc_vsm_next
;
c
->
c
.
reset
=
vslc_vsm_reset
;
c
->
c
.
skip
=
vslc_vsm_skip
;
c
->
c
.
check
=
vslc_vsm_check
;
c
->
c
.
tbl
=
&
vslc_vsm_tbl
;
c
->
vsm
=
vsm
;
c
->
vf
=
vf
;
...
...
@@ -356,6 +360,14 @@ vslc_file_reset(void *cursor)
return
(
-
1
);
}
static
struct
vslc_tbl
vslc_file_tbl
=
{
.
delete
=
vslc_file_delete
,
.
next
=
vslc_file_next
,
.
reset
=
vslc_file_reset
,
.
skip
=
NULL
,
.
check
=
NULL
,
};
struct
VSL_cursor
*
VSL_CursorFile
(
struct
VSL_data
*
vsl
,
const
char
*
name
)
{
...
...
@@ -399,9 +411,7 @@ VSL_CursorFile(struct VSL_data *vsl, const char *name)
}
c
->
c
.
c
.
vxid
=
-
1
;
/* N/A to this cursor type */
c
->
c
.
magic
=
VSLC_MAGIC
;
c
->
c
.
delete
=
vslc_file_delete
;
c
->
c
.
next
=
vslc_file_next
;
c
->
c
.
reset
=
vslc_file_reset
;
c
->
c
.
tbl
=
&
vslc_file_tbl
;
c
->
fd
=
fd
;
c
->
buflen
=
BUFSIZ
;
...
...
@@ -417,9 +427,9 @@ VSL_DeleteCursor(struct VSL_cursor *cursor)
struct
vslc
*
c
;
CAST_OBJ_NOTNULL
(
c
,
(
void
*
)
cursor
,
VSLC_MAGIC
);
if
(
c
->
delete
==
NULL
)
if
(
c
->
tbl
->
delete
==
NULL
)
return
;
(
c
->
delete
)(
c
);
(
c
->
tbl
->
delete
)(
c
);
}
int
...
...
@@ -428,9 +438,9 @@ VSL_ResetCursor(struct VSL_cursor *cursor)
struct
vslc
*
c
;
CAST_OBJ_NOTNULL
(
c
,
(
void
*
)
cursor
,
VSLC_MAGIC
);
if
(
c
->
reset
==
NULL
)
if
(
c
->
tbl
->
reset
==
NULL
)
return
(
-
1
);
return
((
c
->
reset
)(
c
));
return
((
c
->
tbl
->
reset
)(
c
));
}
int
...
...
@@ -439,8 +449,8 @@ VSL_Next(struct VSL_cursor *cursor)
struct
vslc
*
c
;
CAST_OBJ_NOTNULL
(
c
,
(
void
*
)
cursor
,
VSLC_MAGIC
);
AN
(
c
->
next
);
return
((
c
->
next
)(
c
));
AN
(
c
->
tbl
->
next
);
return
((
c
->
tbl
->
next
)(
c
));
}
int
...
...
@@ -449,9 +459,9 @@ vsl_skip(struct VSL_cursor *cursor, ssize_t words)
struct
vslc
*
c
;
CAST_OBJ_NOTNULL
(
c
,
(
void
*
)
cursor
,
VSLC_MAGIC
);
if
(
c
->
skip
==
NULL
)
if
(
c
->
tbl
->
skip
==
NULL
)
return
(
-
1
);
return
((
c
->
skip
)(
c
,
words
));
return
((
c
->
tbl
->
skip
)(
c
,
words
));
}
int
...
...
@@ -460,7 +470,7 @@ VSL_Check(const struct VSL_cursor *cursor, const struct VSLC_ptr *ptr)
const
struct
vslc
*
c
;
CAST_OBJ_NOTNULL
(
c
,
(
const
void
*
)
cursor
,
VSLC_MAGIC
);
if
(
c
->
check
==
NULL
)
if
(
c
->
tbl
->
check
==
NULL
)
return
(
-
1
);
return
((
c
->
check
)(
c
,
ptr
));
return
((
c
->
tbl
->
check
)(
c
,
ptr
));
}
lib/libvarnishapi/vsl_dispatch.c
View file @
63619877
...
...
@@ -203,6 +203,14 @@ vslc_raw_reset(void *cursor)
return
(
0
);
}
static
struct
vslc_tbl
vslc_raw_tbl
=
{
.
delete
=
NULL
,
.
next
=
vslc_raw_next
,
.
reset
=
vslc_raw_reset
,
.
skip
=
NULL
,
.
check
=
NULL
,
};
static
int
vslc_vtx_next
(
void
*
cursor
)
{
...
...
@@ -235,6 +243,14 @@ vslc_vtx_reset(void *cursor)
return
(
0
);
}
static
struct
vslc_tbl
vslc_vtx_tbl
=
{
.
delete
=
NULL
,
.
next
=
vslc_vtx_next
,
.
reset
=
vslc_vtx_reset
,
.
skip
=
NULL
,
.
check
=
NULL
,
};
static
void
vslc_vtx_setup
(
struct
vslc_vtx
*
c
,
struct
vtx
*
vtx
,
unsigned
level
)
{
...
...
@@ -245,8 +261,7 @@ vslc_vtx_setup(struct vslc_vtx *c, struct vtx *vtx, unsigned level)
c
->
c
.
c
.
vxid
=
vtx
->
key
.
vxid
;
c
->
c
.
c
.
level
=
level
;
c
->
c
.
magic
=
VSLC_MAGIC
;
c
->
c
.
next
=
vslc_vtx_next
;
c
->
c
.
reset
=
vslc_vtx_reset
;
c
->
c
.
tbl
=
&
vslc_vtx_tbl
;
c
->
magic
=
VSLC_VTX_MAGIC
;
c
->
vtx
=
vtx
;
...
...
@@ -780,8 +795,7 @@ vslq_raw(struct VSLQ *vslq, VSLQ_dispatch_f *func, void *priv)
memset
(
&
rawc
,
0
,
sizeof
rawc
);
rawc
.
c
.
c
.
vxid
=
-
1
;
rawc
.
c
.
magic
=
VSLC_MAGIC
;
rawc
.
c
.
next
=
vslc_raw_next
;
rawc
.
c
.
reset
=
vslc_raw_reset
;
rawc
.
c
.
tbl
=
&
vslc_raw_tbl
;
rawc
.
magic
=
VSLC_RAW_MAGIC
;
pc
[
0
]
=
&
rawc
.
c
.
c
;
pc
[
1
]
=
NULL
;
...
...
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