~ubuntu-branches/ubuntu/raring/apache-upload-progress-module/raring

« back to all changes in this revision

Viewing changes to ap_backports.h

  • Committer: Bazaar Package Importer
  • Author(s): Jérémy Bobbio
  • Date: 2011-07-19 18:41:47 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110719184147-egvw5mnhj66dydx0
Tags: 0.1+git20110718-1
* New upstream snapshot.
* Do not mention Nginx and lighttpd in extended description.
  (Closes: #610805)
* Fix spelling error in extended description spotted by lintian.
* Bump Standards-Version to 3.9.2, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * This macro is not present in Apache HTTP server version 2.2.3 
 
3
 * Red-Hat 5 / CentOS 5
 
4
 */
 
5
#ifndef ap_is_HTTP_VALID_RESPONSE
 
6
#  define ap_is_HTTP_VALID_RESPONSE(x) (((x) >= 100)&&((x) < 600))
 
7
#endif
 
8
 
 
9
/*
 
10
 * apr_time_from_msec is defined in APR 1.4.0 or later
 
11
 */
 
12
#if (APR_MAJOR_VERSION < 1) || ((APR_MAJOR_VERSION == 1) && (APR_MINOR_VERSION < 4))
 
13
#define apr_time_from_msec(x) (x * 1000)
 
14
#endif
 
15
 
 
16
/*
 
17
 * The following is a patch ported from mod_fcgid for Apache 2.0 releases
 
18
 * which don't provide a version of apr_shm_remove.
 
19
 *
 
20
 * Please have a look at the mod_fcgid mailing list for details.
 
21
 * The original patch can be found at:
 
22
 *     http://lists.freebsd.org/pipermail/freebsd-ports-bugs/2007-June/122731.html
 
23
 */
 
24
/* BEGIN OF PATCH ---------------------------------------------------------- */
 
25
/* apr version 0.x not support apr_shm_remove, I have to copy it from apr version 1.x */
 
26
#if (APR_MAJOR_VERSION < 1)
 
27
 
 
28
#if APR_HAS_SHARED_MEMORY
 
29
 
 
30
        #ifdef HAVE_SYS_MMAN_H
 
31
                #include <sys/mman.h>
 
32
        #endif
 
33
        #ifdef HAVE_SYS_IPC_H
 
34
                #include <sys/ipc.h>
 
35
        #endif
 
36
        #ifdef HAVE_SYS_MUTEX_H
 
37
                #include <sys/mutex.h>
 
38
        #endif
 
39
        #ifdef HAVE_SYS_SHM_H
 
40
                #include <sys/shm.h>
 
41
        #endif
 
42
        #if !defined(SHM_R)
 
43
                #define SHM_R 0400
 
44
        #endif
 
45
        #if !defined(SHM_W)
 
46
                #define SHM_W 0200
 
47
        #endif
 
48
        #ifdef HAVE_SYS_FILE_H
 
49
                #include <sys/file.h>
 
50
        #endif
 
51
 
 
52
/* To avoid conflicts with mod_fcgid and that instance of the patch there.
 
53
 * This basically replaces each of our instances of apr_shm_remove with a local
 
54
 * identifier only used by us thus avoiding hard-to-find bugs if the wrong
 
55
 * version of this function gets linked in when loading the module.
 
56
 *
 
57
 * If re-using this patch you are therefore encouraged to change the name of
 
58
 * the resulting function in the makro and the function declaration below.
 
59
 */
 
60
#define apr_shm_remove modup_backport_apr_shm_remove
 
61
static apr_status_t modup_backport_apr_shm_remove(const char *filename, apr_pool_t * pool)
 
62
{
 
63
#if APR_USE_SHMEM_SHMGET
 
64
    apr_status_t status;
 
65
    apr_file_t *file;
 
66
    key_t shmkey;
 
67
    int shmid;
 
68
#endif
 
69
 
 
70
#if APR_USE_SHMEM_MMAP_TMP
 
71
    return apr_file_remove(filename, pool);
 
72
#endif
 
73
 
 
74
#if APR_USE_SHMEM_MMAP_SHM
 
75
    if (shm_unlink(filename) == -1) {
 
76
        return errno;
 
77
    }
 
78
    return APR_SUCCESS;
 
79
#endif
 
80
 
 
81
#if APR_USE_SHMEM_SHMGET
 
82
    /* Presume that the file already exists; just open for writing */
 
83
    status = apr_file_open(&file, filename, APR_WRITE, APR_OS_DEFAULT, pool);
 
84
    if (status) {
 
85
        return status;
 
86
    }
 
87
 
 
88
    /* ftok() (on solaris at least) requires that the file actually
 
89
     * exist before calling ftok(). */
 
90
    shmkey = ftok(filename, 1);
 
91
    if (shmkey == (key_t) - 1) {
 
92
        goto shm_remove_failed;
 
93
    }
 
94
 
 
95
    apr_file_close(file);
 
96
    if ((shmid = shmget(shmkey, 0, SHM_R | SHM_W)) < 0) {
 
97
        goto shm_remove_failed;
 
98
    }
 
99
 
 
100
    /* Indicate that the segment is to be destroyed as soon
 
101
     * as all processes have detached. This also disallows any
 
102
     * new attachments to the segment. */
 
103
    if (shmctl(shmid, IPC_RMID, NULL) == -1) {
 
104
        goto shm_remove_failed;
 
105
    }
 
106
    return apr_file_remove(filename, pool);
 
107
 
 
108
shm_remove_failed:
 
109
    status = errno;
 
110
    /* ensure the file has been removed anyway. */
 
111
    apr_file_remove(filename, pool);
 
112
    return status;
 
113
#endif
 
114
 
 
115
    /* No support for anonymous shm */
 
116
    return APR_ENOTIMPL;
 
117
}
 
118
/* END OF PATCH ------------------------------------------------------------ */
 
119
 
 
120
#endif
 
121
/* (APR_MAJOR_VERSION < 1) */
 
122
#endif