mirror of
https://github.com/troglobit/finit.git
synced 2026-10-01 21:42:40 +07:00
api.c: Handle domain socket errors more gracefully, restart socket
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
#include "helpers.h"
|
||||
#include "log.h"
|
||||
#include "plugin.h"
|
||||
#include "private.h"
|
||||
#include "sig.h"
|
||||
#include "service.h"
|
||||
#include "util.h"
|
||||
@@ -173,15 +174,10 @@ static void cb(uev_t *w, void *arg, int events)
|
||||
int sd, lvl;
|
||||
struct init_request rq;
|
||||
|
||||
if (UEV_ERROR == events) {
|
||||
_e("Unrecoverable error on API socket");
|
||||
return;
|
||||
}
|
||||
|
||||
sd = accept(w->fd, NULL, NULL);
|
||||
if (sd < 0) {
|
||||
_pe("Failed serving API request");
|
||||
return;
|
||||
goto error;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
@@ -297,8 +293,17 @@ static void cb(uev_t *w, void *arg, int events)
|
||||
_d("Failed sending ACK/NACK back to client");
|
||||
}
|
||||
|
||||
if (UEV_ERROR == events)
|
||||
goto error;
|
||||
|
||||
leave:
|
||||
close(sd);
|
||||
return;
|
||||
|
||||
error:
|
||||
api_exit();
|
||||
if (api_init(w->ctx))
|
||||
_e("Unrecoverable error on API socket");
|
||||
}
|
||||
|
||||
int api_init(uev_ctx_t *ctx)
|
||||
|
||||
Reference in New Issue
Block a user