Hack.
authorRobert Haas <rhaas@postgresql.org>
Thu, 16 Jan 2014 19:56:56 +0000 (14:56 -0500)
committerRobert Haas <rhaas@postgresql.org>
Thu, 6 Feb 2014 14:23:00 +0000 (09:23 -0500)
src/backend/utils/mmgr/mspan.c

index 2c9c3c8ada18788c5c1691f0a21020cc41efc48d..f3bd1df3fc3bf9e09e68e1d42e76ac1d6e4e2e8c 100644 (file)
@@ -140,10 +140,12 @@ struct mspan_context
 };
 
 /* Helper functions. */
-static char *mspan_allocate_from_superblock(char *base, mspan *superblock);
-static mspan *mspan_allocate_span_descriptor(char *base, mspan_manager *mgr);
 static mspan_context *mspan_allocate_context_descriptor(char *base,
                                                                  mspan_manager *mgr);
+static char *mspan_allocate_from_superblock(char *base, mspan *superblock);
+static mspan *mspan_allocate_span_descriptor(char *base, mspan_manager *mgr);
+static mspan *mspan_allocate_span(char *base, mspan_manager *mgr,
+                                       mspan_context *cxt, uint16 span_type, Size pages);
 static void mspan_destroy_span(char *base, mspan *span);
 static void mspan_ensure_active_superblock(char *base, mspan_context *cxt,
                                                           uint16 size_class);
@@ -292,27 +294,17 @@ mspan_alloc(dsm_segment *seg, mspan_context *cxt, Size size, int flags)
                Size    pages = (size + MSPAN_PAGE_SIZE - 1) >> MSPAN_PAGE_BITS;
                mspan  *span;
 
-               span = mspan_find_free_span(base, mgr, pages, 0);
-               if (span != NULL)
-               {
-                       /* XXX. Allocate the span, splitting it if required. */
-                       /*
-                        * XXX. Note that if we split a span than abutts the boundary,
-                        * we should instead destroy it and move back the boundary.
-                        */
-               }
-               else
+               span = mspan_allocate_span(base, mgr, cxt, MSPAN_TYPE_LARGE, pages);
+               if (span == NULL)
                {
-                       /*
-                        * XXX. We need more core.  Allocate either from the boundary or
-                        * via malloc.
-                        */
-                       /*
-                        * XXX. How exactly are we going to give the segments we malloc
-                        * back to the OS?  How are we even going to know where they are?
-                        * We can add them to the freelists as a big old span, but that's
-                        * not going to help much in terms of identifying them later.
-                        */
+                       if (base == NULL)
+                               ereport(ERROR,
+                                               (errcode(ERRCODE_OUT_OF_MEMORY),
+                                                errmsg("out of memory")));
+                       else
+                               ereport(ERROR,
+                                               (errcode(ERRCODE_OUT_OF_MEMORY),
+                                                errmsg("out of shared memory")));
                }
        }
 
@@ -615,10 +607,25 @@ mspan_allocate_span(char *base, mspan_manager *mgr, mspan_context *cxt,
                if (span->npages > pages)
                {
                        /* XXX. Split the span. */
+                       /*
+                        * XXX. Note that if we split a span than abutts the boundary,
+                        * we should instead destroy it and move back the boundary.
+                        */
                }
        }
 
-       /* XXX. Allocate storage for a new span. */
+       /*
+        * XXX. We need more core.  Allocate either from the boundary or
+        * via malloc.
+        */
+       /*
+        * XXX. How exactly are we going to give the segments we malloc
+        * back to the OS?  How are we even going to know where they are?
+        * We can add them to the freelists as a big old span, but that's
+        * not going to help much in terms of identifying them later.
+        */
+
+       return NULL;
 }
 
 /*