Commit d861d51e authored by Jiri (George) Lebl's avatar Jiri (George) Lebl Committed by George Lebl

When restarting a server by whacking it and starting it again, wait at


Fri Feb 20 10:03:42 2004  George Lebl <jirka@5z.com>

	* display.c, server.[ch], slave.c: When restarting a server by
	  whacking it and starting it again, wait at least one second to
	  allow things to "settle".  If local display is busy try again once
	  in 2 secs before resorting to telling the user so.  Be much milder
	  in whacking X's lock files / sockets to avoid whacking actual
	  locks / sockets when displays are in fact busy and used, that is,
	  only whack locks / sockets when we in fact successfully started
	  a server.
parent 20f85d1b
Fri Feb 20 10:03:42 2004 George Lebl <jirka@5z.com>
* display.c, server.[ch], slave.c: When restarting a server by
whacking it and starting it again, wait at least one second to
allow things to "settle". If local display is busy try again once
in 2 secs before resorting to telling the user so. Be much milder
in whacking X's lock files / sockets to avoid whacking actual
locks / sockets when displays are in fact busy and used, that is,
only whack locks / sockets when we in fact successfully started
a server.
THu Feb 19 Guntupalli Karunakar <karunakar@freedomink.org>
* gui/gdmlanguages.c: Fixes #134372, Hindi was incorrectly
......
......@@ -153,7 +153,8 @@ gdm_display_check_loop (GdmDisplay *disp)
}
else
{
disp->sleep_before_run = 0;
/* wait one second just for safety (avoids X server races) */
disp->sleep_before_run = 1;
disp->last_start_time = now;
}
......@@ -339,8 +340,8 @@ gdm_display_manage (GdmDisplay *d)
d->dispstat = DISPLAY_ALIVE;
}
/* reset sleep to 0 */
d->sleep_before_run = 0;
/* reset sleep to 1, to sleep just in case (avoids X server races) */
d->sleep_before_run = 1;
return TRUE;
}
......
......@@ -249,6 +249,9 @@ gdm_server_reinit (GdmDisplay *disp)
#endif
return TRUE;
} else {
/* if something really REALLY screwed up, then whack the
lockfiles for safety */
gdm_server_whack_lockfile (d);
return FALSE;
}
}
......@@ -264,6 +267,7 @@ void
gdm_server_stop (GdmDisplay *disp)
{
static gboolean waiting_for_server = FALSE;
int old_servstat;
if (disp == NULL)
return;
......@@ -282,6 +286,7 @@ gdm_server_stop (GdmDisplay *disp)
gdm_debug ("gdm_server_stop: Server for %s going down!", disp->name);
old_servstat = disp->servstat;
disp->servstat = SERVER_DEAD;
if (disp->servpid > 0) {
......@@ -311,9 +316,15 @@ gdm_server_stop (GdmDisplay *disp)
gdm_sigchld_block_pop ();
gdm_server_whack_lockfile (disp);
if (old_servstat == SERVER_RUNNING)
gdm_server_whack_lockfile (disp);
gdm_debug ("gdm_server_stop: Server pid %d dead", (int)servpid);
/* just in case we restart again wait at least
one sec to avoid races */
if (d->sleep_before_run < 1)
d->sleep_before_run = 1;
}
gdm_server_wipe_cookies (disp);
......@@ -628,6 +639,26 @@ do_server_wait (GdmDisplay *d)
if (d->servpid <= 1) {
d->servstat = SERVER_ABORT;
}
if (d->servstat != SERVER_RUNNING) {
/* bad things are happening */
if (d->servpid > 0) {
pid_t pid;
d->dsp = NULL;
gdm_sigchld_block_push ();
pid = d->servpid;
d->servpid = 0;
if (pid > 1 &&
kill (pid, SIGTERM) == 0)
ve_waitpid_no_signal (pid, NULL, 0);
gdm_sigchld_block_pop ();
}
/* We will rebake cookies anyway, so wipe these */
gdm_server_wipe_cookies (d);
}
}
/**
......@@ -638,8 +669,11 @@ do_server_wait (GdmDisplay *d)
*/
gboolean
gdm_server_start (GdmDisplay *disp, gboolean treat_as_flexi,
int min_flexi_disp, int flexi_retries)
gdm_server_start (GdmDisplay *disp,
gboolean try_again_if_busy /* only affects non-flexi servers */,
gboolean treat_as_flexi,
int min_flexi_disp,
int flexi_retries)
{
int flexi_disp = 20;
char *vtarg = NULL;
......@@ -739,26 +773,6 @@ gdm_server_start (GdmDisplay *disp, gboolean treat_as_flexi,
break;
}
/* bad things are happening */
if (d->servpid > 0) {
pid_t pid;
d->dsp = NULL;
gdm_sigchld_block_push ();
pid = d->servpid;
d->servpid = 0;
if (pid > 1 &&
kill (pid, SIGTERM) == 0)
ve_waitpid_no_signal (pid, NULL, 0);
gdm_sigchld_block_pop ();
gdm_server_whack_lockfile (disp);
}
/* We will rebake cookies anyway, so wipe these */
gdm_server_wipe_cookies (disp);
if (disp->type == TYPE_FLEXI_XNEST &&
display_xnest_no_connect (disp)) {
gdm_slave_send_num (GDM_SOP_FLEXI_ERR,
......@@ -787,10 +801,22 @@ gdm_server_start (GdmDisplay *disp, gboolean treat_as_flexi,
/* eki eki */
_exit (DISPLAY_REMANAGE);
}
return gdm_server_start (d, treat_as_flexi,
return gdm_server_start (d, FALSE /*try_again_if_busy */,
treat_as_flexi,
flexi_disp + 1,
flexi_retries - 1);
} else {
if (try_again_if_busy) {
gdm_debug ("%s: Display %s busy. Trying once again "
"(after 2 sec delay)",
"gdm_server_start", d->name);
gdm_sleep_no_signal (2);
return gdm_server_start (d,
FALSE /* try_again_if_busy */,
treat_as_flexi,
flexi_disp,
flexi_retries);
}
if (busy_ask_user (disp)) {
gdm_error (_("%s: Display %s busy. Trying "
"another display number."),
......@@ -798,6 +824,7 @@ gdm_server_start (GdmDisplay *disp, gboolean treat_as_flexi,
d->name);
d->busy_display = TRUE;
return gdm_server_start (d,
FALSE /*try_again_if_busy */,
TRUE /* treat as flexi */,
high_display_num + 1,
flexi_retries - 1);
......
......@@ -28,6 +28,7 @@ void gdm_server_wipe_cookies (GdmDisplay *disp);
void gdm_server_whack_lockfile (GdmDisplay *disp);
gboolean gdm_server_start (GdmDisplay *d,
gboolean try_again_if_busy,
gboolean treat_as_flexi,
int min_flexi_disp,
int flexi_retries);
......
......@@ -1186,7 +1186,7 @@ gdm_slave_run (GdmDisplay *display)
gdm_random_tick ();
if G_UNLIKELY (d->sleep_before_run > 0) {
if (d->sleep_before_run > 0) {
gdm_debug ("gdm_slave_run: Sleeping %d seconds before server start", d->sleep_before_run);
gdm_sleep_no_signal (d->sleep_before_run);
d->sleep_before_run = 0;
......@@ -1203,6 +1203,7 @@ gdm_slave_run (GdmDisplay *display)
if (SERVER_IS_LOCAL (d) &&
d->servpid <= 0) {
if G_UNLIKELY ( ! gdm_server_start (d,
TRUE /* try_again_if_busy */,
FALSE /* treat_as_flexi */,
20 /* min_flexi_disp */,
5 /* flexi_retries */)) {
......@@ -4467,9 +4468,10 @@ gdm_slave_child_handler (int sig)
} else if (pid != 0 && pid == d->chooserpid) {
d->chooserpid = 0;
} else if (pid != 0 && pid == d->servpid) {
if (d->servstat == SERVER_RUNNING)
gdm_server_whack_lockfile (d);
d->servstat = SERVER_DEAD;
d->servpid = 0;
gdm_server_whack_lockfile (d);
gdm_server_wipe_cookies (d);
gdm_slave_whack_temp_auth_file ();
......@@ -4488,6 +4490,11 @@ gdm_slave_child_handler (int sig)
gdm_slave_send_num (GDM_SOP_CHOOSERPID, 0);
kill (d->chooserpid, SIGTERM);
}
/* just in case we restart again wait at least
one sec to avoid races */
if (d->sleep_before_run < 1)
d->sleep_before_run = 1;
} else if (pid == extra_process) {
/* an extra process died, yay! */
extra_process = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment