Author: adrian.chadd
Date: Fri Mar 27 17:00:28 2009
New Revision: 13872

Added:
    branches/LUSCA_HEAD/libasyncio/
    branches/LUSCA_HEAD/libasyncio/Makefile.am
    branches/LUSCA_HEAD/libasyncio/aiops.c   (contents, props changed)
       - copied, changed from r13870,  
/branches/LUSCA_HEAD/src/fs/aufs/aiops.c
    branches/LUSCA_HEAD/libasyncio/aiops_win32.c   (props changed)
       - copied unchanged from r13870,  
/branches/LUSCA_HEAD/src/fs/aufs/aiops_win32.c
    branches/LUSCA_HEAD/libasyncio/async_io.c   (contents, props changed)
       - copied, changed from r13870,  
/branches/LUSCA_HEAD/src/fs/aufs/async_io.c
    branches/LUSCA_HEAD/libasyncio/async_io.h   (contents, props changed)
       - copied, changed from r13870,  
/branches/LUSCA_HEAD/src/fs/aufs/async_io.h
Modified:
    branches/LUSCA_HEAD/Makefile.am
    branches/LUSCA_HEAD/configure.in

Log:
Commit #1 - migrate out the async io code into an external library to be
reused and tested outside of the application proper.

This breaks asyncio builds as I haven't yet disabled the stuff in  
src/fs/aufs/.



Modified: branches/LUSCA_HEAD/Makefile.am
==============================================================================
--- branches/LUSCA_HEAD/Makefile.am     (original)
+++ branches/LUSCA_HEAD/Makefile.am     Fri Mar 27 17:00:28 2009
@@ -4,8 +4,8 @@
  #

  AUTOMAKE_OPTIONS = dist-bzip2 subdir-objects 1.5
-DIST_SUBDIRS   = lib libcore libmem libsqname libcb libiapp libstat libhttp  
libsqdns libsqident libsqinet libhelper libmime libsqdebug libstmem snmplib  
scripts src icons errors contrib doc helpers tools app
-SUBDIRS                = lib libcore libmem libsqname libcb libiapp libstat 
libhttp  
libsqdns libsqident libsqinet libhelper libmime libsqdebug libstmem  
@makesnmplib@ scripts src icons errors doc helpers tools app
+DIST_SUBDIRS   = lib libcore libmem libsqname libcb libiapp libstat libhttp  
libsqdns libsqident libsqinet libhelper libmime libsqdebug libstmem  
libasyncio snmplib scripts src icons errors contrib doc helpers tools app
+SUBDIRS                = lib libcore libmem libsqname libcb libiapp libstat 
libhttp  
libsqdns libsqident libsqinet libhelper libmime libsqdebug libstmem  
libasyncio @makesnmplib@ scripts src icons errors doc helpers tools app

  DISTCLEANFILES = include/stamp-h include/stamp-h[0-9]*
  DEFAULT_PINGER                = $(libexecdir)/`echo pinger |  
sed '$(transform);s/$$/$(EXEEXT)/'`

Modified: branches/LUSCA_HEAD/configure.in
==============================================================================
--- branches/LUSCA_HEAD/configure.in    (original)
+++ branches/LUSCA_HEAD/configure.in    Fri Mar 27 17:00:28 2009
@@ -3319,6 +3319,7 @@
        app/Makefile \
        app/tcptest/Makefile \
        libmime/Makefile \
+       libasyncio/Makefile \
        libsqdns/Makefile \
        libsqident/Makefile \
        libsqinet/Makefile \

Added: branches/LUSCA_HEAD/libasyncio/Makefile.am
==============================================================================
--- (empty file)
+++ branches/LUSCA_HEAD/libasyncio/Makefile.am  Fri Mar 27 17:00:28 2009
@@ -0,0 +1,10 @@
+## Process this file with automake to produce Makefile.in
+
+LDADD = -L../lib -lmiscutil
+
+libasyncio_a_SOURCES = \
+       aiops.c \
+       async_io.c
+
+noinst_LIBRARIES = \
+       libasyncio.a

Copied: branches/LUSCA_HEAD/libasyncio/aiops.c (from r13870,  
/branches/LUSCA_HEAD/src/fs/aufs/aiops.c)
==============================================================================
--- /branches/LUSCA_HEAD/src/fs/aufs/aiops.c    (original)
+++ branches/LUSCA_HEAD/libasyncio/aiops.c      Fri Mar 27 17:00:28 2009
@@ -36,20 +36,51 @@
  #error "_REENTRANT MUST be defined to build squid async io support."
  #endif

-#include "squid.h"
-#include "async_io.h"
-
+#include       <pthread.h>
  #include      <stdio.h>
  #include      <sys/types.h>
  #include      <sys/stat.h>
+#include       <sys/uio.h>
+#include       <unistd.h>
  #include      <fcntl.h>
-#include       <pthread.h>
  #include      <errno.h>
  #include      <dirent.h>
  #include      <signal.h>
  #if HAVE_SCHED_H
  #include      <sched.h>
  #endif
+#include       <string.h>
+
+/* this is for sqinet.h, which shouldn't be needed in here */
+#include       <netinet/in.h>
+#include       <sys/socket.h>
+
+#include "../include/util.h"
+#include "../include/Array.h"
+#include "../include/Stack.h"
+
+#include "../libcore/tools.h"
+#include "../libcore/gb.h"
+#include "../libcore/kb.h"
+
+#include "../libsqdebug/debug.h"
+
+#include "../libmem/MemPool.h"
+#include "../libmem/MemBufs.h"
+#include "../libmem/MemBuf.h"
+
+/*
+ * This is for comm.h, which includes stuff that should be in the  
filedescriptor
+ * related code. Sigh. That should be fixed.
+ */
+#include "../libsqinet/sqinet.h"
+
+#include "../libiapp/fd_types.h"
+#include "../libiapp/comm_types.h"
+#include "../libiapp/comm.h"
+#include "../libiapp/disk.h"
+
+#include "async_io.h"

  #define RIDICULOUS_LENGTH     4096

@@ -290,9 +321,9 @@

      /* Initialize request queue */
      if (pthread_mutex_init(&(request_queue.mutex), NULL))
-       fatal("Failed to create mutex");
+       libcore_fatalf("Failed to create mutex");
      if (pthread_cond_init(&(request_queue.cond), NULL))
-       fatal("Failed to create condition variable");
+       libcore_fatalf("Failed to create condition variable");
      request_queue.head = NULL;
      request_queue.tailp = &request_queue.head;
      request_queue.requests = 0;
@@ -300,9 +331,9 @@

      /* Initialize done queue */
      if (pthread_mutex_init(&(done_queue.mutex), NULL))
-       fatal("Failed to create mutex");
+       libcore_fatalf("Failed to create mutex");
      if (pthread_cond_init(&(done_queue.cond), NULL))
-       fatal("Failed to create condition variable");
+       libcore_fatalf("Failed to create condition variable");
      done_queue.head = NULL;
      done_queue.tailp = &done_queue.head;
      done_queue.requests = 0;
@@ -330,6 +361,7 @@
            if (j < 4)
                j = 4;
        }
+#if 0
  #if USE_AUFSOPS
        j = 6;
        for (i = 0; i < n_coss_dirs; i++) {
@@ -337,6 +369,7 @@
            j = 3;
        }
  #endif
+#endif
      }
      if (squidaio_nthreads == 0)
        squidaio_nthreads = THREAD_FACTOR;
@@ -969,24 +1002,5 @@
        break;
      default:
        break;
-    }
-}
-
-void
-squidaio_stats(StoreEntry * sentry)
-{
-    squidaio_thread_t *threadp;
-    int i;
-
-    if (!squidaio_initialised)
-       return;
-
-    storeAppendPrintf(sentry, "\n\nThreads Status:\n");
-    storeAppendPrintf(sentry, "#\tID\t# Requests\n");
-
-    threadp = threads;
-    for (i = 0; i < squidaio_nthreads; i++) {
-       storeAppendPrintf(sentry, "%i\t0x%lx\t%ld\n", i + 1, (unsigned long)  
threadp->thread, threadp->requests);
-       threadp = threadp->next;
      }
  }

Copied: branches/LUSCA_HEAD/libasyncio/async_io.c (from r13870,  
/branches/LUSCA_HEAD/src/fs/aufs/async_io.c)
==============================================================================
--- /branches/LUSCA_HEAD/src/fs/aufs/async_io.c (original)
+++ branches/LUSCA_HEAD/libasyncio/async_io.c   Fri Mar 27 17:00:28 2009
@@ -34,7 +34,58 @@
   *
   */

-#include "squid.h"
+#ifndef _REENTRANT
+#error "_REENTRANT MUST be defined to build squid async io support."
+#endif
+
+#include        <pthread.h>
+#include        <stdio.h>
+#include        <sys/types.h>
+#include        <sys/stat.h>
+#include        <sys/uio.h>
+#include        <unistd.h>
+#include        <fcntl.h>
+#include        <errno.h>
+#include        <dirent.h>
+#include        <signal.h>
+#if HAVE_SCHED_H
+#include        <sched.h>
+#endif
+#include        <string.h>
+
+/* this is for sqinet.h, which shouldn't be needed in here */
+#include        <netinet/in.h>
+#include        <sys/socket.h>
+
+#include "../include/util.h"
+#include "../include/Array.h"
+#include "../include/Stack.h"
+
+#include "../libcore/tools.h"
+#include "../libcore/gb.h"
+#include "../libcore/kb.h"
+#include "../libcore/dlink.h"
+
+#include "../libsqdebug/debug.h"
+
+#include "../libmem/MemPool.h"
+#include "../libmem/MemBufs.h"
+#include "../libmem/MemBuf.h"
+
+#include "../libcb/cbdata.h"
+
+/*
+ * This is for comm.h, which includes stuff that should be in the  
filedescriptor
+ * related code. Sigh. That should be fixed.
+ */
+#include "../libsqinet/sqinet.h"
+
+#include "../libiapp/fd_types.h"
+#include "../libiapp/comm_types.h"
+#include "../libiapp/comm.h"
+#include "../libiapp/disk.h"
+
+
  #include "async_io.h"

  #define _AIO_OPEN     0
@@ -78,7 +129,9 @@
  static dlink_list used_list;
  static int initialised = 0;
  static int usage_count = 0;
+#if 0
  static OBJH aioStats;
+#endif
  static MemPool *squidaio_ctrl_pool;

  void
@@ -88,8 +141,10 @@
      if (initialised)
        return;
      squidaio_ctrl_pool = memPoolCreate("aio_ctrl",  
sizeof(squidaio_ctrl_t));
+#if 0
      cachemgrRegister("squidaio_counts", "Async IO Function Counters",
        aioStats, 0, 1);
+#endif
      initialised = 1;
  }

@@ -339,6 +394,7 @@
      return retval;
  }

+#if 0
  void
  aioStats(StoreEntry * sentry)
  {
@@ -355,10 +411,11 @@
      storeAppendPrintf(sentry, "queue\t%d\n", squidaio_get_queue_len());
      squidaio_stats(sentry);
  }
+#endif

  /* Flush all pending I/O */
  void
-aioSync(SwapDir * SD)
+aioSync(void)
  {
      if (!initialised)
        return;                 /* nothing to do then */

Copied: branches/LUSCA_HEAD/libasyncio/async_io.h (from r13870,  
/branches/LUSCA_HEAD/src/fs/aufs/async_io.h)
==============================================================================
--- /branches/LUSCA_HEAD/src/fs/aufs/async_io.h (original)
+++ branches/LUSCA_HEAD/libasyncio/async_io.h   Fri Mar 27 17:00:28 2009
@@ -51,7 +51,6 @@
  int squidaio_get_queue_len(void);
  void *squidaio_xmalloc(int size);
  void squidaio_xfree(void *p, int size);
-void squidaio_stats(StoreEntry *);

  void aioInit(void);
  void aioDone(void);
@@ -64,7 +63,7 @@
  void aioUnlink(const char *, AIOCB *, void *);
  void aioTruncate(const char *, off_t length, AIOCB *, void *);
  int aioCheckCallbacks(void);
-void aioSync(SwapDir *);
+void aioSync(void);
  int aioQueueSize(void);

  #endif

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"lusca-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/lusca-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to