Skip to content
Snippets Groups Projects
Commit 43a891bd authored by Vladislav Shpilevoy's avatar Vladislav Shpilevoy
Browse files

swim: do not return raw member tt_uuid pointer

When a member is deleted, pointer at its struct tt_uuid becomes
invalid. This commit makes member:uuid() create a new tt_uuid
object, cached for subsequent calls.
parent ceefd0c8
No related branches found
No related tags found
No related merge requests found
......@@ -391,7 +391,15 @@ end
-- metatable, serialization, string conversions etc.
--
local function swim_member_uuid(m)
return capi.swim_member_uuid(swim_check_member(m, 'member:uuid()'))
local ptr = swim_check_member(m, 'member:uuid()')
local u = m.u
if not u then
ptr = capi.swim_member_uuid(ptr)
u = ffi.new('struct tt_uuid')
ffi.copy(u, ptr, ffi.sizeof('struct tt_uuid'))
rawset(m, 'u', u)
end
return u
end
local function swim_member_serialize(m)
......
......@@ -403,6 +403,10 @@ s:uuid()
---
- 00000000-0000-1000-8000-000000000001
...
s:uuid() == s:uuid()
---
- true
...
s:uri()
---
- 127.0.0.1:<port>
......
......@@ -137,6 +137,7 @@ s = s1:self()
s
s:status()
s:uuid()
s:uuid() == s:uuid()
s:uri()
s:incarnation()
s:payload_cdata()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment