This commit is contained in:
Havoc Pennington 2001-09-16 03:47:05 +00:00
parent a926a4a0ca
commit 52dc32031d
3 changed files with 73 additions and 21 deletions

View File

@ -870,6 +870,8 @@ process_ice_messages (GIOChannel *channel,
IceConn connection = (IceConn) client_data; IceConn connection = (IceConn) client_data;
IceProcessMessagesStatus status; IceProcessMessagesStatus status;
g_print ("process messages %p\n", connection);
/* This blocks infinitely sometimes. I don't know what /* This blocks infinitely sometimes. I don't know what
* to do about it. Checking "condition" just breaks * to do about it. Checking "condition" just breaks
* session management. * session management.
@ -877,29 +879,39 @@ process_ice_messages (GIOChannel *channel,
status = IceProcessMessages (connection, NULL, NULL); status = IceProcessMessages (connection, NULL, NULL);
if (status == IceProcessMessagesIOError) if (status == IceProcessMessagesIOError)
{ {
#if 0
IcePointer context = IceGetConnectionContext (connection);
#endif
/* We were disconnected */ /* We were disconnected */
IceSetShutdownNegotiation (connection, False); IceSetShutdownNegotiation (connection, False);
IceCloseConnection (connection); IceCloseConnection (connection);
g_print ("closing %p due to IO error\n", connection);
return FALSE;
}
else if (status == IceProcessMessagesConnectionClosed)
{
/* connection is now invalid */
g_print ("%p closed\n", connection);
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
/* This is called when a new ICE connection is made. It arranges for /* This is called when a new ICE connection is made and again when
the ICE connection to be handled via the event loop. */ * it's closed. ICE connections may be used by multiple clients. The
* function arranges for the ICE connection to be handled or stop
* being handled via the event loop.
*/
static void static void
new_ice_connection (IceConn connection, IcePointer client_data, Bool opening, new_ice_connection (IceConn connection, IcePointer client_data, Bool opening,
IcePointer *watch_data) IcePointer *watch_data)
{ {
guint input_id; guint input_id;
g_print ("new connection %p opening = %d\n", connection, opening);
if (opening) if (opening)
{ {
/* Make sure we don't pass on these file descriptors to any /* Make sure we don't pass on these file descriptors to any
@ -937,19 +949,22 @@ accept_connection (GIOChannel *channel,
IceListenObj listen_obj; IceListenObj listen_obj;
IceAcceptStatus status; IceAcceptStatus status;
IceConnectStatus cstatus; IceConnectStatus cstatus;
IceProcessMessagesStatus pstatus;
IceConn cnxn; IceConn cnxn;
listen_obj = client_data; listen_obj = client_data;
cnxn = IceAcceptConnection (listen_obj, cnxn = IceAcceptConnection (listen_obj,
&status); &status);
if (cnxn == NULL || status != IceAcceptSuccess) if (cnxn == NULL || status != IceAcceptSuccess)
{ {
msm_warning (_("Failed to accept new ICE connection\n")); msm_warning (_("Failed to accept new ICE connection\n"));
return TRUE; return TRUE;
} }
g_print ("accept connection %p\n", cnxn);
/* I believe this means we refuse to argue with clients over /* I believe this means we refuse to argue with clients over
* whether we are going to shut their ass down. But I could * whether we are going to shut their ass down. But I could
* be wrong. * be wrong.
@ -970,7 +985,22 @@ accept_connection (GIOChannel *channel,
cstatus = IceConnectionStatus (cnxn); cstatus = IceConnectionStatus (cnxn);
while (cstatus == IceConnectPending) while (cstatus == IceConnectPending)
{ {
IceProcessMessages (cnxn, NULL, NULL); pstatus = IceProcessMessages (cnxn, NULL, NULL);
if (pstatus == IceProcessMessagesIOError)
{
/* We were disconnected */
IceCloseConnection (cnxn);
cnxn = NULL;
break;
}
else if (pstatus == IceProcessMessagesConnectionClosed)
{
/* cnxn is now invalid */
cnxn = NULL;
break;
}
cstatus = IceConnectionStatus (cnxn); cstatus = IceConnectionStatus (cnxn);
} }
@ -981,20 +1011,45 @@ accept_connection (GIOChannel *channel,
else else
msm_warning (_("Rejecting new connection (some client was not allowed to connect to the session manager)\n")); msm_warning (_("Rejecting new connection (some client was not allowed to connect to the session manager)\n"));
/* IceCloseConnection (cnxn);*/ if (cnxn)
IceCloseConnection (cnxn);
} }
return TRUE; return TRUE;
} }
/* We call any handler installed before (or after) ice_init but
* avoid calling the default libICE handler which does an exit()
*/
static void static void
ice_io_error_handler (IceConn connection) ice_io_error_handler (IceConn connection)
{ {
IceCloseConnection (connection); /* do nothing; next IceProcessMessages on the connection wil get
} * an IOError resulting in us calling IceCloseConnection()
*/
}
static void
ice_error_handler (IceConn connection,
Bool swap,
int offending_minor_opcode,
unsigned long offending_sequence,
int error_class,
int severity,
IcePointer values)
{
/* The default error handler would give a more informative message
* than we are, but it would also exit most of the time, which
* is not appropriate here.
*
* gnome-session closes the connection in here, but I'm not sure that
* counts as a good idea. the default handler doesn't do that.
*/
msm_warning (_("ICE error received, opcode: %d sequence: %lu class: %d severity: %d\n"),
offending_minor_opcode,
offending_sequence,
error_class,
severity);
}
static void static void
ice_init (MsmServer *server) ice_init (MsmServer *server)
@ -1012,7 +1067,8 @@ ice_init (MsmServer *server)
int i; int i;
IceSetIOErrorHandler (ice_io_error_handler); IceSetIOErrorHandler (ice_io_error_handler);
IceSetErrorHandler (ice_error_handler);
IceAddConnectionWatch (new_ice_connection, NULL); IceAddConnectionWatch (new_ice_connection, NULL);
/* Some versions of IceListenForConnections have a bug which causes /* Some versions of IceListenForConnections have a bug which causes

View File

@ -111,9 +111,6 @@ void
msm_session_launch (MsmSession *session) msm_session_launch (MsmSession *session)
{ {
system ("xclock &"); system ("xclock &");
system ("xclock &");
system ("xclock &");
system ("xterm &");
} }
MsmSavedClient* MsmSavedClient*
@ -304,6 +301,7 @@ msm_session_get_for_filename (const char *name,
return session; return session;
} }
/* FIXME FALSE */
if (FALSE && session->clients == NULL) if (FALSE && session->clients == NULL)
{ {
session = recover_failed_session (session, session = recover_failed_session (session,

View File

@ -70,8 +70,6 @@ msm_warning (const char *format, ...)
fflush (stderr); fflush (stderr);
g_free (str); g_free (str);
exit (1);
} }
gboolean gboolean