make in-place restarts use socket activation, too (for faster/less flaky tests)
This commit is contained in:
parent
3b7f4d428e
commit
318d4fdeef
|
@ -2,7 +2,7 @@
|
||||||
* vim:ts=4:sw=4:expandtab
|
* vim:ts=4:sw=4:expandtab
|
||||||
*
|
*
|
||||||
* i3 - an improved dynamic tiling window manager
|
* i3 - an improved dynamic tiling window manager
|
||||||
* © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE)
|
* © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE)
|
||||||
*
|
*
|
||||||
* i3.h: global variables that are used all over i3.
|
* i3.h: global variables that are used all over i3.
|
||||||
*
|
*
|
||||||
|
@ -30,6 +30,8 @@
|
||||||
extern struct rlimit original_rlimit_core;
|
extern struct rlimit original_rlimit_core;
|
||||||
/** Whether this version of i3 is a debug build or a release build. */
|
/** Whether this version of i3 is a debug build or a release build. */
|
||||||
extern bool debug_build;
|
extern bool debug_build;
|
||||||
|
/** The number of file descriptors passed via socket activation. */
|
||||||
|
extern int listen_fds;
|
||||||
extern xcb_connection_t *conn;
|
extern xcb_connection_t *conn;
|
||||||
extern int conn_screen;
|
extern int conn_screen;
|
||||||
/** The last timestamp we got from X11 (timestamps are included in some events
|
/** The last timestamp we got from X11 (timestamps are included in some events
|
||||||
|
|
25
src/main.c
25
src/main.c
|
@ -2,7 +2,7 @@
|
||||||
* vim:ts=4:sw=4:expandtab
|
* vim:ts=4:sw=4:expandtab
|
||||||
*
|
*
|
||||||
* i3 - an improved dynamic tiling window manager
|
* i3 - an improved dynamic tiling window manager
|
||||||
* © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE)
|
* © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE)
|
||||||
*
|
*
|
||||||
* main.c: Initialization, main loop
|
* main.c: Initialization, main loop
|
||||||
*
|
*
|
||||||
|
@ -28,6 +28,9 @@ struct rlimit original_rlimit_core;
|
||||||
/* Whether this version of i3 is a debug build or a release build. */
|
/* Whether this version of i3 is a debug build or a release build. */
|
||||||
bool debug_build = false;
|
bool debug_build = false;
|
||||||
|
|
||||||
|
/** The number of file descriptors passed via socket activation. */
|
||||||
|
int listen_fds;
|
||||||
|
|
||||||
static int xkb_event_base;
|
static int xkb_event_base;
|
||||||
|
|
||||||
int xkb_current_group;
|
int xkb_current_group;
|
||||||
|
@ -662,14 +665,26 @@ int main(int argc, char *argv[]) {
|
||||||
/* Also handle the UNIX domain sockets passed via socket activation. The
|
/* Also handle the UNIX domain sockets passed via socket activation. The
|
||||||
* parameter 1 means "remove the environment variables", we don’t want to
|
* parameter 1 means "remove the environment variables", we don’t want to
|
||||||
* pass these to child processes. */
|
* pass these to child processes. */
|
||||||
int fds = sd_listen_fds(1);
|
listen_fds = sd_listen_fds(0);
|
||||||
if (fds < 0)
|
if (listen_fds < 0)
|
||||||
ELOG("socket activation: Error in sd_listen_fds\n");
|
ELOG("socket activation: Error in sd_listen_fds\n");
|
||||||
else if (fds == 0)
|
else if (listen_fds == 0)
|
||||||
DLOG("socket activation: no sockets passed\n");
|
DLOG("socket activation: no sockets passed\n");
|
||||||
else {
|
else {
|
||||||
for (int fd = SD_LISTEN_FDS_START; fd < (SD_LISTEN_FDS_START + fds); fd++) {
|
int flags;
|
||||||
|
for (int fd = SD_LISTEN_FDS_START;
|
||||||
|
fd < (SD_LISTEN_FDS_START + listen_fds);
|
||||||
|
fd++) {
|
||||||
DLOG("socket activation: also listening on fd %d\n", fd);
|
DLOG("socket activation: also listening on fd %d\n", fd);
|
||||||
|
|
||||||
|
/* sd_listen_fds() enables FD_CLOEXEC by default.
|
||||||
|
* However, we need to keep the file descriptors open for in-place
|
||||||
|
* restarting, therefore we explicitly disable FD_CLOEXEC. */
|
||||||
|
if ((flags = fcntl(fd, F_GETFD)) < 0 ||
|
||||||
|
fcntl(fd, F_SETFD, flags & ~FD_CLOEXEC) < 0) {
|
||||||
|
ELOG("Could not disable FD_CLOEXEC on fd %d\n", fd);
|
||||||
|
}
|
||||||
|
|
||||||
struct ev_io *ipc_io = scalloc(sizeof(struct ev_io));
|
struct ev_io *ipc_io = scalloc(sizeof(struct ev_io));
|
||||||
ev_io_init(ipc_io, ipc_new_client, fd, EV_READ);
|
ev_io_init(ipc_io, ipc_new_client, fd, EV_READ);
|
||||||
ev_io_start(main_loop, ipc_io);
|
ev_io_start(main_loop, ipc_io);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* vim:ts=4:sw=4:expandtab
|
* vim:ts=4:sw=4:expandtab
|
||||||
*
|
*
|
||||||
* i3 - an improved dynamic tiling window manager
|
* i3 - an improved dynamic tiling window manager
|
||||||
* © 2009-2011 Michael Stapelberg and contributors (see also: LICENSE)
|
* © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE)
|
||||||
*
|
*
|
||||||
* startup.c: Startup notification code. Ensures a startup notification context
|
* startup.c: Startup notification code. Ensures a startup notification context
|
||||||
* is setup when launching applications. We store the current
|
* is setup when launching applications. We store the current
|
||||||
|
@ -11,6 +11,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "all.h"
|
#include "all.h"
|
||||||
|
#include "sd-daemon.h"
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
@ -113,6 +114,15 @@ void start_application(const char *command, bool no_startup_id) {
|
||||||
/* Child process */
|
/* Child process */
|
||||||
setsid();
|
setsid();
|
||||||
setrlimit(RLIMIT_CORE, &original_rlimit_core);
|
setrlimit(RLIMIT_CORE, &original_rlimit_core);
|
||||||
|
/* Close all socket activation file descriptors explicitly, we disabled
|
||||||
|
* FD_CLOEXEC to keep them open when restarting i3. */
|
||||||
|
for (int fd = SD_LISTEN_FDS_START;
|
||||||
|
fd < (SD_LISTEN_FDS_START + listen_fds);
|
||||||
|
fd++) {
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
unsetenv("LISTEN_PID");
|
||||||
|
unsetenv("LISTEN_FDS");
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
/* Setup the environment variable(s) */
|
/* Setup the environment variable(s) */
|
||||||
if (!no_startup_id)
|
if (!no_startup_id)
|
||||||
|
|
|
@ -498,6 +498,9 @@ sub get_socket_path {
|
||||||
my $cookie = $x->get_property(0, $x->get_root_window(), $atom->id, GET_PROPERTY_TYPE_ANY, 0, 256);
|
my $cookie = $x->get_property(0, $x->get_root_window(), $atom->id, GET_PROPERTY_TYPE_ANY, 0, 256);
|
||||||
my $reply = $x->get_property_reply($cookie->{sequence});
|
my $reply = $x->get_property_reply($cookie->{sequence});
|
||||||
my $socketpath = $reply->{value};
|
my $socketpath = $reply->{value};
|
||||||
|
if ($socketpath eq "/tmp/nested-$ENV{DISPLAY}") {
|
||||||
|
$socketpath .= '-activation';
|
||||||
|
}
|
||||||
$_cached_socket_path = $socketpath;
|
$_cached_socket_path = $socketpath;
|
||||||
return $socketpath;
|
return $socketpath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ is(scalar @{$ws->{nodes}}, 0, 'no tiling nodes');
|
||||||
is(scalar @{$ws->{floating_nodes}}, 1, 'precisely one floating node');
|
is(scalar @{$ws->{floating_nodes}}, 1, 'precisely one floating node');
|
||||||
|
|
||||||
cmd 'restart';
|
cmd 'restart';
|
||||||
sleep 0.5;
|
|
||||||
|
|
||||||
diag('Checking if i3 still lives');
|
diag('Checking if i3 still lives');
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,6 @@ is($docknode->{rect}->{height}, 30, 'dock node has unchanged height');
|
||||||
# perform an inplace-restart
|
# perform an inplace-restart
|
||||||
cmd 'restart';
|
cmd 'restart';
|
||||||
|
|
||||||
sleep 0.25;
|
|
||||||
|
|
||||||
does_i3_live;
|
does_i3_live;
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,7 +76,6 @@ $docknode = $docked[0];
|
||||||
is($docknode->{rect}->{height}, 20, 'dock node has unchanged height');
|
is($docknode->{rect}->{height}, 20, 'dock node has unchanged height');
|
||||||
|
|
||||||
cmd 'restart';
|
cmd 'restart';
|
||||||
sleep 0.25;
|
|
||||||
|
|
||||||
@docked = get_dock_clients;
|
@docked = get_dock_clients;
|
||||||
is(@docked, 1, 'one dock client found');
|
is(@docked, 1, 'one dock client found');
|
||||||
|
|
|
@ -28,8 +28,6 @@ is(get_border_style(), '1pixel', 'border style 1pixel after changing');
|
||||||
# perform an inplace-restart
|
# perform an inplace-restart
|
||||||
cmd 'restart';
|
cmd 'restart';
|
||||||
|
|
||||||
sleep 0.25;
|
|
||||||
|
|
||||||
does_i3_live;
|
does_i3_live;
|
||||||
|
|
||||||
is(get_border_style(), '1pixel', 'border style still 1pixel after restart');
|
is(get_border_style(), '1pixel', 'border style still 1pixel after restart');
|
||||||
|
|
|
@ -17,7 +17,6 @@ cmd 'fullscreen';
|
||||||
sync_with_i3;
|
sync_with_i3;
|
||||||
|
|
||||||
cmd 'restart';
|
cmd 'restart';
|
||||||
sleep 1;
|
|
||||||
|
|
||||||
does_i3_live;
|
does_i3_live;
|
||||||
|
|
||||||
|
|
|
@ -278,7 +278,6 @@ my $old_nodes = scalar @{$__i3_scratch->{nodes}};
|
||||||
my $old_floating_nodes = scalar @{$__i3_scratch->{floating_nodes}};
|
my $old_floating_nodes = scalar @{$__i3_scratch->{floating_nodes}};
|
||||||
|
|
||||||
cmd 'restart';
|
cmd 'restart';
|
||||||
sleep 1;
|
|
||||||
|
|
||||||
does_i3_live;
|
does_i3_live;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@ is($focus->[0], $nodes->[0]->{id}, 'first node focused');
|
||||||
is($focus->[1], $nodes->[1]->{id}, 'second node second in focus stack');
|
is($focus->[1], $nodes->[1]->{id}, 'second node second in focus stack');
|
||||||
|
|
||||||
cmd 'restart';
|
cmd 'restart';
|
||||||
sleep 1;
|
|
||||||
|
|
||||||
does_i3_live;
|
does_i3_live;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue