Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
7729e7d1
Commit
7729e7d1
authored
Feb 28, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
cf3fbe5b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
13 deletions
+27
-13
t/neo/storage/fs1/filestorage.go
t/neo/storage/fs1/filestorage.go
+27
-13
No files found.
t/neo/storage/fs1/filestorage.go
View file @
7729e7d1
...
@@ -108,10 +108,10 @@ func (e *ErrDataRecord) Error() string {
...
@@ -108,10 +108,10 @@ func (e *ErrDataRecord) Error() string {
return
fmt
.
Sprintf
(
"data record @%v: %v: %v"
,
e
.
Pos
,
e
.
Subj
,
e
.
Err
)
return
fmt
.
Sprintf
(
"data record @%v: %v: %v"
,
e
.
Pos
,
e
.
Subj
,
e
.
Err
)
}
}
// XXX -> zodb?
//
//
XXX -> zodb?
var
ErrVersionNonZero
=
errors
.
New
(
"non-zero version"
)
//
var ErrVersionNonZero = errors.New("non-zero version")
var
errPositionBug
=
errors
.
New
(
"software bug: invalid position"
)
var
bugPosition
=
errors
.
New
(
"software bug: invalid position"
)
// noEOF returns err, but changes io.EOF -> io.ErrUnexpectedEOF
// noEOF returns err, but changes io.EOF -> io.ErrUnexpectedEOF
func
noEOF
(
err
error
)
error
{
func
noEOF
(
err
error
)
error
{
...
@@ -144,7 +144,7 @@ func (txnh *TxnHeader) Load(r io.ReaderAt /* *os.File */, pos int64, flags TxnLo
...
@@ -144,7 +144,7 @@ func (txnh *TxnHeader) Load(r io.ReaderAt /* *os.File */, pos int64, flags TxnLo
txnh
.
LenPrev
=
0
txnh
.
LenPrev
=
0
if
pos
<
txnValidFrom
{
if
pos
<
txnValidFrom
{
panic
(
&
ErrTxnRecord
{
pos
,
"read"
,
errPositionBug
})
panic
(
&
ErrTxnRecord
{
pos
,
"read"
,
bugPosition
})
}
}
decodeErr
:=
func
(
format
string
,
a
...
interface
{})
*
ErrTxnRecord
{
decodeErr
:=
func
(
format
string
,
a
...
interface
{})
*
ErrTxnRecord
{
...
@@ -265,9 +265,11 @@ func (txnh *TxnHeader) LoadNext(r io.ReaderAt, flags TxnLoadFlags) error {
...
@@ -265,9 +265,11 @@ func (txnh *TxnHeader) LoadNext(r io.ReaderAt, flags TxnLoadFlags) error {
// decode reads and decodes data record header
// decode reads and decodes data record header
func
(
dh
*
DataHeader
)
load
(
r
io
.
ReaderAt
/* *os.File */
,
pos
int64
,
tmpBuf
*
[
DataHeaderSize
]
byte
)
error
{
func
(
dh
*
DataHeader
)
load
(
r
io
.
ReaderAt
/* *os.File */
,
pos
int64
,
tmpBuf
*
[
DataHeaderSize
]
byte
)
error
{
if
pos
<
dataValidFrom
{
if
pos
<
dataValidFrom
{
panic
(
&
ErrDataRecord
{
pos
,
"read"
,
errPositionBug
})
panic
(
&
ErrDataRecord
{
pos
,
"read"
,
bugPosition
})
}
}
dh
.
Pos
=
pos
_
,
err
:=
r
.
ReadAt
(
tmpBuf
[
:
],
pos
)
_
,
err
:=
r
.
ReadAt
(
tmpBuf
[
:
],
pos
)
if
err
!=
nil
{
if
err
!=
nil
{
return
&
ErrDataRecord
{
pos
,
"read"
,
noEOF
(
err
)}
return
&
ErrDataRecord
{
pos
,
"read"
,
noEOF
(
err
)}
...
@@ -284,22 +286,34 @@ func (dh *DataHeader) load(r io.ReaderAt /* *os.File */, pos int64, tmpBuf *[Dat
...
@@ -284,22 +286,34 @@ func (dh *DataHeader) load(r io.ReaderAt /* *os.File */, pos int64, tmpBuf *[Dat
return
decodeErr
(
"invalid tid: %v"
,
dh
.
Tid
)
return
decodeErr
(
"invalid tid: %v"
,
dh
.
Tid
)
}
}
// XXX check prev data pos:
// < current pos
// > ... (valid)
dh
.
PrevRevPos
=
int64
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
16
:
]))
dh
.
PrevRevPos
=
int64
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
16
:
]))
// XXX txnPos < current pos
// XXX > ... valid
dh
.
TxnPos
=
int64
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
24
:
]))
dh
.
TxnPos
=
int64
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
24
:
]))
if
dh
.
PrevRevPos
<
dataValidFrom
{
return
decodeErr
(
"invalid prev oid data position: %v"
,
dh
.
PrevRevPos
)
}
if
dh
.
TxnPos
<
txnValidFrom
{
return
decodeErr
(
"invalid txn position: %v"
,
dh
.
TxnPos
)
}
if
dh
.
TxnPos
+
TxnHeaderFixSize
>
pos
{
return
decodeErr
(
"txn position not decreasing: %v"
,
dh
.
TxnPos
)
}
if
dh
.
PrevRevPos
+
DataHeaderSize
>
dh
.
TxnPos
-
8
{
return
decodeErr
(
"prev oid data position (%v) overlaps with txn (%v)"
,
dh
.
PrevRevPos
,
dh
.
TxnPos
)
// XXX wording
}
// XXX check PrevRevPos vs TxnPos overlap
verlen
:=
binary
.
BigEndian
.
Uint16
(
tmpBuf
[
32
:
])
verlen
:=
binary
.
BigEndian
.
Uint16
(
tmpBuf
[
32
:
])
if
verlen
!=
0
{
if
verlen
!=
0
{
return
&
ErrDataRecord
{
pos
,
"invalid header"
,
ErrVersionNonZero
}
return
decodeErr
(
"non-zero version: #%v"
,
verlen
)
}
}
// XXX check DataLen >= 0
dh
.
DataLen
=
int64
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
34
:
]))
dh
.
DataLen
=
int64
(
binary
.
BigEndian
.
Uint64
(
tmpBuf
[
34
:
]))
if
dh
.
DataLen
<
0
{
// XXX also check DataLen < max ?
return
decodeErr
(
"invalid data len: %v"
,
dh
.
DataLen
)
}
return
nil
return
nil
...
...
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