chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
mount: properly handle LABEL="" in fstab
[elogind.git]
/
src
/
socket.c
diff --git
a/src/socket.c
b/src/socket.c
index 23658ac274a2343e0bb6ed7455e9d9954022b18f..d0568c9b52074bdb18888f56e8b39283dbf24023 100644
(file)
--- a/
src/socket.c
+++ b/
src/socket.c
@@
-1,4
+1,4
@@
-/*-*- Mode: C; c-basic-offset: 8 -*-*/
+/*-*- Mode: C; c-basic-offset: 8
; indent-tabs-mode: nil
-*-*/
/***
This file is part of systemd.
/***
This file is part of systemd.
@@
-40,6
+40,7
@@
#include "missing.h"
#include "special.h"
#include "bus-errors.h"
#include "missing.h"
#include "special.h"
#include "bus-errors.h"
+#include "label.h"
static const UnitActiveState state_translation_table[_SOCKET_STATE_MAX] = {
[SOCKET_DEAD] = UNIT_INACTIVE,
static const UnitActiveState state_translation_table[_SOCKET_STATE_MAX] = {
[SOCKET_DEAD] = UNIT_INACTIVE,
@@
-445,14
+446,14
@@
static void socket_dump(Unit *u, FILE *f, const char *prefix) {
if (p->type == SOCKET_SOCKET) {
const char *t;
int r;
if (p->type == SOCKET_SOCKET) {
const char *t;
int r;
- char *k;
+ char *k
= NULL
;
if ((r = socket_address_print(&p->address, &k)) < 0)
t = strerror(-r);
else
t = k;
if ((r = socket_address_print(&p->address, &k)) < 0)
t = strerror(-r);
else
t = k;
- fprintf(f, "%s%s: %s\n", prefix, listen_lookup(p->address.type),
k
);
+ fprintf(f, "%s%s: %s\n", prefix, listen_lookup(p->address.type),
t
);
free(k);
} else
fprintf(f, "%sListenFIFO: %s\n", prefix, p->path);
free(k);
} else
fprintf(f, "%sListenFIFO: %s\n", prefix, p->path);
@@
-658,7
+659,6
@@
static int fifo_address_create(
const char *path,
mode_t directory_mode,
mode_t socket_mode,
const char *path,
mode_t directory_mode,
mode_t socket_mode,
- const char *label,
int *_fd) {
int fd = -1, r = 0;
int *_fd) {
int fd = -1, r = 0;
@@
-670,7
+670,7
@@
static int fifo_address_create(
mkdir_parents(path, directory_mode);
mkdir_parents(path, directory_mode);
- if ((r = label_fifofile_set(
label,
path)) < 0)
+ if ((r = label_fifofile_set(path)) < 0)
goto fail;
/* Enforce the right access mode for the fifo */
goto fail;
/* Enforce the right access mode for the fifo */
@@
-724,15
+724,10
@@
static int socket_open_fds(Socket *s) {
SocketPort *p;
int r;
char *label = NULL;
SocketPort *p;
int r;
char *label = NULL;
+ bool know_label = false;
assert(s);
assert(s);
- if ((r = socket_instantiate_service(s)) < 0)
- return r;
-
- if ((r = label_get_socket_label_from_exe(s->service->exec_command[SERVICE_EXEC_START]->path, &label)) < 0)
- return r;
-
LIST_FOREACH(port, p, s->ports) {
if (p->fd >= 0)
LIST_FOREACH(port, p, s->ports) {
if (p->fd >= 0)
@@
-740,6
+735,17
@@
static int socket_open_fds(Socket *s) {
if (p->type == SOCKET_SOCKET) {
if (p->type == SOCKET_SOCKET) {
+ if (!know_label) {
+
+ if ((r = socket_instantiate_service(s)) < 0)
+ return r;
+
+ if ((r = label_get_socket_label_from_exe(s->service->exec_command[SERVICE_EXEC_START]->path, &label)) < 0)
+ return r;
+
+ know_label = true;
+ }
+
if ((r = socket_address_listen(
&p->address,
s->backlog,
if ((r = socket_address_listen(
&p->address,
s->backlog,
@@
-760,7
+766,6
@@
static int socket_open_fds(Socket *s) {
p->path,
s->directory_mode,
s->socket_mode,
p->path,
s->directory_mode,
s->socket_mode,
- label,
&p->fd)) < 0)
goto rollback;
&p->fd)) < 0)
goto rollback;
@@
-1216,6
+1221,9
@@
static void socket_enter_running(Socket *s, int cfd) {
if ((r = manager_add_job(s->meta.manager, JOB_START, UNIT(service), JOB_REPLACE, true, &error, NULL)) < 0)
goto fail;
if ((r = manager_add_job(s->meta.manager, JOB_START, UNIT(service), JOB_REPLACE, true, &error, NULL)) < 0)
goto fail;
+
+ /* Notify clients about changed counters */
+ unit_add_to_dbus_queue(UNIT(s));
}
return;
}
return;
@@
-1374,7
+1382,6
@@
static int socket_serialize(Unit *u, FILE *f, FDSet *fds) {
static int socket_deserialize_item(Unit *u, const char *key, const char *value, FDSet *fds) {
Socket *s = SOCKET(u);
static int socket_deserialize_item(Unit *u, const char *key, const char *value, FDSet *fds) {
Socket *s = SOCKET(u);
- int r;
assert(u);
assert(key);
assert(u);
assert(key);
@@
-1399,14
+1406,14
@@
static int socket_deserialize_item(Unit *u, const char *key, const char *value,
} else if (streq(key, "n-accepted")) {
unsigned k;
} else if (streq(key, "n-accepted")) {
unsigned k;
- if (
(r = safe_atou(value, &k)
) < 0)
+ if (
safe_atou(value, &k
) < 0)
log_debug("Failed to parse n-accepted value %s", value);
else
s->n_accepted += k;
} else if (streq(key, "control-pid")) {
pid_t pid;
log_debug("Failed to parse n-accepted value %s", value);
else
s->n_accepted += k;
} else if (streq(key, "control-pid")) {
pid_t pid;
- if (
(r = parse_pid(value, &pid)
) < 0)
+ if (
parse_pid(value, &pid
) < 0)
log_debug("Failed to parse control-pid value %s", value);
else
s->control_pid = pid;
log_debug("Failed to parse control-pid value %s", value);
else
s->control_pid = pid;
@@
-1594,6
+1601,9
@@
static void socket_sigchld_event(Unit *u, pid_t pid, int code, int status) {
assert_not_reached("Uh, control process died at wrong time.");
}
}
assert_not_reached("Uh, control process died at wrong time.");
}
}
+
+ /* Notify clients about changed exit status */
+ unit_add_to_dbus_queue(u);
}
static void socket_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
}
static void socket_timer_event(Unit *u, uint64_t elapsed, Watch *w) {
@@
-1665,7
+1675,7
@@
int socket_collect_fds(Socket *s, int **fds, unsigned *n_fds) {
if (p->fd >= 0)
rn_fds++;
if (p->fd >= 0)
rn_fds++;
- if (!(rfds = new(int, rn_fds))
< 0
)
+ if (!(rfds = new(int, rn_fds)))
return -ENOMEM;
k = 0;
return -ENOMEM;
k = 0;
@@
-1774,5
+1784,7
@@
const UnitVTable socket_vtable = {
.reset_maintenance = socket_reset_maintenance,
.reset_maintenance = socket_reset_maintenance,
- .bus_message_handler = bus_socket_message_handler
+ .bus_interface = "org.freedesktop.systemd1.Socket",
+ .bus_message_handler = bus_socket_message_handler,
+ .bus_invalidating_properties = bus_socket_invalidating_properties
};
};