summaryrefslogtreecommitdiff
path: root/src/ivyxtloop.c
diff options
context:
space:
mode:
authorbustico2008-03-21 09:03:34 +0000
committerbustico2008-03-21 09:03:34 +0000
commit6ca781b8a38474ab428d5fcb3b489dfe3e974334 (patch)
tree8c8725c88c3fd031d632a9f2b1f7376d1cb3c75b /src/ivyxtloop.c
parent50236114f04a0050625bedee7c4c02b36b1213ae (diff)
downloadivy-c-6ca781b8a38474ab428d5fcb3b489dfe3e974334.zip
ivy-c-6ca781b8a38474ab428d5fcb3b489dfe3e974334.tar.gz
ivy-c-6ca781b8a38474ab428d5fcb3b489dfe3e974334.tar.bz2
ivy-c-6ca781b8a38474ab428d5fcb3b489dfe3e974334.tar.xz
- numerous fixes
- socket in non blocking mode (resolve some deadlock, and agent are immune to another agent beeing blocked)
Diffstat (limited to 'src/ivyxtloop.c')
-rw-r--r--src/ivyxtloop.c27
1 files changed, 26 insertions, 1 deletions
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 ()
{