io pipe refactoring

From: Robert Collins <robertc@dont-contact.us>
Date: 07 Jan 2003 17:34:05 +1100

Any objection to the attached patch?

It abstracts the comm interruption signal pipe back to the comm layer.
Although only the aufs code needs it today, IMO it's logically part of
the comm implementation, not the async implementation.

Rob

-- 
GPG key available at: <http://users.bigpond.net.au/robertc/keys.txt>.

? proposed_IOPipe.patch
? auth/Makefile.in
? fs/Makefile.in
? fs/aufs/Makefile.in
? fs/coss/Makefile.in
? fs/diskd/Makefile.in
? fs/null/Makefile.in
? fs/ufs/Makefile.in
? repl/Makefile.in
Index: comm.cc
===================================================================
RCS file: /cvsroot/squid/squid3/src/comm.cc,v
retrieving revision 1.13
diff -r1.13 comm.cc
1887a1888,1914
>
> void CommIO::Initialise()
> {
> /* Initialize done pipe signal */
> int DonePipe[2];
> pipe(DonePipe);
> DoneFD = DonePipe[1];
> fd_open(DonePipe[0], FD_PIPE, "async-io completetion event: main");
> fd_open(DonePipe[1], FD_PIPE, "async-io completetion event: threads");
> commSetNonBlocking(DonePipe[0]);
> commSetNonBlocking(DonePipe[1]);
> commSetSelect(DonePipe[0], COMM_SELECT_READ, NULLFDHandler, NULL, 0);
> Initialised = true;
> }
>
> bool CommIO::Initialised = false;
> bool CommIO::DoneSignalled = false;
> int CommIO::DoneFD = -1;
>
> void
> CommIO::NULLFDHandler(int fd, void *data)
> {
> char buf[256];
> DoneSignalled = false;
> read(fd, buf, sizeof(buf));
> commSetSelect(fd, COMM_SELECT_READ, NULLFDHandler, NULL, 0);
> }
Index: comm.h
===================================================================
RCS file: /cvsroot/squid/squid3/src/comm.h,v
retrieving revision 1.6
diff -r1.6 comm.h
22a23,45
> /* Where should this belong? */
> class CommIO {
> public:
> static inline void NotifyIOCompleted();
> static void Initialise();
> private:
> static void NULLFDHandler(int, void *);
> static bool Initialised;
> static bool DoneSignalled;
> static int DoneFD;
> };
>
> /* Inline code. TODO: make structued approach to inlining */
> void
> CommIO::NotifyIOCompleted() {
> if (!Initialised)
> Initialise();
> if (!DoneSignalled) {
> DoneSignalled = true;
> write(DoneFD, "!", 1);
> }
> };
>
Index: fs/aufs/aiops.cc
===================================================================
RCS file: /cvsroot/squid/squid3/src/fs/aufs/aiops.cc,v
retrieving revision 1.4
diff -r1.4 aiops.cc
48a49
> #include "comm.h"
149,150d149
< static int done_fd = 0;
< static int done_signalled = 0;
227,235d225
< squidaio_fdhandler(int fd, void *data)
< {
< char buf[256];
< done_signalled = 0;
< read(fd, buf, sizeof(buf));
< commSetSelect(fd, COMM_SELECT_READ, squidaio_fdhandler, NULL, 0);
< }
<
< static void
239d228
< int done_pipe[2];
283,291d271
< /* Initialize done pipe signal */
< pipe(done_pipe);
< done_fd = done_pipe[1];
< fd_open(done_pipe[0], FD_PIPE, "async-io completetion event: main");
< fd_open(done_pipe[1], FD_PIPE, "async-io completetion event: threads");
< commSetNonBlocking(done_pipe[0]);
< commSetNonBlocking(done_pipe[1]);
< commSetSelect(done_pipe[0], COMM_SELECT_READ, squidaio_fdhandler, NULL, 0);
<
413,416c393
< if (!done_signalled) {
< done_signalled = 1;
< write(done_fd, "!", 1);
< }

---
> 	CommIO::NotifyIOCompleted();

Received on Mon Jan 06 2003 - 23:34:09 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:19:05 MST