]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Use FD_READ_METHOD/FD_WRITE_METHOD instead of read()/write()
authorserassio <>
Thu, 7 Apr 2005 01:01:01 +0000 (01:01 +0000)
committerserassio <>
Thu, 7 Apr 2005 01:01:01 +0000 (01:01 +0000)
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

src/CommIO.h [new file with mode: 0755]
src/DiskIO/DiskThreads/aiops.cc
src/Makefile.am
src/comm.cc
src/comm.h

diff --git a/src/CommIO.h b/src/CommIO.h
new file mode 100755 (executable)
index 0000000..4577ab1
--- /dev/null
@@ -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
index c8980a8a71b83a575844c4c2d9ab4afb5586971d..c9f84bcef0938cad8ee9f76d84504836757d39b1 100644 (file)
@@ -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 <slf@connect.com.au>
@@ -50,7 +50,7 @@
 #if HAVE_SCHED_H
 #include       <sched.h>
 #endif
-#include "comm.h"
+#include "CommIO.h"
 
 #define RIDICULOUS_LENGTH      4096
 
index a2885697efe7901cc0c357192697b2e4d7f94f42..fc36073f88591b31e447ed1f871bb543507a9dfa 100644 (file)
@@ -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 \
index 038759420f044383d5c725bcd510545e968b201d..e40e453f5fc158b0d7626b53b60e501f006b70ce 100644 (file)
@@ -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
index 88a2c5a7d236305f55cd2e8be80ac19f3669baf8..5ac570e50b8d972dbdedc71ca807a88dcba6862e 100644 (file)
@@ -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