Mercurial > prosody-modules
comparison mod_inotify_reload/mod_inotify_reload.lua @ 753:9d5731af2c27
Merge with Oliver Gerlich
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 27 Jul 2012 14:29:59 +0100 |
parents | ab988e98a9f9 |
children | 82207f936f1f |
comparison
equal
deleted
inserted
replaced
752:9bbd99f2057a | 753:9d5731af2c27 |
---|---|
42 local id, err = inh:addwatch(path, inotify.IN_CLOSE_WRITE); | 42 local id, err = inh:addwatch(path, inotify.IN_CLOSE_WRITE); |
43 if not id then return nil, err; end | 43 if not id then return nil, err; end |
44 local k = host.."\0"..name; | 44 local k = host.."\0"..name; |
45 watches[k] = { id = id, path = path, name = name, host = host }; | 45 watches[k] = { id = id, path = path, name = name, host = host }; |
46 watch_ids[id] = k; | 46 watch_ids[id] = k; |
47 module:log("debug", "Watching %s:%s with id %d", name, host, id); | |
47 return true; | 48 return true; |
48 end | 49 end |
49 | 50 |
50 function unwatch_module(name, host) | 51 function unwatch_module(name, host) |
51 local k = host.."\0"..name; | 52 local k = host.."\0"..name; |
52 if not watches[k] then | 53 if not watches[k] then |
54 module:log("warn", "Not watching %s:%s", name, host); | |
53 return nil, "not-watching"; | 55 return nil, "not-watching"; |
54 end | 56 end |
55 local id = watches[k].id; | 57 local id = watches[k].id; |
56 local ok, err = inh:rmwatch(id); | 58 local ok, err = inh:rmwatch(id); |
59 module:log("info", "Removed watch %d", id); | |
57 watches[k] = nil; | 60 watches[k] = nil; |
58 watch_ids[id] = nil; | 61 watch_ids[id] = nil; |
59 return ok, err; | 62 return ok, err; |
60 end | 63 end |
61 | 64 |