chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
socket: add support for tcp nagle
[elogind.git]
/
src
/
core
/
socket.c
diff --git
a/src/core/socket.c
b/src/core/socket.c
index e834b045a005875df9ce2cc95f81ec51de044810..5af15964ff088b591fbfac1f201663849c482d5e 100644
(file)
--- a/
src/core/socket.c
+++ b/
src/core/socket.c
@@
-180,9
+180,8
@@
static int socket_arm_timer(Socket *s) {
socket_dispatch_timer, s);
}
socket_dispatch_timer, s);
}
-static int socket_instantiate_service(Socket *s) {
- _cleanup_free_ char *prefix = NULL;
- _cleanup_free_ char *name = NULL;
+int socket_instantiate_service(Socket *s) {
+ _cleanup_free_ char *prefix = NULL, *name = NULL;
int r;
Unit *u;
int r;
Unit *u;
@@
-193,11
+192,9
@@
static int socket_instantiate_service(Socket *s) {
* here. For Accept=no this is mostly a NOP since the service
* is figured out at load time anyway. */
* here. For Accept=no this is mostly a NOP since the service
* is figured out at load time anyway. */
- if (UNIT_DEREF(s->service))
+ if (UNIT_DEREF(s->service)
|| !s->accept
)
return 0;
return 0;
- assert(s->accept);
-
prefix = unit_name_to_prefix(UNIT(s)->id);
if (!prefix)
return -ENOMEM;
prefix = unit_name_to_prefix(UNIT(s)->id);
if (!prefix)
return -ENOMEM;
@@
-209,13
+206,6
@@
static int socket_instantiate_service(Socket *s) {
if (r < 0)
return r;
if (r < 0)
return r;
-#ifdef HAVE_SYSV_COMPAT
- if (SERVICE(u)->is_sysv) {
- log_error("Using SysV services for socket activation is not supported. Refusing.");
- return -ENOENT;
- }
-#endif
-
u->no_gc = true;
unit_ref_set(&s->service, u);
u->no_gc = true;
unit_ref_set(&s->service, u);
@@
-490,6
+480,7
@@
static void socket_dump(Unit *u, FILE *f, const char *prefix) {
"%sSocketMode: %04o\n"
"%sDirectoryMode: %04o\n"
"%sKeepAlive: %s\n"
"%sSocketMode: %04o\n"
"%sDirectoryMode: %04o\n"
"%sKeepAlive: %s\n"
+ "%sNoDelay: %s\n"
"%sFreeBind: %s\n"
"%sTransparent: %s\n"
"%sBroadcast: %s\n"
"%sFreeBind: %s\n"
"%sTransparent: %s\n"
"%sBroadcast: %s\n"
@@
-504,6
+495,7
@@
static void socket_dump(Unit *u, FILE *f, const char *prefix) {
prefix, s->socket_mode,
prefix, s->directory_mode,
prefix, yes_no(s->keep_alive),
prefix, s->socket_mode,
prefix, s->directory_mode,
prefix, yes_no(s->keep_alive),
+ prefix, yes_no(s->no_delay),
prefix, yes_no(s->free_bind),
prefix, yes_no(s->transparent),
prefix, yes_no(s->broadcast),
prefix, yes_no(s->free_bind),
prefix, yes_no(s->transparent),
prefix, yes_no(s->broadcast),
@@
-800,6
+792,12
@@
static void socket_apply_socket_options(Socket *s, int fd) {
log_warning_unit(UNIT(s)->id, "SO_KEEPALIVE failed: %m");
}
log_warning_unit(UNIT(s)->id, "SO_KEEPALIVE failed: %m");
}
+ if (s->no_delay) {
+ int b = s->no_delay;
+ if (setsockopt(fd, SOL_TCP, TCP_NODELAY, &b, sizeof(b)) < 0)
+ log_warning_unit(UNIT(s)->id, "TCP_NODELAY failed: %m");
+ }
+
if (s->broadcast) {
int one = 1;
if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one)) < 0)
if (s->broadcast) {
int one = 1;
if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one)) < 0)
@@
-1173,11
+1171,12
@@
static void socket_unwatch_fds(Socket *s) {
if (p->fd < 0)
continue;
if (p->fd < 0)
continue;
- if (p->event_source) {
- r = sd_event_source_set_enabled(p->event_source, SD_EVENT_OFF);
- if (r < 0)
- log_debug_unit(UNIT(s)->id, "Failed to disable event source.");
- }
+ if (!p->event_source)
+ continue;
+
+ r = sd_event_source_set_enabled(p->event_source, SD_EVENT_OFF);
+ if (r < 0)
+ log_debug_unit(UNIT(s)->id, "Failed to disable event source.");
}
}
}
}
@@
-1349,6
+1348,8
@@
static int socket_spawn(Socket *s, ExecCommand *c, pid_t *_pid) {
NULL,
s->exec_runtime,
&pid);
NULL,
s->exec_runtime,
&pid);
+ if (r < 0)
+ goto fail;
r = unit_watch_pid(UNIT(s), pid);
if (r < 0)
r = unit_watch_pid(UNIT(s), pid);
if (r < 0)
@@
-1409,7
+1410,7
@@
static int socket_chown(Socket *s, pid_t *_pid) {
}
LIST_FOREACH(port, p, s->ports) {
}
LIST_FOREACH(port, p, s->ports) {
- const char *path;
+ const char *path
= NULL
;
if (p->type == SOCKET_SOCKET)
path = socket_address_get_path(&p->address);
if (p->type == SOCKET_SOCKET)
path = socket_address_get_path(&p->address);
@@
-1843,6
+1844,7
@@
static int socket_start(Unit *u) {
SOCKET_FINAL_SIGKILL))
return -EAGAIN;
SOCKET_FINAL_SIGKILL))
return -EAGAIN;
+ /* Already on it! */
if (IN_SET(s->state,
SOCKET_START_PRE,
SOCKET_START_CHOWN,
if (IN_SET(s->state,
SOCKET_START_PRE,
SOCKET_START_CHOWN,
@@
-1868,14
+1870,6
@@
static int socket_start(Unit *u) {
log_error_unit(u->id, "Socket service %s already active, refusing.", UNIT(service)->id);
return -EBUSY;
}
log_error_unit(u->id, "Socket service %s already active, refusing.", UNIT(service)->id);
return -EBUSY;
}
-
-#ifdef HAVE_SYSV_COMPAT
- if (service->is_sysv) {
- log_error_unit(u->id,
- "Using SysV services for socket activation is not supported. Refusing.");
- return -ENOENT;
- }
-#endif
}
assert(s->state == SOCKET_DEAD || s->state == SOCKET_FAILED);
}
assert(s->state == SOCKET_DEAD || s->state == SOCKET_FAILED);
@@
-2282,7
+2276,7
@@
static void socket_sigchld_event(Unit *u, pid_t pid, int code, int status) {
else if (code == CLD_DUMPED)
f = SOCKET_FAILURE_CORE_DUMP;
else
else if (code == CLD_DUMPED)
f = SOCKET_FAILURE_CORE_DUMP;
else
- assert_not_reached("Unknown code");
+ assert_not_reached("Unknown
sigchld
code");
if (s->control_command) {
exec_status_exit(&s->control_command->exec_status, &s->exec_context, pid, code, status);
if (s->control_command) {
exec_status_exit(&s->control_command->exec_status, &s->exec_context, pid, code, status);