diff --git a/src/account.lua b/src/account.lua index d960300..aa05fc0 100644 --- a/src/account.lua +++ b/src/account.lua @@ -32,6 +32,7 @@ Account._mt.__call = function (self, arg) object._mt = {} object._mt.__index = object._attach_mailbox + object._mt.__gc = object._logout_user setmetatable(object, object._mt) object:_login_user() @@ -60,6 +61,12 @@ function Account._login_user(self) end end +function Account._logout_user(self) + if ifcore.logout(self._session) == nil then + error("logout request failed", 0) + end +end + function Account._attach_mailbox(self, mailbox) self[mailbox] = Mailbox(self, mailbox) diff --git a/src/imapfilter.c b/src/imapfilter.c index 34dbdef..227cf77 100644 --- a/src/imapfilter.c +++ b/src/imapfilter.c @@ -86,23 +86,18 @@ main(int argc, char *argv[]) } get_pathmax(); - open_debug(); - create_homedir(); - catch_signals(); - open_log(); + if (opts.config == NULL) + opts.config = get_filepath("config.lua"); buffer_init(&ibuf, INPUT_BUF); buffer_init(&obuf, OUTPUT_BUF); buffer_init(&nbuf, NAMESPACE_BUF); buffer_init(&cbuf, CONVERSION_BUF); - if (opts.config == NULL) - opts.config = get_filepath("config.lua"); - regexp_compile(responses); #ifndef NO_SSLTLS @@ -111,7 +106,7 @@ main(int argc, char *argv[]) #endif start_lua(); - +#if LUA_VERSION_NUM < 502 { list *l; session *s; @@ -124,7 +119,7 @@ main(int argc, char *argv[]) request_logout(s); } } - +#endif stop_lua(); #ifndef NO_SSLTLS