diff options
-rw-r--r-- | server/media.erl | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/server/media.erl b/server/media.erl index 9d5bcb6..7e84b28 100644 --- a/server/media.erl +++ b/server/media.erl @@ -122,9 +122,9 @@ devote(Artist, Title) -> lock(Artist, Title) -> F = fun() -> [Head|_] = ask(Artist, Title), - Votes = Head#track.votes -1, - New = Head#track(votes = Votes), - mnesia:write(New), + Votes = Head#track.votes - 1, + New = Head#track{votes = Votes}, + mnesia:write(New) end, mnesia:transaction(F). @@ -133,13 +133,16 @@ unlock(Artist, Title) -> [Head|_] = ask(Artist, Title), Votes = Head#track.votes -1, New = Head#track{votes = Votes}, - mnesia:write(New), + mnesia:write(New) end, mnesia:transaction(F). lock_prozess(Artist, Title) -> lock(Artist, Title), receive - after TIMEOUT unlock(Artist, Title). + + after ?TIMEOUT -> + unlock(Artist, Title) end. + |