From: serassio <> Date: Thu, 7 Apr 2005 01:01:01 +0000 (+0000) Subject: Use FD_READ_METHOD/FD_WRITE_METHOD instead of read()/write() X-Git-Tag: SQUID_3_0_PRE4~813 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=56410c896d812808af40b8065db1faf5686548ba;p=thirdparty%2Fsquid.git Use FD_READ_METHOD/FD_WRITE_METHOD instead of read()/write() in the async-io completion event for better portability The CommIO class must be moved to a separate include file to avoid problems with fde.h inclusion from comm.h --- diff --git a/src/CommIO.h b/src/CommIO.h new file mode 100755 index 0000000000..4577ab1eea --- /dev/null +++ b/src/CommIO.h @@ -0,0 +1,38 @@ +#ifndef __COMMIO_H__ +#define __COMMIO_H__ + +#include "fde.h" + +class CommIO +{ + +public: + static inline void NotifyIOCompleted(); + static void ResetNotifications(); + static void Initialise(); + static void NotifyIOClose(); + +private: + static void NULLFDHandler(int, void *); + static void FlushPipe(); + static bool Initialised; + static bool DoneSignalled; + static int DoneFD; + static int DoneReadFD; +}; + + +/* Inline code. TODO: make structued approach to inlining */ +void +CommIO::NotifyIOCompleted() +{ + if (!Initialised) + Initialise(); + + if (!DoneSignalled) { + DoneSignalled = true; + FD_WRITE_METHOD(DoneFD, "!", 1); + } +}; + +#endif diff --git a/src/DiskIO/DiskThreads/aiops.cc b/src/DiskIO/DiskThreads/aiops.cc index c8980a8a71..c9f84bcef0 100644 --- a/src/DiskIO/DiskThreads/aiops.cc +++ b/src/DiskIO/DiskThreads/aiops.cc @@ -1,5 +1,5 @@ /* - * $Id: aiops.cc,v 1.2 2005/04/01 21:11:28 serassio Exp $ + * $Id: aiops.cc,v 1.3 2005/04/06 19:01:02 serassio Exp $ * * DEBUG: section 43 AIOPS * AUTHOR: Stewart Forster @@ -50,7 +50,7 @@ #if HAVE_SCHED_H #include #endif -#include "comm.h" +#include "CommIO.h" #define RIDICULOUS_LENGTH 4096 diff --git a/src/Makefile.am b/src/Makefile.am index a2885697ef..fc36073f88 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,7 @@ # # Makefile for the Squid Object Cache server # -# $Id: Makefile.am,v 1.105 2005/02/07 22:17:55 serassio Exp $ +# $Id: Makefile.am,v 1.106 2005/04/06 19:03:46 serassio Exp $ # # Uncomment and customize the following to suit your needs: # @@ -356,6 +356,7 @@ squid_SOURCES = \ clientStream.h \ comm.cc \ comm.h \ + CommIO.h \ comm_select.cc \ comm_poll.cc \ comm_epoll.cc \ diff --git a/src/comm.cc b/src/comm.cc index 038759420f..e40e453f5f 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -1,6 +1,6 @@ /* - * $Id: comm.cc,v 1.402 2005/04/01 21:11:28 serassio Exp $ + * $Id: comm.cc,v 1.403 2005/04/06 19:01:01 serassio Exp $ * * DEBUG: section 5 Socket Functions * AUTHOR: Harvest Derived @@ -39,6 +39,7 @@ #include "StoreIOBuffer.h" #include "comm.h" #include "fde.h" +#include "CommIO.h" #include "ConnectionDetail.h" #if defined(_SQUID_CYGWIN_) @@ -2425,7 +2426,7 @@ int CommIO::DoneReadFD = -1; void CommIO::FlushPipe() { char buf[256]; - read(DoneReadFD, buf, sizeof(buf)); + FD_READ_METHOD(DoneReadFD, buf, sizeof(buf)); } void diff --git a/src/comm.h b/src/comm.h index 88a2c5a7d2..5ac570e50b 100644 --- a/src/comm.h +++ b/src/comm.h @@ -34,26 +34,6 @@ extern int commIsHalfClosed(int); extern void commCheckHalfClosed(void *); extern bool comm_has_incomplete_write(int); -/* Where should this belong? */ - -class CommIO -{ - -public: - static inline void NotifyIOCompleted(); - static void ResetNotifications(); - static void Initialise(); - static void NotifyIOClose(); - -private: - static void NULLFDHandler(int, void *); - static void FlushPipe(); - static bool Initialised; - static bool DoneSignalled; - static int DoneFD; - static int DoneReadFD; -}; - /* Not sure where these should live yet */ class Acceptor @@ -124,17 +104,4 @@ private: void removeCheck (int const); }; -/* Inline code. TODO: make structued approach to inlining */ -void -CommIO::NotifyIOCompleted() -{ - if (!Initialised) - Initialise(); - - if (!DoneSignalled) { - DoneSignalled = true; - write(DoneFD, "!", 1); - } -}; - #endif