зеркало из
1
0
Форкнуть 0

Avoid spontaneous exception when connection is hung up

This commit is contained in:
Alp Toker 2007-01-26 23:13:32 +00:00
Родитель 9fb4403e09
Коммит 615e539e41
1 изменённых файлов: 10 добавлений и 1 удалений

Просмотреть файл

@ -30,6 +30,15 @@ namespace NDesk.DBus
public static void Init (Connection conn)
{
IOFunc dispatchHandler = delegate (IOChannel source, IOCondition condition, IntPtr data) {
if ((condition & IOCondition.Hup) == IOCondition.Hup) {
if (Protocol.Verbose)
Console.Error.WriteLine ("Warning: Connection was probably hung up (" + condition + ")");
//TODO: handle disconnection properly, consider memory management
return false;
}
//this may not provide expected behaviour all the time, but works for now
conn.Iterate ();
return true;
};
@ -40,7 +49,7 @@ namespace NDesk.DBus
static void Init (Connection conn, IOFunc dispatchHandler)
{
IOChannel channel = new IOChannel ((int)conn.Transport.SocketHandle);
IO.AddWatch (channel, IOCondition.In, dispatchHandler);
IO.AddWatch (channel, IOCondition.In | IOCondition.Hup, dispatchHandler);
}
}
}