From: Robert Haas Date: Thu, 16 Jan 2014 19:56:56 +0000 (-0500) Subject: Hack. X-Git-Url: http://git.postgresql.org/gitweb/?a=commitdiff_plain;h=4d1211c9861ba062e76355aa4ce946692faf6786;p=users%2Frhaas%2Fpostgres.git Hack. --- diff --git a/src/backend/utils/mmgr/mspan.c b/src/backend/utils/mmgr/mspan.c index 2c9c3c8ada..f3bd1df3fc 100644 --- a/src/backend/utils/mmgr/mspan.c +++ b/src/backend/utils/mmgr/mspan.c @@ -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; } /*