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
445ba2bb
Commit
445ba2bb
authored
Apr 29, 2013
by
Martin Blix Grydeland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement VSL_ResetCursor
parent
f6e05865
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
15 deletions
+62
-15
vsl.h
include/vapi/vsl.h
+11
-0
vsl_api.h
lib/libvarnishapi/vsl_api.h
+2
-0
vsl_cursor.c
lib/libvarnishapi/vsl_cursor.c
+49
-15
No files found.
include/vapi/vsl.h
View file @
445ba2bb
...
...
@@ -121,6 +121,17 @@ void VSL_DeleteCursor(struct VSL_cursor *c);
* Delete the cursor pointed to by c
*/
int
VSL_ResetCursor
(
struct
VSL_cursor
*
c
);
/*
* Reset the cursor position to the head, so that the next call to
* VSL_Next returns the first record. For VSM cursor, it will
* point close to the head of the log, but at least 2 segments away
* from the tail.
*
* Return values:
* -1: Operation not supported
*/
int
VSL_Next
(
struct
VSL_cursor
*
c
);
/*
* Return raw pointer to next VSL record.
...
...
lib/libvarnishapi/vsl_api.h
View file @
445ba2bb
...
...
@@ -40,6 +40,7 @@ int vsl_diag(struct VSL_data *vsl, const char *fmt, ...)
typedef
void
vslc_delete_f
(
void
*
);
typedef
int
vslc_next_f
(
void
*
);
typedef
int
vslc_reset_f
(
void
*
);
struct
vslc
{
struct
VSL_cursor
c
;
...
...
@@ -48,6 +49,7 @@ struct vslc {
vslc_delete_f
*
delete
;
vslc_next_f
*
next
;
vslc_reset_f
*
reset
;
};
struct
VSL_data
{
...
...
lib/libvarnishapi/vsl_cursor.c
View file @
445ba2bb
...
...
@@ -144,13 +144,37 @@ vslc_vsm_next(void *cursor)
}
}
static
int
vslc_vsm_reset
(
void
*
cursor
)
{
struct
vslc_vsm
*
c
;
unsigned
segment
;
CAST_OBJ_NOTNULL
(
c
,
cursor
,
VSLC_VSM_MAGIC
);
/*
* Starting (VSL_SEGMENTS - 3) behind varnishd. This way
* even if varnishd wraps immediately, we'll still have a
* full segment worth of log before the general constraint
* of at least 2 segments apart will be broken
*/
segment
=
(
c
->
head
->
segment
+
3
)
%
VSL_SEGMENTS
;
if
(
c
->
head
->
segments
[
segment
]
<
0
)
segment
=
0
;
assert
(
c
->
head
->
segments
[
segment
]
>=
0
);
c
->
next
=
c
->
head
->
log
+
c
->
head
->
segments
[
segment
];
c
->
seq
=
c
->
head
->
seq
;
c
->
c
.
c
.
ptr
=
NULL
;
return
(
0
);
}
struct
VSL_cursor
*
VSL_CursorVSM
(
struct
VSL_data
*
vsl
,
struct
VSM_data
*
vsm
,
int
tail
)
{
struct
vslc_vsm
*
c
;
struct
VSM_fantom
vf
;
struct
VSL_head
*
head
;
unsigned
segment
;
CHECK_OBJ_NOTNULL
(
vsl
,
VSL_MAGIC
);
CHECK_OBJ_NOTNULL
(
vsm
,
VSM_MAGIC
);
...
...
@@ -178,6 +202,7 @@ VSL_CursorVSM(struct VSL_data *vsl, struct VSM_data *vsm, int tail)
c
->
c
.
magic
=
VSLC_MAGIC
;
c
->
c
.
delete
=
vslc_vsm_delete
;
c
->
c
.
next
=
vslc_vsm_next
;
c
->
c
.
reset
=
vslc_vsm_reset
;
c
->
vsm
=
vsm
;
c
->
vf
=
vf
;
...
...
@@ -190,20 +215,9 @@ VSL_CursorVSM(struct VSL_data *vsl, struct VSM_data *vsm, int tail)
c
->
next
=
c
->
head
->
log
+
c
->
head
->
segments
[
c
->
head
->
segment
];
while
(
c
->
next
<
c
->
end
&&
*
c
->
next
!=
VSL_ENDMARKER
)
c
->
next
=
VSL_NEXT
(
c
->
next
);
}
else
{
/*
* Starting (VSL_SEGMENTS - 3) behind varnishd. This way
* even if varnishd wraps immediately, we'll still have a
* full segment worth of log before the general constraint
* of at least 2 segments apart will be broken
*/
segment
=
(
c
->
head
->
segment
+
3
)
%
VSL_SEGMENTS
;
if
(
c
->
head
->
segments
[
segment
]
<
0
)
segment
=
0
;
assert
(
c
->
head
->
segments
[
segment
]
>=
0
);
c
->
next
=
c
->
head
->
log
+
c
->
head
->
segments
[
segment
];
}
c
->
seq
=
c
->
head
->
seq
;
c
->
seq
=
c
->
head
->
seq
;
}
else
AZ
(
vslc_vsm_reset
(
&
c
->
c
));
return
(
&
c
->
c
.
c
);
}
...
...
@@ -284,6 +298,14 @@ vslc_file_next(void *cursor)
return
(
1
);
}
static
int
vslc_file_reset
(
void
*
cursor
)
{
(
void
)
cursor
;
/* XXX: Implement me */
return
(
-
1
);
}
struct
VSL_cursor
*
VSL_CursorFile
(
struct
VSL_data
*
vsl
,
const
char
*
name
)
{
...
...
@@ -328,6 +350,7 @@ VSL_CursorFile(struct VSL_data *vsl, const char *name)
c
->
c
.
magic
=
VSLC_MAGIC
;
c
->
c
.
delete
=
vslc_file_delete
;
c
->
c
.
next
=
vslc_file_next
;
c
->
c
.
reset
=
vslc_file_reset
;
c
->
fd
=
fd
;
c
->
buflen
=
BUFSIZ
;
...
...
@@ -348,6 +371,17 @@ VSL_DeleteCursor(struct VSL_cursor *cursor)
(
c
->
delete
)(
c
);
}
int
VSL_ResetCursor
(
struct
VSL_cursor
*
cursor
)
{
struct
vslc
*
c
;
CAST_OBJ_NOTNULL
(
c
,
(
void
*
)
cursor
,
VSLC_MAGIC
);
if
(
c
->
reset
==
NULL
)
return
(
-
1
);
return
((
c
->
reset
)(
c
));
}
int
VSL_Next
(
struct
VSL_cursor
*
cursor
)
{
...
...
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