From 81447ed392e57f822e09cf648cb16732a3e3773f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 19 Jun 2004 19:27:47 +0000 Subject: cli protocol git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@28 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/iochannel.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/iochannel.c') diff --git a/src/iochannel.c b/src/iochannel.c index 2044d561..f0c4c499 100644 --- a/src/iochannel.c +++ b/src/iochannel.c @@ -15,6 +15,8 @@ struct iochannel { int readable; int writable; + int no_close; + struct mainloop_source* input_source, *output_source; }; @@ -83,6 +85,7 @@ struct iochannel* iochannel_new(struct mainloop*m, int ifd, int ofd) { io->callback = NULL; io->readable = 0; io->writable = 0; + io->no_close = 0; if (ifd == ofd) { assert(ifd >= 0); @@ -109,10 +112,12 @@ struct iochannel* iochannel_new(struct mainloop*m, int ifd, int ofd) { void iochannel_free(struct iochannel*io) { assert(io); - if (io->ifd >= 0) - close(io->ifd); - if (io->ofd >= 0 && io->ofd != io->ifd) - close(io->ofd); + if (!io->no_close) { + if (io->ifd >= 0) + close(io->ifd); + if (io->ofd >= 0 && io->ofd != io->ifd) + close(io->ofd); + } if (io->input_source) mainloop_source_free(io->input_source); @@ -162,3 +167,8 @@ void iochannel_set_callback(struct iochannel*io, void (*callback)(struct iochann io->callback = callback; io->userdata = userdata; } + +void iochannel_set_noclose(struct iochannel*io, int b) { + assert(io); + io->no_close = b; +} -- cgit