1
0
Fork 0
mirror of https://github.com/pygos/init.git synced 2024-05-08 23:06:15 +02:00

Include service ID in initsock status response

Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
This commit is contained in:
David Oberhollenzer 2019-03-28 13:57:19 +01:00
parent c16735414b
commit 9e7478397a
3 changed files with 15 additions and 4 deletions

View file

@ -36,6 +36,7 @@ typedef struct {
typedef struct {
E_SERVICE_STATE state;
int exit_status;
int id;
char *filename;
char *service_name;
} init_status_response_t;

View file

@ -63,16 +63,19 @@ static char *read_string(int fd)
int init_socket_recv_status(int fd, init_status_response_t *resp)
{
uint8_t info[2];
uint8_t info[8];
memset(resp, 0, sizeof(*resp));
if (read_retry(fd, info, 2) <= 0)
if (read_retry(fd, info, sizeof(info)) <= 0)
return -1;
resp->state = info[0];
resp->exit_status = info[1];
resp->id = ((int)info[4] << 24) | ((int)info[5] << 16) |
((int)info[6] << 8) | (int)info[7];
if (resp->state == ESS_NONE)
return 0;

View file

@ -42,17 +42,24 @@ static int send_string(int fd, const void *dst, size_t addrlen,
int init_socket_send_status(int fd, const void *dest_addr, size_t addrlen,
E_SERVICE_STATE state, service_t *svc)
{
uint8_t info[2];
uint8_t info[8];
if (svc == NULL || state == ESS_NONE) {
info[0] = ESS_NONE;
info[1] = 0;
info[2] = info[3] = 0;
info[4] = info[5] = info[6] = info[7] = 0xFF;
} else {
info[0] = state;
info[1] = svc->status & 0xFF;
info[2] = info[3] = 0;
info[4] = (svc->id >> 24) & 0xFF;
info[5] = (svc->id >> 16) & 0xFF;
info[6] = (svc->id >> 8) & 0xFF;
info[7] = svc->id & 0xFF;
}
if (send_retry(fd, dest_addr, addrlen, info, 2))
if (send_retry(fd, dest_addr, addrlen, info, sizeof(info)))
return -1;
if (svc != NULL && state != ESS_NONE) {