Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
8b4e080e
Commit
8b4e080e
authored
Jul 07, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3d6f9eb0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
14 deletions
+32
-14
go/zodb/storage/zeo/zeo.go
go/zodb/storage/zeo/zeo.go
+32
-14
No files found.
go/zodb/storage/zeo/zeo.go
View file @
8b4e080e
...
@@ -39,7 +39,7 @@ import (
...
@@ -39,7 +39,7 @@ import (
)
)
type
zeo
struct
{
type
zeo
struct
{
srv
*
zLink
srv
*
zLink
// XXX rename -> link?
// state we get from server by way of server notifications.
// state we get from server by way of server notifications.
mu
sync
.
Mutex
mu
sync
.
Mutex
...
@@ -65,7 +65,7 @@ func (z *zeo) Sync(ctx context.Context) (head zodb.Tid, err error) {
...
@@ -65,7 +65,7 @@ func (z *zeo) Sync(ctx context.Context) (head zodb.Tid, err error) {
return
zodb
.
InvalidTid
,
err
return
zodb
.
InvalidTid
,
err
}
}
head
,
ok
:=
tidUnpack
(
xhead
)
head
,
ok
:=
z
.
srv
.
tidUnpack
(
xhead
)
if
!
ok
{
if
!
ok
{
return
zodb
.
InvalidTid
,
rpc
.
ereplyf
(
"got %v; expect tid"
,
xhead
)
return
zodb
.
InvalidTid
,
rpc
.
ereplyf
(
"got %v; expect tid"
,
xhead
)
}
}
...
@@ -96,7 +96,7 @@ func (z *zeo) _Load(ctx context.Context, xid zodb.Xid) (*mem.Buf, zodb.Tid, erro
...
@@ -96,7 +96,7 @@ func (z *zeo) _Load(ctx context.Context, xid zodb.Xid) (*mem.Buf, zodb.Tid, erro
}
}
data
,
ok1
:=
res
[
0
]
.
(
string
)
data
,
ok1
:=
res
[
0
]
.
(
string
)
serial
,
ok2
:=
tidUnpack
(
res
[
1
])
serial
,
ok2
:=
z
.
srv
.
tidUnpack
(
res
[
1
])
// next_serial (res[2]) - just ignore
// next_serial (res[2]) - just ignore
if
!
(
ok1
&&
ok2
)
{
if
!
(
ok1
&&
ok2
)
{
...
@@ -188,7 +188,7 @@ func (r rpc) excError(exc string, argv []interface{}) error {
...
@@ -188,7 +188,7 @@ func (r rpc) excError(exc string, argv []interface{}) error {
return
r
.
ereplyf
(
"poskeyerror: got %#v; expect 1-tuple"
,
argv
...
)
return
r
.
ereplyf
(
"poskeyerror: got %#v; expect 1-tuple"
,
argv
...
)
}
}
oid
,
ok
:=
oidUnpack
(
argv
[
0
])
oid
,
ok
:=
r
.
zl
.
oidUnpack
(
argv
[
0
])
if
!
ok
{
if
!
ok
{
return
r
.
ereplyf
(
"poskeyerror: got (%v); expect (oid)"
,
argv
[
0
])
return
r
.
ereplyf
(
"poskeyerror: got (%v); expect (oid)"
,
argv
[
0
])
}
}
...
@@ -368,7 +368,7 @@ func openByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (_ zodb
...
@@ -368,7 +368,7 @@ func openByURL(ctx context.Context, u *url.URL, opt *zodb.DriverOptions) (_ zodb
}
}
}
}
lastTid
,
ok
:=
tidUnpack
(
xlastTid
)
// XXX -> xlastTid -> scan
lastTid
,
ok
:=
zl
.
tidUnpack
(
xlastTid
)
// XXX -> xlastTid -> scan
if
!
ok
{
if
!
ok
{
return
nil
,
zodb
.
InvalidTid
,
rpc
.
ereplyf
(
"got %v; expect tid"
,
xlastTid
)
return
nil
,
zodb
.
InvalidTid
,
rpc
.
ereplyf
(
"got %v; expect tid"
,
xlastTid
)
}
}
...
@@ -423,13 +423,31 @@ func init() {
...
@@ -423,13 +423,31 @@ func init() {
// ---- oid/tid packing ----
// ---- oid/tid packing ----
// xuint64Unpack tries to decode packed 8-byte string as bigendian uint64
// xuint64Unpack tries to decode packed 8-byte string as bigendian uint64
func
xuint64Unpack
(
xv
interface
{})
(
uint64
,
bool
)
{
func
(
zl
*
zLink
)
xuint64Unpack
(
xv
interface
{})
(
uint64
,
bool
)
{
switch
zl
.
encoding
{
default
:
panic
(
"bug"
)
case
'Z'
:
v
,
err
:=
pickletools
.
Xstrbytes8
(
xv
)
v
,
err
:=
pickletools
.
Xstrbytes8
(
xv
)
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
false
return
0
,
false
}
}
return
v
,
true
return
v
,
true
case
'M'
:
switch
v
:=
xv
.
(
type
)
{
default
:
return
0
,
false
case
[]
byte
:
if
len
(
v
)
!=
8
{
return
0
,
false
}
return
binary
.
BigEndian
.
Uint64
(
v
),
true
}
}
}
}
// xuint64Pack packs v into big-endian 8-byte string
// xuint64Pack packs v into big-endian 8-byte string
...
@@ -449,12 +467,12 @@ func oidPack(oid zodb.Oid) string {
...
@@ -449,12 +467,12 @@ func oidPack(oid zodb.Oid) string {
return
xuint64Pack
(
uint64
(
oid
))
return
xuint64Pack
(
uint64
(
oid
))
}
}
func
tidUnpack
(
xv
interface
{})
(
zodb
.
Tid
,
bool
)
{
func
(
zl
*
zLink
)
tidUnpack
(
xv
interface
{})
(
zodb
.
Tid
,
bool
)
{
v
,
ok
:=
xuint64Unpack
(
xv
)
v
,
ok
:=
zl
.
xuint64Unpack
(
xv
)
return
zodb
.
Tid
(
v
),
ok
return
zodb
.
Tid
(
v
),
ok
}
}
func
oidUnpack
(
xv
interface
{})
(
zodb
.
Oid
,
bool
)
{
func
(
zl
*
zLink
)
oidUnpack
(
xv
interface
{})
(
zodb
.
Oid
,
bool
)
{
v
,
ok
:=
xuint64Unpack
(
xv
)
v
,
ok
:=
zl
.
xuint64Unpack
(
xv
)
return
zodb
.
Oid
(
v
),
ok
return
zodb
.
Oid
(
v
),
ok
}
}
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