Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 170352
Collapse All | Expand All

(-)arch/unix/fcgid_proctbl_unix.c.prev (+84 lines)
Lines 1-4 Link Here
1
#include "fcgid_proctbl.h"
1
#include "fcgid_proctbl.h"
2
#include "apr_version.h"
2
#include "apr_shm.h"
3
#include "apr_shm.h"
3
#include "apr_global_mutex.h"
4
#include "apr_global_mutex.h"
4
#include "fcgid_global.h"
5
#include "fcgid_global.h"
Lines 18-23 Link Here
18
static fcgid_global_share *g_global_share = NULL;	/* global information */
19
static fcgid_global_share *g_global_share = NULL;	/* global information */
19
static size_t g_table_size = FCGID_PROC_TABLE_SIZE;
20
static size_t g_table_size = FCGID_PROC_TABLE_SIZE;
20
21
22
/* apr version 0.x not support apr_shm_remove, I have to copy it from apr version 1.x */
23
#if (APR_MAJOR_VERSION < 1)
24
#ifdef HAVE_SYS_MMAN_H
25
#include <sys/mman.h>
26
#endif
27
#ifdef HAVE_SYS_IPC_H
28
#include <sys/ipc.h>
29
#endif
30
#ifdef HAVE_SYS_MUTEX_H
31
#include <sys/mutex.h>
32
#endif
33
#ifdef HAVE_SYS_SHM_H
34
#include <sys/shm.h>
35
#endif
36
#if !defined(SHM_R)
37
#define SHM_R 0400
38
#endif
39
#if !defined(SHM_W)
40
#define SHM_W 0200
41
#endif
42
#ifdef HAVE_SYS_FILE_H
43
#include <sys/file.h>
44
#endif
45
46
static apr_status_t apr_shm_remove(const char *filename, apr_pool_t * pool)
47
{
48
#if APR_USE_SHMEM_SHMGET
49
	apr_status_t status;
50
	apr_file_t *file;
51
	key_t shmkey;
52
	int shmid;
53
#endif
54
55
#if APR_USE_SHMEM_MMAP_TMP
56
	return apr_file_remove(filename, pool);
57
#endif
58
#if APR_USE_SHMEM_MMAP_SHM
59
	if (shm_unlink(filename) == -1) {
60
		return errno;
61
	}
62
	return APR_SUCCESS;
63
#endif
64
#if APR_USE_SHMEM_SHMGET
65
	/* Presume that the file already exists; just open for writing */
66
	status = apr_file_open(&file, filename, APR_WRITE,
67
						   APR_OS_DEFAULT, pool);
68
	if (status) {
69
		return status;
70
	}
71
72
	/* ftok() (on solaris at least) requires that the file actually
73
	 * exist before calling ftok(). */
74
	shmkey = ftok(filename, 1);
75
	if (shmkey == (key_t) - 1) {
76
		goto shm_remove_failed;
77
	}
78
79
	apr_file_close(file);
80
81
	if ((shmid = shmget(shmkey, 0, SHM_R | SHM_W)) < 0) {
82
		goto shm_remove_failed;
83
	}
84
85
	/* Indicate that the segment is to be destroyed as soon
86
	 * as all processes have detached. This also disallows any
87
	 * new attachments to the segment. */
88
	if (shmctl(shmid, IPC_RMID, NULL) == -1) {
89
		goto shm_remove_failed;
90
	}
91
	return apr_file_remove(filename, pool);
92
93
  shm_remove_failed:
94
	status = errno;
95
	/* ensure the file has been removed anyway. */
96
	apr_file_remove(filename, pool);
97
	return status;
98
#endif
99
100
	/* No support for anonymous shm */
101
	return APR_ENOTIMPL;
102
}
103
#endif							/* APR_MAJOR_VERSION<1 */
104
21
apr_status_t
105
apr_status_t
22
proctable_post_config(server_rec * main_server, apr_pool_t * configpool)
106
proctable_post_config(server_rec * main_server, apr_pool_t * configpool)
23
{
107
{

Return to bug 170352