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