Merge pull request #28 from westermo/wmo/2.4

Westermo fixes for services changing type at runtime

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2016-04-26 09:38:41 +02:00
commit a1e6febc4f
3 files changed
+15 -9

No files matched your search

+6 -6
View File
@@ -275,7 +275,9 @@ void inetd_stop(inetd_t *inetd)
/* For dgram inetd services we block the parent SVC /* For dgram inetd services we block the parent SVC
* and halt the watcher, so don't close the socket! */ * and halt the watcher, so don't close the socket! */
if (inetd->svc->block != SVC_BLOCK_INETD_BUSY) { if (inetd->svc->block != SVC_BLOCK_INETD_BUSY) {
shutdown(inetd->watcher.fd, SHUT_RDWR); _d("Shutting down inet socket %d ...", inetd->watcher.fd);
if (inetd->type == SOCK_STREAM)
shutdown(inetd->watcher.fd, SHUT_RDWR);
close(inetd->watcher.fd); close(inetd->watcher.fd);
inetd->watcher.fd = -1; inetd->watcher.fd = -1;
} }
@@ -626,12 +628,10 @@ int inetd_new(inetd_t *inetd, char *name, char *service, char *proto, int forkin
int inetd_del(inetd_t *inetd) int inetd_del(inetd_t *inetd)
{ {
inetd_filter_t *filter, *tmp; inetd->svc->block = 0;
inetd_stop(inetd);
TAILQ_FOREACH_SAFE(filter, &inetd->filters, link, tmp) return inetd_flush(inetd);
free(filter);
return 0;
} }
/** /**
+8
View File
@@ -648,6 +648,7 @@ int service_register(int type, char *line, time_t mtime, char *username)
id = svc_next_id(cmd); id = svc_next_id(cmd);
} }
recreate:
#endif #endif
svc = svc_find(cmd, id); svc = svc_find(cmd, id);
@@ -658,6 +659,13 @@ int service_register(int type, char *line, time_t mtime, char *username)
_e("Out of memory, cannot register service %s", cmd); _e("Out of memory, cannot register service %s", cmd);
return errno = ENOMEM; return errno = ENOMEM;
} }
} else {
if (svc_is_inetd(svc) && type != SVC_TYPE_INETD) {
_d("Service was previously inetd, deregistering ...");
inetd_del(&svc->inetd);
svc_del(svc);
goto recreate;
}
} }
svc->log = log; svc->log = log;
+1 -3
View File
@@ -97,9 +97,7 @@ svc_t *svc_new(char *cmd, int id, int type)
*/ */
int svc_del(svc_t *svc) int svc_del(svc_t *svc)
{ {
/* Clear any old references and set SVC_TYPE_FREE */ svc->type = SVC_TYPE_FREE;
memset(svc, 0, sizeof(*svc));
return 0; return 0;
} }