From 6ca781b8a38474ab428d5fcb3b489dfe3e974334 Mon Sep 17 00:00:00 2001 From: bustico Date: Fri, 21 Mar 2008 09:03:34 +0000 Subject: - numerous fixes - socket in non blocking mode (resolve some deadlock, and agent are immune to another agent beeing blocked) --- src/ivyxtloop.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'src/ivyxtloop.c') diff --git a/src/ivyxtloop.c b/src/ivyxtloop.c index 6613307..fc5b0ae 100644 --- a/src/ivyxtloop.c +++ b/src/ivyxtloop.c @@ -45,10 +45,14 @@ struct _channel { XtInputId id_read; + XtInputId id_write; XtInputId id_delete; + + HANDLE fd; void *data; ChannelHandleDelete handle_delete; ChannelHandleRead handle_read; + ChannelHandleWrite handle_write; }; @@ -93,6 +97,13 @@ static void IvyXtHandleChannelRead( XtPointer closure, int* source, XtInputId* i (*channel->handle_read)(channel,*source,channel->data); } +static void IvyXtHandleChannelWrite( XtPointer closure, int* source, XtInputId* id ) +{ + Channel channel = (Channel)closure; + TRACE("Handle Channel write %d\n",*source ); + (*channel->handle_write)(channel,*source,channel->data); +} + static void IvyXtHandleChannelDelete( XtPointer closure, int* source, XtInputId* id ) { Channel channel = (Channel)closure; @@ -108,7 +119,8 @@ void IvyXtChannelAppContext( XtAppContext cntx ) Channel IvyChannelAdd(HANDLE fd, void *data, ChannelHandleDelete handle_delete, - ChannelHandleRead handle_read + ChannelHandleRead handle_read, + ChannelHandleWrite handle_write ) { Channel channel; @@ -122,7 +134,9 @@ Channel IvyChannelAdd(HANDLE fd, void *data, channel->handle_delete = handle_delete; channel->handle_read = handle_read; + channel->handle_write = handle_write; channel->data = data; + channel->fd = fd; channel->id_read = XtAppAddInput( app, fd, (XtPointer)XtInputReadMask, IvyXtHandleChannelRead, channel); channel->id_delete = XtAppAddInput( app, fd, (XtPointer)XtInputExceptMask, IvyXtHandleChannelDelete, channel); @@ -131,6 +145,17 @@ Channel IvyChannelAdd(HANDLE fd, void *data, } +void IvyChannelAddWritableEvent(Channel channel) +{ + channel->id_write = XtAppAddInput( app, channel->fd, (XtPointer)XtInputWriteMask, IvyXtHandleChannelWrite, channel); +} + +void IvyChannelClearWritableEvent(Channel channel) +{ + XtRemoveInput( channel->id_write ); +} + + void IvyChannelStop () { -- cgit v1.1