Skip to content

Commit

Permalink
Merge pull request #4 from eugeneia/snabbtop-for-next
Browse files Browse the repository at this point in the history
snabbtop-for-next: Fix bugs in counter.delete and mkdir
  • Loading branch information
lukego committed Jul 31, 2015
2 parents 2534e5f + 0df7f4a commit 63f2823
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/core/counter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ function open (name, readonly)
end

function delete (name)
local ptr = public[numbers[name]]
if not ptr then error("counter not found for deletion: " .. name) end
local number = numbers[name]
if not number then error("counter not found for deletion: " .. name) end
-- Free shm object
shm.unmap(ptr)
shm.unmap(public[number])
shm.unlink(name)
-- Free local state
numbers[name] = false
public[ptr] = false
private[ptr] = false
public[number] = false
private[number] = false
end

-- Copy counter private counter values to public shared memory.
Expand Down
5 changes: 5 additions & 0 deletions src/core/shm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ end
-- Make directories needed for a named object.
-- Given the name "foo/bar/baz" create /var/run/foo and /var/run/foo/bar.
function mkdir (name)
-- Create root with mode "rwxrwxrwt" (R/W for all and sticky)
local mask = S.umask(0)
S.mkdir(root, "01777")
S.umask(mask)
-- Create sub directories
local dir = root
name:gsub("([^/]+)",
function (x) S.mkdir(dir, "rwxu") dir = dir.."/"..x end)
Expand Down

0 comments on commit 63f2823

Please sign in to comment.