summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-12-22 19:25:10 +0100
committerLennart Poettering <lennart@poettering.net>2012-12-22 22:17:58 +0100
commitee09281729588900edc06152032a0cc09557f998 (patch)
tree5ee30e3cb828f97c893243237013fdfd7532f5c2 /src
parent51d88d1b4fb4ba7c2ecbc72cbbcababb21e4925f (diff)
socket: properly serialize/desrialize mqueue fds
Diffstat (limited to 'src')
-rw-r--r--src/core/socket.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/core/socket.c b/src/core/socket.c
index 49e795e4b9..18b81761c5 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -1702,7 +1702,8 @@ static int socket_serialize(Unit *u, FILE *f, FDSet *fds) {
if (p->type == SOCKET_SOCKET) {
char *t;
- if ((r = socket_address_print(&p->address, &t)) < 0)
+ r = socket_address_print(&p->address, &t);
+ if (r < 0)
return r;
if (socket_address_family(&p->address) == AF_NETLINK)
@@ -1712,6 +1713,8 @@ static int socket_serialize(Unit *u, FILE *f, FDSet *fds) {
free(t);
} else if (p->type == SOCKET_SPECIAL)
unit_serialize_item_format(u, f, "special", "%i %s", copy, p->path);
+ else if (p->type == SOCKET_MQUEUE)
+ unit_serialize_item_format(u, f, "mqueue", "%i %s", copy, p->path);
else {
assert(p->type == SOCKET_FIFO);
unit_serialize_item_format(u, f, "fifo", "%i %s", copy, p->path);
@@ -1732,7 +1735,8 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
if (streq(key, "state")) {
SocketState state;
- if ((state = socket_state_from_string(value)) < 0)
+ state = socket_state_from_string(value);
+ if (state < 0)
log_debug("Failed to parse state value %s", value);
else
s->deserialized_state = state;
@@ -1808,6 +1812,26 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
}
}
+ } else if (streq(key, "mqueue")) {
+ int fd, skip = 0;
+ SocketPort *p;
+
+ if (sscanf(value, "%i %n", &fd, &skip) < 1 || fd < 0 || !fdset_contains(fds, fd))
+ log_debug("Failed to parse mqueue value %s", value);
+ else {
+
+ LIST_FOREACH(port, p, s->ports)
+ if (p->type == SOCKET_MQUEUE &&
+ streq_ptr(p->path, value+skip))
+ break;
+
+ if (p) {
+ if (p->fd >= 0)
+ close_nointr_nofail(p->fd);
+ p->fd = fdset_remove(fds, fd);
+ }
+ }
+
} else if (streq(key, "socket")) {
int fd, type, skip = 0;
SocketPort *p;