summaryrefslogtreecommitdiffstats
path: root/rubbos/app/httpd-2.0.64/srclib/apr/shmem
diff options
context:
space:
mode:
Diffstat (limited to 'rubbos/app/httpd-2.0.64/srclib/apr/shmem')
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/shmem/beos/Makefile.in14
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/shmem/beos/shm.c147
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/shmem/os2/Makefile.in14
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/shmem/os2/shm.c138
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/.libs/shm.obin0 -> 20952 bytes
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/Makefile14
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/Makefile.in14
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/shm.c568
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/shm.lo12
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/shm.obin0 -> 20936 bytes
-rw-r--r--rubbos/app/httpd-2.0.64/srclib/apr/shmem/win32/shm.c294
11 files changed, 1215 insertions, 0 deletions
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/shmem/beos/Makefile.in b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/beos/Makefile.in
new file mode 100644
index 00000000..52447d8b
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/beos/Makefile.in
@@ -0,0 +1,14 @@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+TARGETS = shm.lo
+
+# bring in rules.mk for standard functionality
+@INCLUDE_RULES@
+
+INCDIR=../../include
+OSDIR=$(INCDIR)/arch/@OSDIR@
+DEFOSDIR=$(INCDIR)/arch/@DEFAULT_OSDIR@
+INCLUDES=-I$(INCDIR) -I$(OSDIR) -I$(DEFOSDIR)
+
+# DO NOT REMOVE
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/shmem/beos/shm.c b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/beos/shm.c
new file mode 100644
index 00000000..f4b5ab83
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/beos/shm.c
@@ -0,0 +1,147 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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 KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr_general.h"
+#include "apr_shm.h"
+#include "apr_errno.h"
+#include "apr_lib.h"
+#include "apr_strings.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <kernel/OS.h>
+#include "apr_portable.h"
+
+struct apr_shm_t {
+ apr_pool_t *pool;
+ void *memblock;
+ void *ptr;
+ apr_size_t reqsize;
+ apr_size_t avail;
+ area_id aid;
+};
+
+APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
+ apr_size_t reqsize,
+ const char *file,
+ apr_pool_t *p)
+{
+ apr_size_t pagesize;
+ area_id newid;
+ char *addr;
+
+ (*m) = (apr_shm_t *)apr_pcalloc(p, sizeof(apr_shm_t));
+ /* we MUST allocate in pages, so calculate how big an area we need... */
+ pagesize = ((reqsize + B_PAGE_SIZE - 1) / B_PAGE_SIZE) * B_PAGE_SIZE;
+
+ newid = create_area("apr_shmem", (void*)&addr, B_ANY_ADDRESS,
+ pagesize, B_CONTIGUOUS, B_READ_AREA|B_WRITE_AREA);
+
+ if (newid < 0)
+ return errno;
+
+ (*m)->pool = p;
+ (*m)->aid = newid;
+ (*m)->memblock = addr;
+ (*m)->ptr = (void*)addr;
+ (*m)->avail = pagesize; /* record how big an area we actually created... */
+ (*m)->reqsize = reqsize;
+
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m)
+{
+ delete_area(m->aid);
+ m->avail = 0;
+ m->memblock = NULL;
+ return APR_SUCCESS;
+}
+
+
+APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m,
+ const char *filename,
+ apr_pool_t *pool)
+{
+ area_info ai;
+ thread_info ti;
+ area_id deleteme;
+ apr_shm_t *new_m;
+
+ deleteme = find_area(filename);
+ if (deleteme == B_NAME_NOT_FOUND)
+ return APR_EINVAL;
+
+ new_m = (apr_shm_t*)apr_palloc(pool, sizeof(apr_shm_t*));
+ if (new_m == NULL)
+ return APR_ENOMEM;
+ new_m->pool = pool;
+
+ get_area_info(deleteme, &ai);
+ get_thread_info(find_thread(NULL), &ti);
+
+ if (ti.team != ai.team) {
+ area_id narea;
+
+ narea = clone_area(ai.name, &(ai.address), B_CLONE_ADDRESS,
+ B_READ_AREA|B_WRITE_AREA, ai.area);
+
+ if (narea < B_OK)
+ return narea;
+
+ get_area_info(narea, &ai);
+ new_m->aid = narea;
+ new_m->memblock = ai.address;
+ new_m->ptr = (void*)ai.address;
+ new_m->avail = ai.size;
+ new_m->reqsize = ai.size;
+ }
+
+ (*m) = new_m;
+
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_shm_detach(apr_shm_t *m)
+{
+ delete_area(m->aid);
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(void *) apr_shm_baseaddr_get(const apr_shm_t *m)
+{
+ return m->memblock;
+}
+
+APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m)
+{
+ return m->reqsize;
+}
+
+APR_POOL_IMPLEMENT_ACCESSOR(shm)
+
+APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm,
+ apr_shm_t *shm)
+{
+ return APR_ENOTIMPL;
+}
+
+APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **m,
+ apr_os_shm_t *osshm,
+ apr_pool_t *pool)
+{
+ return APR_ENOTIMPL;
+}
+
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/shmem/os2/Makefile.in b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/os2/Makefile.in
new file mode 100644
index 00000000..52447d8b
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/os2/Makefile.in
@@ -0,0 +1,14 @@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+TARGETS = shm.lo
+
+# bring in rules.mk for standard functionality
+@INCLUDE_RULES@
+
+INCDIR=../../include
+OSDIR=$(INCDIR)/arch/@OSDIR@
+DEFOSDIR=$(INCDIR)/arch/@DEFAULT_OSDIR@
+INCLUDES=-I$(INCDIR) -I$(OSDIR) -I$(DEFOSDIR)
+
+# DO NOT REMOVE
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/shmem/os2/shm.c b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/os2/shm.c
new file mode 100644
index 00000000..8f41d821
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/os2/shm.c
@@ -0,0 +1,138 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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 KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr_general.h"
+#include "apr_shm.h"
+#include "apr_errno.h"
+#include "apr_lib.h"
+#include "apr_strings.h"
+#include "apr_portable.h"
+
+struct apr_shm_t {
+ apr_pool_t *pool;
+ void *memblock;
+};
+
+APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
+ apr_size_t reqsize,
+ const char *filename,
+ apr_pool_t *pool)
+{
+ int rc;
+ apr_shm_t *newm = (apr_shm_t *)apr_palloc(pool, sizeof(apr_shm_t));
+ char *name = NULL;
+ ULONG flags = PAG_COMMIT|PAG_READ|PAG_WRITE;
+
+ newm->pool = pool;
+
+ if (filename) {
+ name = apr_pstrcat(pool, "\\SHAREMEM\\", filename, NULL);
+ }
+
+ if (name == NULL) {
+ flags |= OBJ_GETTABLE;
+ }
+
+ rc = DosAllocSharedMem(&(newm->memblock), name, reqsize, flags);
+
+ if (rc) {
+ return APR_OS2_STATUS(rc);
+ }
+
+ *m = newm;
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m)
+{
+ DosFreeMem(m->memblock);
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m,
+ const char *filename,
+ apr_pool_t *pool)
+{
+ int rc;
+ apr_shm_t *newm = (apr_shm_t *)apr_palloc(pool, sizeof(apr_shm_t));
+ char *name = NULL;
+ ULONG flags = PAG_READ|PAG_WRITE;
+
+ newm->pool = pool;
+ name = apr_pstrcat(pool, "\\SHAREMEM\\", filename, NULL);
+
+ rc = DosGetNamedSharedMem(&(newm->memblock), name, flags);
+
+ if (rc) {
+ return APR_FROM_OS_ERROR(rc);
+ }
+
+ *m = newm;
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_shm_detach(apr_shm_t *m)
+{
+ int rc = 0;
+
+ if (m->memblock) {
+ rc = DosFreeMem(m->memblock);
+ }
+
+ return APR_FROM_OS_ERROR(rc);
+}
+
+APR_DECLARE(void *) apr_shm_baseaddr_get(const apr_shm_t *m)
+{
+ return m->memblock;
+}
+
+APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m)
+{
+ ULONG flags, size = 0x1000000;
+ DosQueryMem(m->memblock, &size, &flags);
+ return size;
+}
+
+APR_POOL_IMPLEMENT_ACCESSOR(shm)
+
+APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm,
+ apr_shm_t *shm)
+{
+ *osshm = shm->memblock;
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **m,
+ apr_os_shm_t *osshm,
+ apr_pool_t *pool)
+{
+ int rc;
+ apr_shm_t *newm = (apr_shm_t *)apr_palloc(pool, sizeof(apr_shm_t));
+ ULONG flags = PAG_COMMIT|PAG_READ|PAG_WRITE;
+
+ newm->pool = pool;
+
+ rc = DosGetSharedMem(&(newm->memblock), flags);
+
+ if (rc) {
+ return APR_FROM_OS_ERROR(rc);
+ }
+
+ *m = newm;
+ return APR_SUCCESS;
+}
+
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/.libs/shm.o b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/.libs/shm.o
new file mode 100644
index 00000000..354fe508
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/.libs/shm.o
Binary files differ
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/Makefile b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/Makefile
new file mode 100644
index 00000000..3acd6980
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/Makefile
@@ -0,0 +1,14 @@
+srcdir = .
+
+
+TARGETS = shm.lo
+
+# bring in rules.mk for standard functionality
+include /bottlenecks/rubbos/app/httpd-2.0.64/srclib/apr/build/apr_rules.mk
+
+INCDIR=../../include
+INCDIR2=$(INCDIR)/arch
+INCDIR3=$(INCDIR)/arch/unix
+INCLUDES=-I$(INCDIR) -I$(INCDIR2) -I$(INCDIR3)
+
+# DO NOT REMOVE
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/Makefile.in b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/Makefile.in
new file mode 100644
index 00000000..b155d75b
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/Makefile.in
@@ -0,0 +1,14 @@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+TARGETS = shm.lo
+
+# bring in rules.mk for standard functionality
+@INCLUDE_RULES@
+
+INCDIR=../../include
+INCDIR2=$(INCDIR)/arch
+INCDIR3=$(INCDIR)/arch/unix
+INCLUDES=-I$(INCDIR) -I$(INCDIR2) -I$(INCDIR3)
+
+# DO NOT REMOVE
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/shm.c b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/shm.c
new file mode 100644
index 00000000..9af33fa4
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/shm.c
@@ -0,0 +1,568 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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 KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr_arch_shm.h"
+
+#include "apr_general.h"
+#include "apr_errno.h"
+#include "apr_user.h"
+#include "apr_strings.h"
+
+static apr_status_t shm_cleanup_owner(void *m_)
+{
+ apr_shm_t *m = (apr_shm_t *)m_;
+
+ /* anonymous shared memory */
+ if (m->filename == NULL) {
+#if APR_USE_SHMEM_MMAP_ZERO || APR_USE_SHMEM_MMAP_ANON
+ if (munmap(m->base, m->realsize) == -1) {
+ return errno;
+ }
+ return APR_SUCCESS;
+#endif
+#if APR_USE_SHMEM_SHMGET_ANON
+ if (shmdt(m->base) == -1) {
+ return errno;
+ }
+ /* This segment will automatically remove itself after all
+ * references have detached. */
+ return APR_SUCCESS;
+#endif
+ }
+
+ /* name-based shared memory */
+ else {
+#if APR_USE_SHMEM_MMAP_TMP
+ apr_status_t rv;
+
+ if (munmap(m->base, m->realsize) == -1) {
+ return errno;
+ }
+ rv = apr_file_remove(m->filename, m->pool);
+ if (rv != APR_SUCCESS) {
+ return rv;
+ }
+ return APR_SUCCESS;
+#endif
+#if APR_USE_SHMEM_MMAP_SHM
+ if (munmap(m->base, m->realsize) == -1) {
+ return errno;
+ }
+ if (shm_unlink(m->filename) == -1) {
+ return errno;
+ }
+ return APR_SUCCESS;
+#endif
+#if APR_USE_SHMEM_SHMGET
+ apr_status_t rv;
+
+ /* Indicate that the segment is to be destroyed as soon
+ * as all processes have detached. This also disallows any
+ * new attachments to the segment. */
+ if (shmctl(m->shmid, IPC_RMID, NULL) == -1) {
+ return errno;
+ }
+ if (shmdt(m->base) == -1) {
+ return errno;
+ }
+ rv = apr_file_remove(m->filename, m->pool);
+ if (rv != APR_SUCCESS) {
+ return rv;
+ }
+ return APR_SUCCESS;
+#endif
+ }
+
+ return APR_ENOTIMPL;
+}
+
+APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
+ apr_size_t reqsize,
+ const char *filename,
+ apr_pool_t *pool)
+{
+ apr_shm_t *new_m;
+ apr_status_t status;
+#if APR_USE_SHMEM_SHMGET || APR_USE_SHMEM_SHMGET_ANON
+ struct shmid_ds shmbuf;
+ apr_uid_t uid;
+ apr_gid_t gid;
+#endif
+#if APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM || \
+ APR_USE_SHMEM_MMAP_ZERO
+ int tmpfd;
+#endif
+#if APR_USE_SHMEM_SHMGET
+ apr_size_t nbytes;
+ key_t shmkey;
+#endif
+#if APR_USE_SHMEM_MMAP_ZERO || APR_USE_SHMEM_SHMGET || \
+ APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM
+ apr_file_t *file; /* file where metadata is stored */
+#endif
+
+ /* Check if they want anonymous or name-based shared memory */
+ if (filename == NULL) {
+#if APR_USE_SHMEM_MMAP_ZERO || APR_USE_SHMEM_MMAP_ANON
+ new_m = apr_palloc(pool, sizeof(apr_shm_t));
+ if (!new_m) {
+ return APR_ENOMEM;
+ }
+ new_m->pool = pool;
+ new_m->reqsize = reqsize;
+ new_m->realsize = reqsize +
+ APR_ALIGN_DEFAULT(sizeof(apr_size_t)); /* room for metadata */
+ new_m->filename = NULL;
+
+#if APR_USE_SHMEM_MMAP_ZERO
+ status = apr_file_open(&file, "/dev/zero", APR_READ | APR_WRITE,
+ APR_OS_DEFAULT, pool);
+ if (status != APR_SUCCESS) {
+ return status;
+ }
+ status = apr_os_file_get(&tmpfd, file);
+ if (status != APR_SUCCESS) {
+ return status;
+ }
+
+ new_m->base = mmap(NULL, new_m->realsize, PROT_READ|PROT_WRITE,
+ MAP_SHARED, tmpfd, 0);
+ if (new_m->base == (void *)MAP_FAILED) {
+ return errno;
+ }
+
+ status = apr_file_close(file);
+ if (status != APR_SUCCESS) {
+ return status;
+ }
+
+ /* store the real size in the metadata */
+ *(apr_size_t*)(new_m->base) = new_m->realsize;
+ /* metadata isn't usable */
+ new_m->usable = (char *)new_m->base + APR_ALIGN_DEFAULT(sizeof(apr_size_t));
+
+ apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner,
+ apr_pool_cleanup_null);
+ *m = new_m;
+ return APR_SUCCESS;
+
+#elif APR_USE_SHMEM_MMAP_ANON
+ new_m->base = mmap(NULL, new_m->realsize, PROT_READ|PROT_WRITE,
+ MAP_ANON|MAP_SHARED, -1, 0);
+ if (new_m->base == (void *)MAP_FAILED) {
+ return errno;
+ }
+
+ /* store the real size in the metadata */
+ *(apr_size_t*)(new_m->base) = new_m->realsize;
+ /* metadata isn't usable */
+ new_m->usable = (char *)new_m->base + APR_ALIGN_DEFAULT(sizeof(apr_size_t));
+
+ apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner,
+ apr_pool_cleanup_null);
+ *m = new_m;
+ return APR_SUCCESS;
+
+#endif /* APR_USE_SHMEM_MMAP_ZERO */
+#endif /* APR_USE_SHMEM_MMAP_ZERO || APR_USE_SHMEM_MMAP_ANON */
+#if APR_USE_SHMEM_SHMGET_ANON
+
+ new_m = apr_palloc(pool, sizeof(apr_shm_t));
+ if (!new_m) {
+ return APR_ENOMEM;
+ }
+ new_m->pool = pool;
+ new_m->reqsize = reqsize;
+ new_m->realsize = reqsize;
+ new_m->filename = NULL;
+
+ if ((new_m->shmid = shmget(IPC_PRIVATE, new_m->realsize,
+ SHM_R | SHM_W | IPC_CREAT)) < 0) {
+ return errno;
+ }
+
+ if ((new_m->base = shmat(new_m->shmid, NULL, 0)) == (void *)-1) {
+ return errno;
+ }
+ new_m->usable = new_m->base;
+
+ if (shmctl(new_m->shmid, IPC_STAT, &shmbuf) == -1) {
+ return errno;
+ }
+ apr_uid_current(&uid, &gid, pool);
+ shmbuf.shm_perm.uid = uid;
+ shmbuf.shm_perm.gid = gid;
+ if (shmctl(new_m->shmid, IPC_SET, &shmbuf) == -1) {
+ return errno;
+ }
+
+ /* Remove the segment once use count hits zero.
+ * We will not attach to this segment again, since it is
+ * anonymous memory, so it is ok to mark it for deletion.
+ */
+ if (shmctl(new_m->shmid, IPC_RMID, NULL) == -1) {
+ return errno;
+ }
+
+ apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner,
+ apr_pool_cleanup_null);
+ *m = new_m;
+ return APR_SUCCESS;
+#endif /* APR_USE_SHMEM_SHMGET_ANON */
+ /* It is an error if they want anonymous memory but we don't have it. */
+ return APR_ENOTIMPL; /* requested anonymous but we don't have it */
+ }
+
+ /* Name-based shared memory */
+ else {
+ new_m = apr_palloc(pool, sizeof(apr_shm_t));
+ if (!new_m) {
+ return APR_ENOMEM;
+ }
+ new_m->pool = pool;
+ new_m->reqsize = reqsize;
+ new_m->filename = apr_pstrdup(pool, filename);
+
+#if APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM
+ new_m->realsize = reqsize +
+ APR_ALIGN_DEFAULT(sizeof(apr_size_t)); /* room for metadata */
+ /* FIXME: Ignore error for now. *
+ * status = apr_file_remove(file, pool);*/
+ status = APR_SUCCESS;
+
+#if APR_USE_SHMEM_MMAP_TMP
+ /* FIXME: Is APR_OS_DEFAULT sufficient? */
+ status = apr_file_open(&file, filename,
+ APR_READ | APR_WRITE | APR_CREATE | APR_EXCL,
+ APR_OS_DEFAULT, pool);
+ if (status != APR_SUCCESS) {
+ return status;
+ }
+
+ status = apr_os_file_get(&tmpfd, file);
+ if (status != APR_SUCCESS) {
+ apr_file_close(file); /* ignore errors, we're failing */
+ apr_file_remove(new_m->filename, new_m->pool);
+ return status;
+ }
+
+ status = apr_file_trunc(file, new_m->realsize);
+ if (status != APR_SUCCESS) {
+ apr_file_close(file); /* ignore errors, we're failing */
+ apr_file_remove(new_m->filename, new_m->pool);
+ return status;
+ }
+
+ new_m->base = mmap(NULL, new_m->realsize, PROT_READ | PROT_WRITE,
+ MAP_SHARED, tmpfd, 0);
+ /* FIXME: check for errors */
+
+ status = apr_file_close(file);
+ if (status != APR_SUCCESS) {
+ return status;
+ }
+#endif /* APR_USE_SHMEM_MMAP_TMP */
+#if APR_USE_SHMEM_MMAP_SHM
+ /* FIXME: Is APR_OS_DEFAULT sufficient? */
+ tmpfd = shm_open(filename, O_RDWR | O_CREAT | O_EXCL, APR_OS_DEFAULT);
+ if (tmpfd == -1) {
+ return errno;
+ }
+
+ status = apr_os_file_put(&file, &tmpfd,
+ APR_READ | APR_WRITE | APR_CREATE | APR_EXCL,
+ pool);
+ if (status != APR_SUCCESS) {
+ return status;
+ }
+
+ status = apr_file_trunc(file, new_m->realsize);
+ if (status != APR_SUCCESS) {
+ shm_unlink(filename); /* we're failing, remove the object */
+ return status;
+ }
+ new_m->base = mmap(NULL, reqsize, PROT_READ | PROT_WRITE,
+ MAP_SHARED, tmpfd, 0);
+
+ /* FIXME: check for errors */
+
+ /* FIXME: Is it ok to close this file when using shm_open?? */
+ status = apr_file_close(file);
+ if (status != APR_SUCCESS) {
+ return status;
+ }
+#endif /* APR_USE_SHMEM_MMAP_SHM */
+
+ /* store the real size in the metadata */
+ *(apr_size_t*)(new_m->base) = new_m->realsize;
+ /* metadata isn't usable */
+ new_m->usable = (char *)new_m->base + APR_ALIGN_DEFAULT(sizeof(apr_size_t));
+
+ apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner,
+ apr_pool_cleanup_null);
+ *m = new_m;
+ return APR_SUCCESS;
+
+#endif /* APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM */
+
+#if APR_USE_SHMEM_SHMGET
+ new_m->realsize = reqsize;
+
+ /* FIXME: APR_OS_DEFAULT is too permissive, switch to 600 I think. */
+ status = apr_file_open(&file, filename,
+ APR_WRITE | APR_CREATE | APR_EXCL,
+ APR_OS_DEFAULT, pool);
+ if (status != APR_SUCCESS) {
+ return status;
+ }
+
+ /* ftok() (on solaris at least) requires that the file actually
+ * exist before calling ftok(). */
+ shmkey = ftok(filename, 1);
+ if (shmkey == (key_t)-1) {
+ return errno;
+ }
+
+ if ((new_m->shmid = shmget(shmkey, new_m->realsize,
+ SHM_R | SHM_W | IPC_CREAT | IPC_EXCL)) < 0) {
+ return errno;
+ }
+
+ if ((new_m->base = shmat(new_m->shmid, NULL, 0)) == (void *)-1) {
+ return errno;
+ }
+ new_m->usable = new_m->base;
+
+ if (shmctl(new_m->shmid, IPC_STAT, &shmbuf) == -1) {
+ return errno;
+ }
+ apr_uid_current(&uid, &gid, pool);
+ shmbuf.shm_perm.uid = uid;
+ shmbuf.shm_perm.gid = gid;
+ if (shmctl(new_m->shmid, IPC_SET, &shmbuf) == -1) {
+ return errno;
+ }
+
+ nbytes = sizeof(reqsize);
+ status = apr_file_write(file, (const void *)&reqsize,
+ &nbytes);
+ if (status != APR_SUCCESS) {
+ return status;
+ }
+ status = apr_file_close(file);
+ if (status != APR_SUCCESS) {
+ return status;
+ }
+
+ apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_owner,
+ apr_pool_cleanup_null);
+ *m = new_m;
+ return APR_SUCCESS;
+
+#endif /* APR_USE_SHMEM_SHMGET */
+ }
+
+ return APR_ENOTIMPL;
+}
+
+APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m)
+{
+ return apr_pool_cleanup_run(m->pool, m, shm_cleanup_owner);
+}
+
+static apr_status_t shm_cleanup_attach(void *m_)
+{
+ apr_shm_t *m = (apr_shm_t *)m_;
+
+ if (m->filename == NULL) {
+ /* It doesn't make sense to detach from an anonymous memory segment. */
+ return APR_EINVAL;
+ }
+ else {
+#if APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM
+ if (munmap(m->base, m->realsize) == -1) {
+ return errno;
+ }
+ return APR_SUCCESS;
+#endif /* APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM */
+#if APR_USE_SHMEM_SHMGET
+ if (shmdt(m->base) == -1) {
+ return errno;
+ }
+ return APR_SUCCESS;
+#endif
+ }
+
+ return APR_ENOTIMPL;
+}
+
+APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m,
+ const char *filename,
+ apr_pool_t *pool)
+{
+ if (filename == NULL) {
+ /* It doesn't make sense to attach to a segment if you don't know
+ * the filename. */
+ return APR_EINVAL;
+ }
+ else {
+#if APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM
+ apr_shm_t *new_m;
+ apr_status_t status;
+ int tmpfd;
+ apr_file_t *file; /* file where metadata is stored */
+ apr_size_t nbytes;
+
+ new_m = apr_palloc(pool, sizeof(apr_shm_t));
+ if (!new_m) {
+ return APR_ENOMEM;
+ }
+ new_m->pool = pool;
+ new_m->filename = apr_pstrdup(pool, filename);
+
+ status = apr_file_open(&file, filename,
+ APR_READ | APR_WRITE,
+ APR_OS_DEFAULT, pool);
+ if (status != APR_SUCCESS) {
+ return status;
+ }
+ status = apr_os_file_get(&tmpfd, file);
+ if (status != APR_SUCCESS) {
+ return status;
+ }
+
+ nbytes = sizeof(new_m->realsize);
+ status = apr_file_read(file, (void *)&(new_m->realsize),
+ &nbytes);
+ if (status != APR_SUCCESS) {
+ return status;
+ }
+
+ status = apr_os_file_get(&tmpfd, file);
+ if (status != APR_SUCCESS) {
+ apr_file_close(file); /* ignore errors, we're failing */
+ apr_file_remove(new_m->filename, new_m->pool);
+ return status;
+ }
+
+ new_m->reqsize = new_m->realsize - sizeof(apr_size_t);
+
+ new_m->base = mmap(NULL, new_m->realsize, PROT_READ | PROT_WRITE,
+ MAP_SHARED, tmpfd, 0);
+ /* FIXME: check for errors */
+
+ status = apr_file_close(file);
+ if (status != APR_SUCCESS) {
+ return status;
+ }
+
+ /* metadata isn't part of the usable segment */
+ new_m->usable = (char *)new_m->base + APR_ALIGN_DEFAULT(sizeof(apr_size_t));
+
+ apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_attach,
+ apr_pool_cleanup_null);
+ *m = new_m;
+ return APR_SUCCESS;
+
+#endif /* APR_USE_SHMEM_MMAP_TMP || APR_USE_SHMEM_MMAP_SHM */
+#if APR_USE_SHMEM_SHMGET
+ apr_shm_t *new_m;
+ apr_status_t status;
+ apr_file_t *file; /* file where metadata is stored */
+ apr_size_t nbytes;
+ key_t shmkey;
+
+ new_m = apr_palloc(pool, sizeof(apr_shm_t));
+ if (!new_m) {
+ return APR_ENOMEM;
+ }
+
+ /* FIXME: does APR_OS_DEFAULT matter for reading? */
+ status = apr_file_open(&file, filename,
+ APR_READ, APR_OS_DEFAULT, pool);
+ if (status != APR_SUCCESS) {
+ return status;
+ }
+
+ nbytes = sizeof(new_m->reqsize);
+ status = apr_file_read(file, (void *)&(new_m->reqsize),
+ &nbytes);
+ if (status != APR_SUCCESS) {
+ return status;
+ }
+ status = apr_file_close(file);
+ if (status != APR_SUCCESS) {
+ return status;
+ }
+
+ new_m->filename = apr_pstrdup(pool, filename);
+ new_m->pool = pool;
+ shmkey = ftok(filename, 1);
+ if (shmkey == (key_t)-1) {
+ return errno;
+ }
+ if ((new_m->shmid = shmget(shmkey, 0, SHM_R | SHM_W)) == -1) {
+ return errno;
+ }
+ if ((new_m->base = shmat(new_m->shmid, NULL, 0)) == (void *)-1) {
+ return errno;
+ }
+ new_m->usable = new_m->base;
+ new_m->realsize = new_m->reqsize;
+
+ apr_pool_cleanup_register(new_m->pool, new_m, shm_cleanup_attach,
+ apr_pool_cleanup_null);
+ *m = new_m;
+ return APR_SUCCESS;
+
+#endif /* APR_USE_SHMEM_SHMGET */
+ }
+
+ return APR_ENOTIMPL;
+}
+
+APR_DECLARE(apr_status_t) apr_shm_detach(apr_shm_t *m)
+{
+ apr_status_t rv = shm_cleanup_attach(m);
+ apr_pool_cleanup_kill(m->pool, m, shm_cleanup_attach);
+ return rv;
+}
+
+APR_DECLARE(void *) apr_shm_baseaddr_get(const apr_shm_t *m)
+{
+ return m->usable;
+}
+
+APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m)
+{
+ return m->reqsize;
+}
+
+APR_POOL_IMPLEMENT_ACCESSOR(shm)
+
+APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm,
+ apr_shm_t *shm)
+{
+ return APR_ENOTIMPL;
+}
+
+APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **m,
+ apr_os_shm_t *osshm,
+ apr_pool_t *pool)
+{
+ return APR_ENOTIMPL;
+}
+
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/shm.lo b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/shm.lo
new file mode 100644
index 00000000..ebc6464d
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/shm.lo
@@ -0,0 +1,12 @@
+# shm.lo - a libtool object file
+# Generated by ltmain.sh - GNU libtool 1.5.26 (1.1220.2.493 2008/02/01 16:58:18)
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object='.libs/shm.o'
+
+# Name of the non-PIC object.
+non_pic_object='shm.o'
+
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/shm.o b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/shm.o
new file mode 100644
index 00000000..a10a59ff
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/unix/shm.o
Binary files differ
diff --git a/rubbos/app/httpd-2.0.64/srclib/apr/shmem/win32/shm.c b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/win32/shm.c
new file mode 100644
index 00000000..2db04c0b
--- /dev/null
+++ b/rubbos/app/httpd-2.0.64/srclib/apr/shmem/win32/shm.c
@@ -0,0 +1,294 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file 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 KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "apr_general.h"
+#include "apr_errno.h"
+#include "apr_file_io.h"
+#include "apr_shm.h"
+#include "apr_arch_file_io.h"
+
+typedef struct memblock_t {
+ apr_size_t size;
+ apr_size_t length;
+} memblock_t;
+
+struct apr_shm_t {
+ apr_pool_t *pool;
+ memblock_t *memblk;
+ void *usrmem;
+ apr_size_t size;
+ apr_size_t length;
+ HANDLE hMap;
+};
+
+static apr_status_t shm_cleanup(void* shm)
+{
+ apr_status_t rv = APR_SUCCESS;
+ apr_shm_t *m = shm;
+
+ if (UnmapViewOfFile(m->memblk)) {
+ rv = apr_get_os_error();
+ }
+ if (CloseHandle(m->hMap)) {
+ return (rv != APR_SUCCESS) ? rv : apr_get_os_error();
+ }
+ /* ### Do we want to make a point of unlinking m->file here?
+ * Need to add the fname to the apr_shm_t, in that case.
+ */
+ return rv;
+}
+
+APR_DECLARE(apr_status_t) apr_shm_create(apr_shm_t **m,
+ apr_size_t reqsize,
+ const char *file,
+ apr_pool_t *pool)
+{
+ static apr_size_t memblock = 0;
+ HANDLE hMap, hFile;
+ apr_status_t rv;
+ apr_size_t size;
+ apr_file_t *f;
+ void *base;
+ void *mapkey;
+ DWORD err;
+
+ reqsize += sizeof(memblock_t);
+
+ if (!memblock)
+ {
+ SYSTEM_INFO si;
+ GetSystemInfo(&si);
+ memblock = si.dwAllocationGranularity;
+ }
+
+ /* Compute the granualar multiple of the pagesize */
+ size = memblock * (1 + (reqsize - 1) / memblock);
+
+ if (!file) {
+ /* Do Anonymous, which must be passed as a duplicated handle */
+#ifndef _WIN32_WCE
+ hFile = INVALID_HANDLE_VALUE;
+#endif
+ mapkey = NULL;
+ }
+ else {
+ /* Do file backed, which is not an inherited handle
+ * While we could open APR_EXCL, it doesn't seem that Unix
+ * ever did. Ignore that error here, but fail later when
+ * we discover we aren't the creator of the file map object.
+ */
+ rv = apr_file_open(&f, file,
+ APR_READ | APR_WRITE | APR_BINARY | APR_CREATE,
+ APR_UREAD | APR_UWRITE, pool);
+ if ((rv != APR_SUCCESS)
+ || ((rv = apr_os_file_get(&hFile, f)) != APR_SUCCESS)) {
+ return rv;
+ }
+ rv = apr_file_trunc(f, size);
+
+ /* res_name_from_filename turns file into a pseudo-name
+ * without slashes or backslashes, and prepends the \global
+ * prefix on Win2K and later
+ */
+ mapkey = res_name_from_filename(file, 1, pool);
+ }
+
+#if APR_HAS_UNICODE_FS
+ IF_WIN_OS_IS_UNICODE
+ {
+ hMap = CreateFileMappingW(hFile, NULL, PAGE_READWRITE, 0, size, mapkey);
+ }
+#endif
+#if APR_HAS_ANSI_FS
+ ELSE_WIN_OS_IS_ANSI
+ {
+ hMap = CreateFileMappingA(hFile, NULL, PAGE_READWRITE, 0, size, mapkey);
+ }
+#endif
+ err = apr_get_os_error();
+
+ if (file) {
+ apr_file_close(f);
+ }
+
+ if (hMap && APR_STATUS_IS_EEXIST(err)) {
+ CloseHandle(hMap);
+ return APR_EEXIST;
+ }
+ if (!hMap) {
+ return err;
+ }
+
+ base = MapViewOfFile(hMap, FILE_MAP_READ | FILE_MAP_WRITE,
+ 0, 0, size);
+ if (!base) {
+ CloseHandle(hMap);
+ return apr_get_os_error();
+ }
+
+ *m = (apr_shm_t *) apr_palloc(pool, sizeof(apr_shm_t));
+ (*m)->pool = pool;
+ (*m)->hMap = hMap;
+ (*m)->memblk = base;
+ (*m)->size = size;
+
+ (*m)->usrmem = (char*)base + sizeof(memblock_t);
+ (*m)->length = reqsize - sizeof(memblock_t);;
+
+ (*m)->memblk->length = (*m)->length;
+ (*m)->memblk->size = (*m)->size;
+
+ apr_pool_cleanup_register((*m)->pool, *m,
+ shm_cleanup, apr_pool_cleanup_null);
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_shm_destroy(apr_shm_t *m)
+{
+ apr_status_t rv = shm_cleanup(m);
+ apr_pool_cleanup_kill(m->pool, m, shm_cleanup);
+ return rv;
+}
+
+APR_DECLARE(apr_status_t) apr_shm_attach(apr_shm_t **m,
+ const char *file,
+ apr_pool_t *pool)
+{
+ HANDLE hMap;
+ void *mapkey;
+ void *base;
+
+ if (!file) {
+ return APR_EINVAL;
+ }
+ else {
+ /* res_name_from_filename turns file into a pseudo-name
+ * without slashes or backslashes, and prepends the \global
+ * prefix on Win2K and later
+ */
+ mapkey = res_name_from_filename(file, 1, pool);
+ }
+
+#if APR_HAS_UNICODE_FS
+ IF_WIN_OS_IS_UNICODE
+ {
+#ifndef _WIN32_WCE
+ hMap = OpenFileMappingW(FILE_MAP_READ | FILE_MAP_WRITE, FALSE, mapkey);
+#else
+ /* The WCE 3.0 lacks OpenFileMapping. So we emulate one with
+ * opening the existing shmem and reading its size from the header
+ */
+ hMap = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL,
+ PAGE_READWRITE, 0, sizeof(apr_shm_t), mapkey);
+#endif
+ }
+#endif
+#if APR_HAS_ANSI_FS
+ ELSE_WIN_OS_IS_ANSI
+ {
+ hMap = OpenFileMappingA(FILE_MAP_READ | FILE_MAP_WRITE, FALSE, mapkey);
+ }
+#endif
+
+ if (!hMap) {
+ return apr_get_os_error();
+ }
+
+ base = MapViewOfFile(hMap, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
+ if (!base) {
+ CloseHandle(hMap);
+ return apr_get_os_error();
+ }
+
+ *m = (apr_shm_t *) apr_palloc(pool, sizeof(apr_shm_t));
+ (*m)->pool = pool;
+ (*m)->memblk = base;
+ /* Real (*m)->mem->size could be recovered with VirtualQuery */
+ (*m)->size = (*m)->memblk->size;
+#if _WIN32_WCE
+ /* Reopen with real size */
+ UnmapViewOfFile(base);
+ CloseHandle(hMap);
+
+ hMap = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL,
+ PAGE_READWRITE, 0, (*m)->size, mapkey);
+ if (!hMap) {
+ return apr_get_os_error();
+ }
+ base = MapViewOfFile(hMap, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
+ if (!base) {
+ CloseHandle(hMap);
+ return apr_get_os_error();
+ }
+#endif
+ (*m)->hMap = hMap;
+ (*m)->length = (*m)->memblk->length;
+ (*m)->usrmem = (char*)base + sizeof(memblock_t);
+ apr_pool_cleanup_register((*m)->pool, *m,
+ shm_cleanup, apr_pool_cleanup_null);
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_shm_detach(apr_shm_t *m)
+{
+ apr_status_t rv = shm_cleanup(m);
+ apr_pool_cleanup_kill(m->pool, m, shm_cleanup);
+ return rv;
+}
+
+APR_DECLARE(void *) apr_shm_baseaddr_get(const apr_shm_t *m)
+{
+ return m->usrmem;
+}
+
+APR_DECLARE(apr_size_t) apr_shm_size_get(const apr_shm_t *m)
+{
+ return m->length;
+}
+
+APR_POOL_IMPLEMENT_ACCESSOR(shm)
+
+APR_DECLARE(apr_status_t) apr_os_shm_get(apr_os_shm_t *osshm,
+ apr_shm_t *shm)
+{
+ *osshm = shm->hMap;
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_os_shm_put(apr_shm_t **m,
+ apr_os_shm_t *osshm,
+ apr_pool_t *pool)
+{
+ void* base;
+ base = MapViewOfFile(*osshm, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
+ if (!base) {
+ return apr_get_os_error();
+ }
+
+ *m = (apr_shm_t *) apr_palloc(pool, sizeof(apr_shm_t));
+ (*m)->pool = pool;
+ (*m)->hMap = *osshm;
+ (*m)->memblk = base;
+ (*m)->usrmem = (char*)base + sizeof(memblock_t);
+ /* Real (*m)->mem->size could be recovered with VirtualQuery */
+ (*m)->size = (*m)->memblk->size;
+ (*m)->length = (*m)->memblk->length;
+
+ apr_pool_cleanup_register((*m)->pool, *m,
+ shm_cleanup, apr_pool_cleanup_null);
+ return APR_SUCCESS;
+}
+