Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnishapi
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
varnishapi
Commits
cd3a1ce3
Commit
cd3a1ce3
authored
Aug 29, 2018
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NewCursorFile fails if the Log is already attached to VSM.
parent
7d76e225
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
cursor.go
pkg/log/cursor.go
+5
-0
cursor_e2e_test.go
pkg/log/cursor_e2e_test.go
+15
-0
No files found.
pkg/log/cursor.go
View file @
cd3a1ce3
...
...
@@ -94,10 +94,15 @@ func (log *Log) NewCursor() (*Cursor, error) {
// NewCursorFile creates a Cursor to read from a binary log file,
// created by varnishlog -w.
//
// Fails if the Log object is already attached to a live Varnish log.
func
(
log
*
Log
)
NewCursorFile
(
path
string
)
(
*
Cursor
,
error
)
{
if
err
:=
log
.
checkNil
();
err
!=
nil
{
return
nil
,
err
}
if
log
.
vsm
!=
nil
{
return
nil
,
errors
.
New
(
"Already attached to a Varnish log"
)
}
C
.
VSL_ResetError
(
log
.
vsl
)
cursor
:=
C
.
VSL_CursorFile
(
log
.
vsl
,
C
.
CString
(
path
),
0
)
if
cursor
==
nil
{
...
...
pkg/log/cursor_e2e_test.go
View file @
cd3a1ce3
...
...
@@ -69,6 +69,21 @@ func TestNewCursor(t *testing.T) {
defer
cn
.
Delete
()
}
func
TestIllegalCursorFile
(
t
*
testing
.
T
)
{
l
:=
New
()
defer
l
.
Release
()
if
err
:=
l
.
Attach
(
""
);
err
!=
nil
{
t
.
Fatal
(
"Attach(default):"
,
err
)
return
}
c
,
err
:=
l
.
NewCursorFile
(
testFile
)
if
err
==
nil
{
t
.
Fatal
(
"Expected NewCursorFile() to fail for attached Log"
)
return
}
c
.
Delete
()
}
func
TestE2ECursor
(
t
*
testing
.
T
)
{
l
:=
New
()
defer
l
.
Release
()
...
...
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