Mercurial > prosody-hg
comparison plugins/mod_admin_socket.lua @ 12418:dd47adf74e93 0.12
mod_admin_socket: Improve error reporting when socket can't be created (fixes #1719)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sat, 19 Mar 2022 11:38:21 +0000 |
| parents | 6966026262f4 |
| children | c35afa353f8f 68df46926c26 |
comparison
equal
deleted
inserted
replaced
| 12416:19fd28239e73 | 12418:dd47adf74e93 |
|---|---|
| 60 | 60 |
| 61 function module.load() | 61 function module.load() |
| 62 sock = unix.stream(); | 62 sock = unix.stream(); |
| 63 sock:settimeout(0); | 63 sock:settimeout(0); |
| 64 os.remove(socket_path); | 64 os.remove(socket_path); |
| 65 assert(sock:bind(socket_path)); | 65 local ok, err = sock:bind(socket_path); |
| 66 assert(sock:listen()); | 66 if not ok then |
| 67 module:log_status("error", "Unable to bind admin socket %s: %s", socket_path, err); | |
| 68 return; | |
| 69 end | |
| 70 local ok, err = sock:listen(); | |
| 71 if not ok then | |
| 72 module:log_status("error", "Unable to listen on admin socket %s: %s", socket_path, err); | |
| 73 return; | |
| 74 end | |
| 67 if server.wrapserver then | 75 if server.wrapserver then |
| 68 conn = server.wrapserver(sock, socket_path, 0, listeners); | 76 conn = server.wrapserver(sock, socket_path, 0, listeners); |
| 69 else | 77 else |
| 70 conn = server.watchfd(sock:getfd(), accept_connection); | 78 conn = server.watchfd(sock:getfd(), accept_connection); |
| 71 end | 79 end |
