qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acon...@apache.org
Subject svn commit: r1664744 - in /qpid/dispatch/trunk: ./ include/qpid/ include/qpid/dispatch/ src/ src/posix/ tests/
Date Fri, 06 Mar 2015 22:40:23 GMT
Author: aconway
Date: Fri Mar  6 22:40:22 2015
New Revision: 1664744

URL: http://svn.apache.org/r1664744
Log:
DISPATCH-121: Allow memory pools to be switched off at compile time.

For debugging purposes to get better results from toolsl like valgrind.

Fixed memory bugs
- Numerous memory bugs in tests.
- Invalid read in qd_hash_free (remove from DEQ after free)
- Added missing qd_timer_finalize in qd_server_free

Added:
    qpid/dispatch/trunk/src/alloc.h
      - copied, changed from r1664743, qpid/dispatch/trunk/src/alloc_private.h
    qpid/dispatch/trunk/src/alloc_malloc.h
      - copied, changed from r1664743, qpid/dispatch/trunk/src/timer_private.h
    qpid/dispatch/trunk/src/alloc_pool.c
      - copied, changed from r1664743, qpid/dispatch/trunk/src/alloc.c
    qpid/dispatch/trunk/src/alloc_pool.h
      - copied, changed from r1664743, qpid/dispatch/trunk/include/qpid/dispatch/alloc.h
Removed:
    qpid/dispatch/trunk/include/qpid/dispatch/alloc.h
    qpid/dispatch/trunk/src/alloc.c
    qpid/dispatch/trunk/src/alloc_private.h
Modified:
    qpid/dispatch/trunk/CMakeLists.txt
    qpid/dispatch/trunk/include/qpid/dispatch.h
    qpid/dispatch/trunk/include/qpid/dispatch/container.h
    qpid/dispatch/trunk/include/qpid/dispatch/message.h
    qpid/dispatch/trunk/reconfigure.in
    qpid/dispatch/trunk/src/CMakeLists.txt
    qpid/dispatch/trunk/src/bitmask.c
    qpid/dispatch/trunk/src/buffer.c
    qpid/dispatch/trunk/src/compose.c
    qpid/dispatch/trunk/src/config.h.in
    qpid/dispatch/trunk/src/dispatch.c
    qpid/dispatch/trunk/src/hash.c
    qpid/dispatch/trunk/src/iovec.c
    qpid/dispatch/trunk/src/iterator.c
    qpid/dispatch/trunk/src/log.c
    qpid/dispatch/trunk/src/message_private.h
    qpid/dispatch/trunk/src/parse.c
    qpid/dispatch/trunk/src/posix/driver.c
    qpid/dispatch/trunk/src/python_embedded.c
    qpid/dispatch/trunk/src/server.c
    qpid/dispatch/trunk/src/server_private.h
    qpid/dispatch/trunk/src/timer.c
    qpid/dispatch/trunk/src/timer_private.h
    qpid/dispatch/trunk/tests/CMakeLists.txt
    qpid/dispatch/trunk/tests/alloc_test.c
    qpid/dispatch/trunk/tests/field_test.c
    qpid/dispatch/trunk/tests/message_test.c
    qpid/dispatch/trunk/tests/parse_test.c
    qpid/dispatch/trunk/tests/run_unit_tests.c
    qpid/dispatch/trunk/tests/run_unit_tests_size.c
    qpid/dispatch/trunk/tests/server_test.c
    qpid/dispatch/trunk/tests/system_test.py
    qpid/dispatch/trunk/tests/system_tests_qdmanage.py
    qpid/dispatch/trunk/tests/system_tests_qdstat.py
    qpid/dispatch/trunk/tests/timer_test.c
    qpid/dispatch/trunk/tests/tool_test.c

Modified: qpid/dispatch/trunk/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/CMakeLists.txt?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/CMakeLists.txt (original)
+++ qpid/dispatch/trunk/CMakeLists.txt Fri Mar  6 22:40:22 2015
@@ -27,6 +27,9 @@ message("Build type is \"${CMAKE_BUILD_T
 
 project(qpid-dispatch C)
 
+# Build time switch to turn off memory pooling.
+option(USE_MEMORY_POOL "Use per-thread memory pools" ON)
+
 file(STRINGS "${CMAKE_SOURCE_DIR}/VERSION.txt" QPID_DISPATCH_VERSION)
 
 cmake_minimum_required(VERSION 2.6)

Modified: qpid/dispatch/trunk/include/qpid/dispatch.h
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/include/qpid/dispatch.h?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/include/qpid/dispatch.h (original)
+++ qpid/dispatch/trunk/include/qpid/dispatch.h Fri Mar  6 22:40:22 2015
@@ -39,7 +39,6 @@
  * provides the tools to do so.
 */
 
-#include <qpid/dispatch/alloc.h>
 #include <qpid/dispatch/bitmask.h>
 #include <qpid/dispatch/buffer.h>
 #include <qpid/dispatch/ctools.h>

Modified: qpid/dispatch/trunk/include/qpid/dispatch/container.h
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/include/qpid/dispatch/container.h?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/include/qpid/dispatch/container.h (original)
+++ qpid/dispatch/trunk/include/qpid/dispatch/container.h Fri Mar  6 22:40:22 2015
@@ -32,7 +32,6 @@
 #include <proton/engine.h>
 #include <qpid/dispatch/dispatch.h>
 #include <qpid/dispatch/server.h>
-#include <qpid/dispatch/alloc.h>
 #include <qpid/dispatch/ctools.h>
 
 typedef uint8_t qd_dist_mode_t;

Modified: qpid/dispatch/trunk/include/qpid/dispatch/message.h
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/include/qpid/dispatch/message.h?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/include/qpid/dispatch/message.h (original)
+++ qpid/dispatch/trunk/include/qpid/dispatch/message.h Fri Mar  6 22:40:22 2015
@@ -20,7 +20,6 @@
  */
 
 #include <qpid/dispatch/ctools.h>
-#include <qpid/dispatch/alloc.h>
 #include <qpid/dispatch/iterator.h>
 #include <qpid/dispatch/buffer.h>
 #include <qpid/dispatch/compose.h>

Modified: qpid/dispatch/trunk/reconfigure.in
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/reconfigure.in?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/reconfigure.in (original)
+++ qpid/dispatch/trunk/reconfigure.in Fri Mar  6 22:40:22 2015
@@ -7,4 +7,4 @@
 # That will force automatic re-configure and everybody will be happy.
 #
 
-1
+2

Modified: qpid/dispatch/trunk/src/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/CMakeLists.txt?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/CMakeLists.txt (original)
+++ qpid/dispatch/trunk/src/CMakeLists.txt Fri Mar  6 22:40:22 2015
@@ -43,7 +43,6 @@ include_directories(
 
 # Build the qpid-dispatch library.
 set(qpid_dispatch_SOURCES
-  alloc.c
   amqp.c
   bitmask.c
   buffer.c
@@ -74,6 +73,10 @@ set(qpid_dispatch_SOURCES
   waypoint.c
   )
 
+if(USE_MEMORY_POOL)
+  list(APPEND qpid_dispatch_SOURCES alloc_pool.c)
+endif()
+
 set_property(
   SOURCE python_embedded.c router_pynode.c
   PROPERTY COMPILE_FLAGS -Wno-strict-aliasing

Copied: qpid/dispatch/trunk/src/alloc.h (from r1664743, qpid/dispatch/trunk/src/alloc_private.h)
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/alloc.h?p2=qpid/dispatch/trunk/src/alloc.h&p1=qpid/dispatch/trunk/src/alloc_private.h&r1=1664743&r2=1664744&rev=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/alloc_private.h (original)
+++ qpid/dispatch/trunk/src/alloc.h Fri Mar  6 22:40:22 2015
@@ -1,5 +1,5 @@
-#ifndef __dispatch_alloc_private_h__
-#define __dispatch_alloc_private_h__ 1
+#ifndef ALLOC_H
+#define ALLOC_H
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -19,11 +19,12 @@
  * under the License.
  */
 
-#include <qpid/dispatch/alloc.h>
-#include <qpid/dispatch/dispatch.h>
-
-void qd_alloc_initialize(void);
-void qd_alloc_debug_dump(const char *file);
-void qd_alloc_finalize(void);
+#include "config.h"
 
+#if USE_MEMORY_POOL
+#include "alloc_pool.h"
+#else
+#include "alloc_malloc.h"
 #endif
+
+#endif // ALLOC_H

Copied: qpid/dispatch/trunk/src/alloc_malloc.h (from r1664743, qpid/dispatch/trunk/src/timer_private.h)
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/alloc_malloc.h?p2=qpid/dispatch/trunk/src/alloc_malloc.h&p1=qpid/dispatch/trunk/src/timer_private.h&r1=1664743&r2=1664744&rev=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/timer_private.h (original)
+++ qpid/dispatch/trunk/src/alloc_malloc.h Fri Mar  6 22:40:22 2015
@@ -1,5 +1,5 @@
-#ifndef __timer_private_h__
-#define __timer_private_h__ 1
+#ifndef ALLOC_MALLOC_H
+#define ALLOC_MALLOC_H
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -19,34 +19,26 @@
  * under the License.
  */
 
-#include <qpid/dispatch/ctools.h>
-#include <qpid/dispatch/timer.h>
-#include <qpid/dispatch/threading.h>
-
-typedef enum {
-    TIMER_FREE,
-    TIMER_IDLE,
-    TIMER_SCHEDULED,
-    TIMER_PENDING
-} qd_timer_state_t;
-
-
-struct qd_timer_t {
-    DEQ_LINKS(qd_timer_t);
-    qd_server_t      *server;
-    qd_timer_cb_t     handler;
-    void             *context;
-    long              delta_time;
-    qd_timer_state_t  state;
-};
-
-DEQ_DECLARE(qd_timer_t, qd_timer_list_t);
-
-void qd_timer_initialize(sys_mutex_t *server_lock);
-void qd_timer_finalize(void);
-long qd_timer_next_duration_LH(void);
-void qd_timer_visit_LH(long current_time);
-void qd_timer_idle_LH(qd_timer_t *timer);
+/**
+ *@file
+ *
+ * Use simple malloc/free allocation in place of allocation pools.
+ * Useful for debugging with tools like valgrind.
+ */
+
+#define ALLOC_DECLARE(T)                        \
+    T *new_##T(void);                           \
+    void free_##T(T *p);
+
+#define ALLOC_DEFINE_CONFIG(T,S,A,C)                                    \
+    T *new_##T(void) { size_t *a = (A); return (T*) malloc((S)+ (a ? *a : 0)); } \
+    void free_##T(T *p) { free(p); } \
+
+#define ALLOC_DEFINE(T) ALLOC_DEFINE_CONFIG(T, sizeof(T), 0, 0)
+
+static inline void qd_alloc_initialize(void) {}
+static inline void qd_alloc_debug_dump(const char *file) {}
+static inline void qd_alloc_finalize(void) {}
 
 
-#endif
+#endif // ALLOC_MALLOC_H

Copied: qpid/dispatch/trunk/src/alloc_pool.c (from r1664743, qpid/dispatch/trunk/src/alloc.c)
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/alloc_pool.c?p2=qpid/dispatch/trunk/src/alloc_pool.c&p1=qpid/dispatch/trunk/src/alloc.c&r1=1664743&r2=1664744&rev=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/alloc.c (original)
+++ qpid/dispatch/trunk/src/alloc_pool.c Fri Mar  6 22:40:22 2015
@@ -18,7 +18,7 @@
  */
 
 #include <Python.h>
-#include <qpid/dispatch/alloc.h>
+#include "alloc.h"
 #include <qpid/dispatch/ctools.h>
 #include <qpid/dispatch/log.h>
 #include <memory.h>
@@ -27,7 +27,9 @@
 #include "entity.h"
 #include "entity_cache.h"
 
+#if !defined(NDEBUG)
 #define QD_MEMORY_DEBUG 1
+#endif
 
 const char *QD_ALLOCATOR_TYPE = "allocator";
 
@@ -280,7 +282,7 @@ void qd_alloc_finalize(void)
 
     //
     // Note: By the time we get here, the server threads have been joined and there is
-    //       only the main thread remaining.  There is therefore no reason to be 
+    //       only the main thread remaining.  There is therefore no reason to be
     //       concerned about locking.
     //
 
@@ -333,7 +335,7 @@ void qd_alloc_finalize(void)
         //
         if (dump_file && desc->stats->total_free_to_heap < desc->stats->total_alloc_from_heap)
             fprintf(dump_file,
-                    "alloc.c: Items of type '%s' remain allocated at shutdown: %"PRId64"\n",

+                    "alloc.c: Items of type '%s' remain allocated at shutdown: %"PRId64"\n",
                     desc->type_name,
                     desc->stats->total_alloc_from_heap - desc->stats->total_free_to_heap);
 

Copied: qpid/dispatch/trunk/src/alloc_pool.h (from r1664743, qpid/dispatch/trunk/include/qpid/dispatch/alloc.h)
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/alloc_pool.h?p2=qpid/dispatch/trunk/src/alloc_pool.h&p1=qpid/dispatch/trunk/include/qpid/dispatch/alloc.h&r1=1664743&r2=1664744&rev=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/include/qpid/dispatch/alloc.h (original)
+++ qpid/dispatch/trunk/src/alloc_pool.h Fri Mar  6 22:40:22 2015
@@ -8,9 +8,9 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -98,4 +98,8 @@ void qd_dealloc(qd_alloc_type_desc_t *de
  */
 #define ALLOC_DEFINE(T) ALLOC_DEFINE_CONFIG(T, sizeof(T), 0, 0)
 
+void qd_alloc_initialize(void);
+void qd_alloc_debug_dump(const char *file);
+void qd_alloc_finalize(void);
+
 #endif

Modified: qpid/dispatch/trunk/src/bitmask.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/bitmask.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/bitmask.c (original)
+++ qpid/dispatch/trunk/src/bitmask.c Fri Mar  6 22:40:22 2015
@@ -17,9 +17,12 @@
  * under the License.
  */
 
+#include "alloc.h"
 #include <qpid/dispatch/bitmask.h>
-#include <qpid/dispatch/alloc.h>
 #include <assert.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <sys/types.h>
 
 #define QD_BITMASK_LONGS 16
 #define QD_BITMASK_BITS  (QD_BITMASK_LONGS * 64)

Modified: qpid/dispatch/trunk/src/buffer.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/buffer.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/buffer.c (original)
+++ qpid/dispatch/trunk/src/buffer.c Fri Mar  6 22:40:22 2015
@@ -18,7 +18,7 @@
  */
 
 #include <qpid/dispatch/buffer.h>
-#include <qpid/dispatch/alloc.h>
+#include "alloc.h"
 
 static size_t buffer_size = 512;
 static int    size_locked = 0;

Modified: qpid/dispatch/trunk/src/compose.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/compose.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/compose.c (original)
+++ qpid/dispatch/trunk/src/compose.c Fri Mar  6 22:40:22 2015
@@ -18,7 +18,7 @@
  */
 
 #include <qpid/dispatch/ctools.h>
-#include <qpid/dispatch/alloc.h>
+#include "alloc.h"
 #include <qpid/dispatch/buffer.h>
 #include <qpid/dispatch/amqp.h>
 #include "compose_private.h"

Modified: qpid/dispatch/trunk/src/config.h.in
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/config.h.in?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/config.h.in (original)
+++ qpid/dispatch/trunk/src/config.h.in Fri Mar  6 22:40:22 2015
@@ -17,6 +17,5 @@
  * under the License.
  */
 
-#define QPID_DISPATCH_LIB            "${QPID_DISPATCH_LIB}"
-
-
+#define QPID_DISPATCH_LIB "${QPID_DISPATCH_LIB}"
+#cmakedefine01 USE_MEMORY_POOL

Modified: qpid/dispatch/trunk/src/dispatch.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/dispatch.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/dispatch.c (original)
+++ qpid/dispatch/trunk/src/dispatch.c Fri Mar  6 22:40:22 2015
@@ -26,7 +26,7 @@
 
 #include "config.h"
 #include "dispatch_private.h"
-#include "alloc_private.h"
+#include "alloc.h"
 #include "log_private.h"
 #include "router_private.h"
 #include "waypoint_private.h"

Modified: qpid/dispatch/trunk/src/hash.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/hash.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/hash.c (original)
+++ qpid/dispatch/trunk/src/hash.c Fri Mar  6 22:40:22 2015
@@ -19,7 +19,7 @@
 
 #include <qpid/dispatch/hash.h>
 #include <qpid/dispatch/ctools.h>
-#include <qpid/dispatch/alloc.h>
+#include "alloc.h"
 #include <stdio.h>
 #include <string.h>
 
@@ -109,8 +109,8 @@ void qd_hash_free(qd_hash_t *h)
         item = DEQ_HEAD(h->buckets[idx].items);
         while (item) {
             free(item->key);
-            free_qd_hash_item_t(item);
             DEQ_REMOVE_HEAD(h->buckets[idx].items);
+            free_qd_hash_item_t(item);
             item = DEQ_HEAD(h->buckets[idx].items);
         }
     }

Modified: qpid/dispatch/trunk/src/iovec.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/iovec.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/iovec.c (original)
+++ qpid/dispatch/trunk/src/iovec.c Fri Mar  6 22:40:22 2015
@@ -17,9 +17,10 @@
  * under the License.
  */
 
+#include "alloc.h"
 #include <qpid/dispatch/iovec.h>
-#include <qpid/dispatch/alloc.h>
 #include <string.h>
+#include <stdlib.h>
 
 #define QD_IOVEC_MAX 64
 

Modified: qpid/dispatch/trunk/src/iterator.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/iterator.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/iterator.c (original)
+++ qpid/dispatch/trunk/src/iterator.c Fri Mar  6 22:40:22 2015
@@ -19,7 +19,7 @@
 
 #include <qpid/dispatch/iterator.h>
 #include <qpid/dispatch/ctools.h>
-#include <qpid/dispatch/alloc.h>
+#include "alloc.h"
 #include <qpid/dispatch/log.h>
 #include "message_private.h"
 #include <stdio.h>

Modified: qpid/dispatch/trunk/src/log.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/log.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/log.c (original)
+++ qpid/dispatch/trunk/src/log.c Fri Mar  6 22:40:22 2015
@@ -24,7 +24,7 @@
 #include "aprintf.h"
 #include <qpid/dispatch/ctools.h>
 #include <qpid/dispatch/dispatch.h>
-#include <qpid/dispatch/alloc.h>
+#include "alloc.h"
 #include <qpid/dispatch/threading.h>
 #include <qpid/dispatch/log.h>
 #include <stdarg.h>

Modified: qpid/dispatch/trunk/src/message_private.h
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/message_private.h?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/message_private.h (original)
+++ qpid/dispatch/trunk/src/message_private.h Fri Mar  6 22:40:22 2015
@@ -20,7 +20,7 @@
  */
 
 #include <qpid/dispatch/message.h>
-#include <qpid/dispatch/alloc.h>
+#include "alloc.h"
 #include <qpid/dispatch/threading.h>
 
 /** @file

Modified: qpid/dispatch/trunk/src/parse.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/parse.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/parse.c (original)
+++ qpid/dispatch/trunk/src/parse.c Fri Mar  6 22:40:22 2015
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-#include <qpid/dispatch/alloc.h>
+#include "alloc.h"
 #include <qpid/dispatch/ctools.h>
 #include <qpid/dispatch/parse.h>
 #include <qpid/dispatch/amqp.h>

Modified: qpid/dispatch/trunk/src/posix/driver.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/posix/driver.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/posix/driver.c (original)
+++ qpid/dispatch/trunk/src/posix/driver.c Fri Mar  6 22:40:22 2015
@@ -37,7 +37,7 @@
 #include <assert.h>
 
 #include <qpid/dispatch/driver.h>
-#include <qpid/dispatch/alloc.h>
+#include "alloc.h"
 #include <proton/error.h>
 #include <proton/sasl.h>
 #include <proton/ssl.h>

Modified: qpid/dispatch/trunk/src/python_embedded.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/python_embedded.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/python_embedded.c (original)
+++ qpid/dispatch/trunk/src/python_embedded.c Fri Mar  6 22:40:22 2015
@@ -23,7 +23,7 @@
 #include <qpid/dispatch/log.h>
 #include <qpid/dispatch/error.h>
 #include <qpid/dispatch/amqp.h>
-#include <qpid/dispatch/alloc.h>
+#include "alloc.h"
 #include <qpid/dispatch/router.h>
 #include <qpid/dispatch/error.h>
 

Modified: qpid/dispatch/trunk/src/server.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/server.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/server.c (original)
+++ qpid/dispatch/trunk/src/server.c Fri Mar  6 22:40:22 2015
@@ -27,7 +27,7 @@
 #include "dispatch_private.h"
 #include "server_private.h"
 #include "timer_private.h"
-#include "alloc_private.h"
+#include "alloc.h"
 #include <stdio.h>
 #include <time.h>
 #include <string.h>
@@ -868,11 +868,9 @@ qd_server_t *qd_server(qd_dispatch_t *qd
 void qd_server_free(qd_server_t *qd_server)
 {
     if (!qd_server) return;
-    int i;
-
-    for (i = 0; i < qd_server->thread_count; i++)
+    for (int i = 0; i < qd_server->thread_count; i++)
         thread_free(qd_server->threads[i]);
-
+    qd_timer_finalize();
     qdpn_driver_free(qd_server->driver);
     sys_mutex_free(qd_server->lock);
     sys_cond_free(qd_server->cond);

Modified: qpid/dispatch/trunk/src/server_private.h
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/server_private.h?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/server_private.h (original)
+++ qpid/dispatch/trunk/src/server_private.h Fri Mar  6 22:40:22 2015
@@ -22,7 +22,7 @@
 #include <qpid/dispatch/enum.h>
 #include <qpid/dispatch/server.h>
 #include <qpid/dispatch/user_fd.h>
-#include <qpid/dispatch/alloc.h>
+#include "alloc.h"
 #include <qpid/dispatch/ctools.h>
 #include <qpid/dispatch/log.h>
 #include <qpid/dispatch/driver.h>

Modified: qpid/dispatch/trunk/src/timer.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/timer.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/timer.c (original)
+++ qpid/dispatch/trunk/src/timer.c Fri Mar  6 22:40:22 2015
@@ -22,7 +22,7 @@
 #include "server_private.h"
 #include <qpid/dispatch/ctools.h>
 #include <qpid/dispatch/threading.h>
-#include <qpid/dispatch/alloc.h>
+#include "alloc.h"
 #include <assert.h>
 #include <stdio.h>
 
@@ -34,6 +34,9 @@ static long             time_base;
 ALLOC_DECLARE(qd_timer_t);
 ALLOC_DEFINE(qd_timer_t);
 
+/// For tests only
+sys_mutex_t* qd_timer_lock() { return lock; }
+
 //=========================================================================
 // Private static functions
 //=========================================================================

Modified: qpid/dispatch/trunk/src/timer_private.h
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/src/timer_private.h?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/src/timer_private.h (original)
+++ qpid/dispatch/trunk/src/timer_private.h Fri Mar  6 22:40:22 2015
@@ -48,5 +48,7 @@ long qd_timer_next_duration_LH(void);
 void qd_timer_visit_LH(long current_time);
 void qd_timer_idle_LH(qd_timer_t *timer);
 
+/// For tests only
+sys_mutex_t* qd_timer_lock();
 
 #endif

Modified: qpid/dispatch/trunk/tests/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/CMakeLists.txt?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/CMakeLists.txt (original)
+++ qpid/dispatch/trunk/tests/CMakeLists.txt Fri Mar  6 22:40:22 2015
@@ -21,9 +21,7 @@
 find_program(VALGRIND_EXECUTABLE valgrind DOC "Location of the valgrind program")
 mark_as_advanced(VALGRIND_EXECUTABLE)
 find_package_handle_standard_args(VALGRIND DEFAULT_MSG VALGRIND_EXECUTABLE)
-if (VALGRIND_FOUND)
-  option(USE_VALGRIND "Use valgrind when running tests" OFF)
-endif(VALGRIND_FOUND)
+option(USE_VALGRIND "Use valgrind when running tests" OFF)
 
 include_directories(
   ${CMAKE_SOURCE_DIR}/src
@@ -34,7 +32,6 @@ include_directories(
 ## Build test applications
 ##
 set(unit_test_SOURCES
-    alloc_test.c
     compose_test.c
     parse_test.c
     run_unit_tests.c
@@ -42,6 +39,9 @@ set(unit_test_SOURCES
     timer_test.c
     tool_test.c
     )
+if (USE_MEMORY_POOL)
+  list(APPEND unit_test_SOURCES alloc_test.c)
+endif()
 
 add_executable(unit_tests ${unit_test_SOURCES})
 target_link_libraries(unit_tests qpid-dispatch)

Modified: qpid/dispatch/trunk/tests/alloc_test.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/alloc_test.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/alloc_test.c (original)
+++ qpid/dispatch/trunk/tests/alloc_test.c Fri Mar  6 22:40:22 2015
@@ -18,9 +18,9 @@
  */
 
 #include "test_case.h"
+#include "alloc.h"
 #include <stdio.h>
 #include <string.h>
-#include "alloc_private.h"
 
 typedef struct {
     int A;
@@ -49,31 +49,29 @@ static char* test_alloc_basic(void *cont
     object_t         *obj[50];
     int               idx;
     qd_alloc_stats_t *stats;
-    char             *error;
+    char             *error = 0;
 
     for (idx = 0; idx < 20; idx++)
         obj[idx] = new_object_t();
-
     stats = alloc_stats_object_t();
     error = check_stats(stats, 21, 0, 21, 0, 0);
-    if (error) return error;
-
     for (idx = 0; idx < 20; idx++)
         free_object_t(obj[idx]);
+    if (error) return error;
 
     error = check_stats(stats, 21, 5, 6, 0, 5);
     if (error) return error;
 
     for (idx = 0; idx < 20; idx++)
         obj[idx] = new_object_t();
-
     error = check_stats(stats, 27, 5, 21, 3, 5);
+    for (idx = 0; idx < 20; idx++)
+        free_object_t(obj[idx]);
     if (error) return error;
 
     return 0;
 }
 
-
 int alloc_tests(void)
 {
     int result = 0;

Modified: qpid/dispatch/trunk/tests/field_test.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/field_test.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/field_test.c (original)
+++ qpid/dispatch/trunk/tests/field_test.c Fri Mar  6 22:40:22 2015
@@ -47,6 +47,8 @@ static char* test_view_global_dns(void *
     if (!qd_field_iterator_equal(iter, (unsigned char*) "M0global/sub"))
         return "ITER_VIEW_ADDRESS_HASH failed";
 
+    qd_field_iterator_free(iter);
+
     return 0;
 }
 
@@ -73,6 +75,8 @@ static char* test_view_global_non_dns(vo
     if (!qd_field_iterator_equal(iter, (unsigned char*) "M0global/sub"))
         return "ITER_VIEW_ADDRESS_HASH failed";
 
+    qd_field_iterator_free(iter);
+
     return 0;
 }
 
@@ -99,6 +103,8 @@ static char* test_view_global_no_host(vo
     if (!qd_field_iterator_equal(iter, (unsigned char*) "M0global/sub"))
         return "ITER_VIEW_ADDRESS_HASH failed";
 
+    qd_field_iterator_free(iter);
+
     return 0;
 }
 
@@ -133,6 +139,7 @@ static char* test_view_address_hash(void
                      cases[idx].addr, cases[idx].view, got);
             return fail_text;
         }
+        qd_field_iterator_free(iter);
     }
 
     return 0;
@@ -158,6 +165,7 @@ static char* test_view_address_hash_over
                      cases[idx].addr, cases[idx].view, got);
             return fail_text;
         }
+        qd_field_iterator_free(iter);
     }
 
     return 0;
@@ -181,7 +189,9 @@ static char* test_view_node_hash(void *c
             snprintf(fail_text, FAIL_TEXT_SIZE, "Addr '%s' failed.  Expected '%s', got '%s'",
                      cases[idx].addr, cases[idx].view, got);
             return fail_text;
+            qd_field_iterator_free(iter);
         }
+        qd_field_iterator_free(iter);
     }
 
     return 0;

Modified: qpid/dispatch/trunk/tests/message_test.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/message_test.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/message_test.c (original)
+++ qpid/dispatch/trunk/tests/message_test.c Fri Mar  6 22:40:22 2015
@@ -106,6 +106,7 @@ static char* test_receive_from_messenger
 
     if (!qd_field_iterator_equal(iter, (unsigned char*) "test_addr_1"))
         return "Mismatched 'to' field contents";
+    qd_field_iterator_free(iter);
 
     ssize_t test_len = qd_message_field_length(msg, QD_FIELD_TO);
     if (test_len != 11) return "Incorrect field length";
@@ -142,6 +143,8 @@ static char* test_message_properties(voi
 
     size_t       size = 10000;
     int result = pn_message_encode(pn_msg, buffer, &size);
+    pn_message_free(pn_msg);
+
     if (result != 0) return "Error in pn_message_encode";
 
     qd_message_t         *msg     = qd_message();
@@ -154,20 +157,24 @@ static char* test_message_properties(voi
     if (qd_field_iterator_length(iter) != 13) return "Bad length for correlation-id";
     if (!qd_field_iterator_equal(iter, (const unsigned char *)"correlationId"))
         return "Invalid correlation-id";
+    qd_field_iterator_free(iter);
 
     iter = qd_message_field_iterator(msg, QD_FIELD_SUBJECT);
     if (!iter) return "Expected iterator for the 'subject' field";
     if (!qd_field_iterator_equal(iter, (const unsigned char *)subject))
         return "Bad value for subject";
+    qd_field_iterator_free(iter);
 
     iter = qd_message_field_iterator(msg, QD_FIELD_MESSAGE_ID);
     if (!iter) return "Expected iterator for the 'message-id' field";
     if (qd_field_iterator_length(iter) != 9) return "Bad length for message-id";
     if (!qd_field_iterator_equal(iter, (const unsigned char *)"messageId"))
         return "Invalid message-id";
+    qd_field_iterator_free(iter);
 
     iter = qd_message_field_iterator(msg, QD_FIELD_TO);
     if (iter) return "Expected no iterator for the 'to' field";
+    qd_field_iterator_free(iter);
 
     qd_message_free(msg);
 
@@ -182,6 +189,7 @@ static char* test_check_multiple(void *c
 
     size_t size = 10000;
     int result = pn_message_encode(pn_msg, buffer, &size);
+    pn_message_free(pn_msg);
     if (result != 0) return "Error in pn_message_encode";
 
     qd_message_t         *msg     = qd_message();

Modified: qpid/dispatch/trunk/tests/parse_test.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/parse_test.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/parse_test.c (original)
+++ qpid/dispatch/trunk/tests/parse_test.c Fri Mar  6 22:40:22 2015
@@ -146,6 +146,8 @@ static char *test_parser_errors(void *co
                     err_vectors[idx].expected_error, qd_parse_error(parsed));
             return error;
         }
+        qd_parse_free(parsed);
+        qd_field_iterator_free(field);
         idx++;
     }
 

Modified: qpid/dispatch/trunk/tests/run_unit_tests.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/run_unit_tests.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/run_unit_tests.c (original)
+++ qpid/dispatch/trunk/tests/run_unit_tests.c Fri Mar  6 22:40:22 2015
@@ -17,6 +17,8 @@
  * under the License.
  */
 
+#include "alloc.h"
+
 #include <qpid/dispatch.h>
 #include <qpid/dispatch/buffer.h>
 #include <stdio.h>
@@ -34,17 +36,24 @@ int main(int argc, char** argv)
         fprintf(stderr, "usage: %s <config-file>\n", argv[0]);
         exit(1);
     }
+    int result = 0;
 
+    // Call qd_dispatch() first initialize allocator used by other tests.
     qd_dispatch_t *qd = qd_dispatch(0);
     qd_dispatch_load_config(qd, argv[1]);
-
-    int result = 0;
-    result += tool_tests();
-    result += alloc_tests();
+    if (qd_error_code()) {
+        printf("Config failed: %s\n", qd_error_message());
+        return 1;
+    }
+    result += timer_tests();
     result += server_tests(qd);
+    result += tool_tests();
     result += parse_tests();
     result += compose_tests();
-    qd_dispatch_free(qd);
-    result += timer_tests();
+#if USE_MEMORY_POOL
+    result += alloc_tests();
+#endif
+    qd_dispatch_free(qd);       // dispatch_free last.
+
     return result;
 }

Modified: qpid/dispatch/trunk/tests/run_unit_tests_size.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/run_unit_tests_size.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/run_unit_tests_size.c (original)
+++ qpid/dispatch/trunk/tests/run_unit_tests_size.c Fri Mar  6 22:40:22 2015
@@ -18,7 +18,7 @@
  */
 
 #include <qpid/dispatch/buffer.h>
-#include "alloc_private.h"
+#include "alloc.h"
 
 int message_tests();
 int field_tests();
@@ -39,6 +39,8 @@ int main(int argc, char** argv)
     int result = 0;
     result += message_tests();
     result += field_tests();
+    qd_alloc_finalize();
+
     return result;
 }
 

Modified: qpid/dispatch/trunk/tests/server_test.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/server_test.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/server_test.c (original)
+++ qpid/dispatch/trunk/tests/server_test.c Fri Mar  6 22:40:22 2015
@@ -121,6 +121,9 @@ static char* test_user_fd(void *context)
     close(fd[0]);
     close(fd[1]);
 
+    qd_user_fd_free(ufd_read);
+    qd_user_fd_free(ufd_write);
+
     if (stored_error[0])            return stored_error;
     if (write_count - OCTET_COUNT > 2) sprintf(stored_error, "Excessively high Write Count:
%d", write_count);
     if (read_count != OCTET_COUNT)  sprintf(stored_error, "Incorrect Read Count: %d", read_count);;

Modified: qpid/dispatch/trunk/tests/system_test.py
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/system_test.py?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/system_test.py (original)
+++ qpid/dispatch/trunk/tests/system_test.py Fri Mar  6 22:40:22 2015
@@ -120,9 +120,9 @@ def retry_delay(deadline, delay, max_del
     return min(delay*2, max_delay)
 
 
-DEFAULT_TIMEOUT = float(os.environ.get("QPID_SYSTEM_TEST_TIMEOUT", 10))
+TIMEOUT = float(os.environ.get("QPID_SYSTEM_TEST_TIMEOUT", 10))
 
-def retry(function, timeout=DEFAULT_TIMEOUT, delay=.001, max_delay=1):
+def retry(function, timeout=TIMEOUT, delay=.001, max_delay=1):
     """Call function until it returns a true value or timeout expires.
     Double the delay for each retry up to max_delay.
     Returns what function returns or None if timeout expires.
@@ -137,7 +137,7 @@ def retry(function, timeout=DEFAULT_TIME
             if delay is None:
                 return None
 
-def retry_exception(function, timeout=DEFAULT_TIMEOUT, delay=.001, max_delay=1, exception_test=None):
+def retry_exception(function, timeout=TIMEOUT, delay=.001, max_delay=1, exception_test=None):
     """Call function until it returns without exception or timeout expires.
     Double the delay for each retry up to max_delay.
     Calls exception_test with any exception raised by function, exception_test
@@ -352,7 +352,7 @@ class Qdrouterd(Process):
     def management(self):
         """Return a management agent proxy for this router"""
         if not self._management:
-            self._management = Node.connect(self.addresses[0], timeout=DEFAULT_TIMEOUT)
+            self._management = Node.connect(self.addresses[0], timeout=TIMEOUT)
         return self._management
 
     def teardown(self):
@@ -481,7 +481,7 @@ class Qpidd(Process):
 class Messenger(proton.Messenger):
     """Convenience additions to proton.Messenger"""
 
-    def __init__(self, name=None, timeout=DEFAULT_TIMEOUT, blocking=True):
+    def __init__(self, name=None, timeout=TIMEOUT, blocking=True):
         super(Messenger, self).__init__(name)
         self.timeout = timeout
         self.blocking = blocking

Modified: qpid/dispatch/trunk/tests/system_tests_qdmanage.py
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/system_tests_qdmanage.py?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/system_tests_qdmanage.py (original)
+++ qpid/dispatch/trunk/tests/system_tests_qdmanage.py Fri Mar  6 22:40:22 2015
@@ -18,7 +18,7 @@
 #
 
 import re, json, unittest, os
-from system_test import TestCase, Process, Qdrouterd, main_module
+from system_test import TestCase, Process, Qdrouterd, main_module, TIMEOUT
 from subprocess import PIPE, STDOUT
 from qpid_dispatch_internal.compat import OrderedDict, dictify
 from qpid_dispatch_internal.management.qdrouter import QdSchema
@@ -53,7 +53,7 @@ class QdmanageTest(TestCase):
 
     def run_qdmanage(self, cmd, input=None, expect=Process.EXIT_OK, address=None):
         p = self.popen(
-            ['qdmanage'] + cmd.split(' ') + ['--bus', address or self.address(), '--indent=-1'],
+            ['qdmanage'] + cmd.split(' ') + ['--bus', address or self.address(), '--indent=-1',
'--timeout', str(TIMEOUT)],
             stdin=PIPE, stdout=PIPE, stderr=STDOUT, expect=expect)
         out = p.communicate(input)[0]
         try:

Modified: qpid/dispatch/trunk/tests/system_tests_qdstat.py
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/system_tests_qdstat.py?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/system_tests_qdstat.py (original)
+++ qpid/dispatch/trunk/tests/system_tests_qdstat.py Fri Mar  6 22:40:22 2015
@@ -64,8 +64,9 @@ class QdstatTest(system_test.TestCase):
         cls.router = cls.tester.qdrouterd('test-router', config)
 
     def run_qdstat(self, args, regexp=None, address=None):
-        p = self.popen(['qdstat', '--bus', str(address or self.router.addresses[0])] + args,
-                       name='qdstat-'+self.id(), stdout=PIPE, expect=None)
+        p = self.popen(
+            ['qdstat', '--bus', str(address or self.router.addresses[0]), '--timeout', str(system_test.TIMEOUT)
] + args,
+            name='qdstat-'+self.id(), stdout=PIPE, expect=None)
         out = p.communicate()[0]
         assert p.returncode == 0, \
             "qdstat exit status %s, output:\n%s" % (p.returncode, out)

Modified: qpid/dispatch/trunk/tests/timer_test.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/timer_test.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/timer_test.c (original)
+++ qpid/dispatch/trunk/tests/timer_test.c Fri Mar  6 22:40:22 2015
@@ -20,7 +20,7 @@
 #include <stdio.h>
 #include <qpid/dispatch/timer.h>
 #include "dispatch_private.h"
-#include "alloc_private.h"
+#include "alloc.h"
 #include "timer_private.h"
 #include "test_case.h"
 #include <qpid/dispatch/threading.h>
@@ -367,12 +367,10 @@ static char* test_big(void *context)
 int timer_tests(void)
 {
     int result = 0;
-    qd_alloc_initialize();
 
     fire_mask = 0;
     DEQ_INIT(pending_timers);
-    lock = sys_mutex();
-    qd_timer_initialize(lock);
+    lock = qd_timer_lock();
     time = 1;
 
     timers[0]  = qd_timer(0, 0, (void*) 0x00000001);
@@ -407,9 +405,6 @@ int timer_tests(void)
     for (i = 0; i < 16; i++)
         qd_timer_free(timers[i]);
 
-    qd_timer_finalize();
-    sys_mutex_free(lock);
-
     return result;
 }
 

Modified: qpid/dispatch/trunk/tests/tool_test.c
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/tests/tool_test.c?rev=1664744&r1=1664743&r2=1664744&view=diff
==============================================================================
--- qpid/dispatch/trunk/tests/tool_test.c (original)
+++ qpid/dispatch/trunk/tests/tool_test.c Fri Mar  6 22:40:22 2015
@@ -22,7 +22,7 @@
 #include <string.h>
 #include <qpid/dispatch/ctools.h>
 #include <qpid/dispatch/bitmask.h>
-#include "alloc_private.h"
+#include "alloc.h"
 
 typedef struct item_t {
     DEQ_LINKS(struct item_t);
@@ -222,7 +222,6 @@ static char* test_bitmask(void *context)
 int tool_tests(void)
 {
     int result = 0;
-    qd_alloc_initialize();
 
     TEST_CASE(test_deq_basic, 0);
     TEST_CASE(test_deq_basic2, 0);



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message