~ubuntu-branches/ubuntu/quantal/nginx/quantal-updates

« back to all changes in this revision

Viewing changes to debian/modules/nginx-development-kit/src/ndk_upstream_list.c

  • Committer: Bazaar Package Importer
  • Author(s): Michael Lustfield, Micheal Lustfield, Kartik Mistry
  • Date: 2011-03-03 23:39:07 UTC
  • mfrom: (4.2.29 sid)
  • Revision ID: james.westby@ubuntu.com-20110303233907-y48yifhfnn5qjuxz
Tags: 0.8.54-4
[Micheal Lustfield]
* debian/nginx-{full,light,extras}.default:
  + Added comment about alternative to ULIMIT.
* debian/nginx-{full,light,extras}.init.d:
  + Added quotes around a test variable. (Closes: #610946, LP: #699736)
* debian/patches/609343-log-time-iso8601.diff:
  + Added patch to add $time_iso8601 variable to logs. (Closes: #609343)
* Clean up old logrotate files. (Closes: #608983, Closes: #610289)
  + Added Files:
    - debian/nginx-common.preinst
  + Modified Files:
    - debian/rules
  + Moved debian/nginx-common.logrotate to debian/logrotate.
* Added common files to nginx-common package. (Closes: #610290)
  + Removed Files:
    - debian/nginx-full.dirs
    - debian/nginx-light.dirs
    - debian/nginx-full.install
    - debian/nginx-light.install
    - debian/nginx-extras.install
    - debian/nginx.*
  + Added Files:
    - debian/nginx-common.default
    - debian/nginx-common.dirs
    - debian/nginx-common.init.d
    - debian/nginx-common.install
    - debian/nginx-common.manpages
    - debian/logrotate
  + Modified Files:
    - debian/nginx-extras.dirs
    - debian/control
    - debian/rules
* debian/nginx-*.install: (Closes: #609797)
  + Removed NEWS.Debian from nginx-{full,light,extras}.install.
  + Added NEWS.Debian to nginx-common.install.
* nginx-common.postinst:
  + Enforce /var/log/nginx mode and user:group. (Closes: #610983)
  + Enforce /var/log/nginx/*.log mode and user:group. (Closes: #612832)
* debian/rules:
  + Added --with-file-aio to nginx-extras. (Closes: #613175)
  + Removed split clients and user id modules from nginx-light.
* debian/conf/sites-available/default:
  + Fixed a minor typo ( s/Quickstart/QuickStart/ ). (Closes: #613355)
* debian/conf/mime.types:
  + Changed xml type to application/xhtml+xml. (Closes: #613851)
* debian/help/docs/fcgiwrap:
  + Removed Ubuntu specific line in docs. (Closes: #614987)
* debian/conf/sites-available/default:
  + Fixed a pointer to a file. (Closes: #614980)

[Kartik Mistry]
* debian/*.lintian-overrides:
  + Add Lintian overrides for nginx man page. We've manpage in nginx-common
    binary

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
// TODO : generalize this into a generic list module, with weight
 
4
 
 
5
 
 
6
ngx_array_t     *ndk_upstreams;
 
7
 
 
8
typedef struct {
 
9
    ngx_uint_t      weight;
 
10
    ngx_str_t       s;
 
11
    ngx_conf_t     *cf;
 
12
} ndk_upstream_list_parse_t;
 
13
 
 
14
 
 
15
 
 
16
static ngx_int_t
 
17
ndk_upstream_list_parse_weight (ndk_upstream_list_parse_t *ulp)
 
18
{
 
19
    size_t      i;
 
20
    ngx_str_t   *s;
 
21
 
 
22
    s = &ulp->s;
 
23
 
 
24
    for (i=0; i<s->len; i++) {
 
25
 
 
26
        if (s->data[i] < '0' || s->data[i] > '9')
 
27
            break;
 
28
    }
 
29
 
 
30
    if (!i) {
 
31
        ulp->weight = 1;
 
32
        return  NGX_OK;
 
33
    }
 
34
 
 
35
    if (i == s->len) {
 
36
        ngx_conf_log_error (NGX_LOG_EMERG, ulp->cf, 0,
 
37
            "upstream list just consists of number \"%V\"", s);
 
38
 
 
39
        return  NGX_ERROR;
 
40
    }
 
41
 
 
42
    if (s->data[i] != ':') {
 
43
        ngx_conf_log_error (NGX_LOG_EMERG, ulp->cf, 0,
 
44
            "upstream list not correct format \"%V\"", s);
 
45
 
 
46
        return  NGX_ERROR;
 
47
    }
 
48
 
 
49
 
 
50
    ulp->weight = ngx_atoi (s->data, i);
 
51
 
 
52
    s->data += (i + 1);
 
53
    s->len -= (i + 1);
 
54
 
 
55
    return  NGX_OK;
 
56
}
 
57
 
 
58
 
 
59
 
 
60
static char *
 
61
ndk_upstream_list (ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
 
62
{
 
63
    // TODO : change this for getting upstream pointer if available
 
64
 
 
65
    ngx_uint_t                   buckets, count, i, j;
 
66
    ngx_str_t                   *value, **bucket, *us;
 
67
    ngx_array_t                 *ula;
 
68
    ndk_upstream_list_t         *ul, *ule;
 
69
    ndk_upstream_list_parse_t    ulp;
 
70
 
 
71
 
 
72
    ula = ndk_upstreams;
 
73
 
 
74
    // create array of upstream lists it doesn't already exist
 
75
 
 
76
    if (ula == NULL) {
 
77
 
 
78
        ula = ngx_array_create (cf->pool, 4, sizeof (ndk_upstream_list_t));
 
79
        if (ula == NULL)
 
80
            return  NGX_CONF_ERROR;
 
81
 
 
82
        ndk_upstreams = ula;
 
83
    }
 
84
 
 
85
 
 
86
    // check to see if the list already exists
 
87
 
 
88
    value = cf->args->elts;
 
89
    value++;
 
90
 
 
91
    ul = ula->elts;
 
92
    ule = ul + ula->nelts;
 
93
 
 
94
    for ( ; ul<ule; ul++) {
 
95
 
 
96
        if (ul->name.len == value->len && 
 
97
            ngx_strncasecmp (ul->name.data, value->data, value->len) == 0) {
 
98
 
 
99
            ngx_conf_log_error (NGX_LOG_EMERG, cf, 0,
 
100
                           "duplicate upstream list name \"%V\"", value);
 
101
 
 
102
            return  NGX_CONF_ERROR;
 
103
        }
 
104
    }
 
105
 
 
106
 
 
107
    // create a new list
 
108
 
 
109
    ul = ngx_array_push (ula);
 
110
    if (ul == NULL)
 
111
        return  NGX_CONF_ERROR;
 
112
 
 
113
    ul->name = *value;
 
114
 
 
115
 
 
116
 
 
117
    // copy all the upstream names
 
118
 
 
119
    count = cf->args->nelts - 2;
 
120
 
 
121
    us = ngx_palloc (cf->pool, count * sizeof (ngx_str_t));
 
122
    if (us == NULL)
 
123
        return  NGX_CONF_ERROR;
 
124
 
 
125
    ngx_memcpy (us, value + 1, count * sizeof (ngx_str_t));
 
126
 
 
127
 
 
128
    // calculate the total number of buckets
 
129
 
 
130
    buckets = 0;
 
131
 
 
132
    ulp.cf = cf;
 
133
 
 
134
    for (i=0; i<count; i++, us++) {
 
135
 
 
136
        ulp.s = *us;
 
137
 
 
138
        if (ndk_upstream_list_parse_weight (&ulp) != NGX_OK)
 
139
            return  NGX_CONF_ERROR;
 
140
 
 
141
        buckets += ulp.weight;
 
142
    }
 
143
 
 
144
 
 
145
    // allocate space for all buckets
 
146
 
 
147
    bucket = ngx_palloc (cf->pool, buckets * sizeof (ngx_str_t **));
 
148
    if (bucket == NULL)
 
149
        return  NGX_CONF_ERROR;
 
150
    
 
151
    ul->elts = bucket;
 
152
    ul->nelts = buckets;
 
153
 
 
154
 
 
155
    // set values for each bucket
 
156
 
 
157
    us -= count;
 
158
 
 
159
    for (i=0; i<count; i++, us++) {
 
160
 
 
161
        ulp.s = *us;
 
162
 
 
163
        if (ndk_upstream_list_parse_weight (&ulp) != NGX_OK)
 
164
            return  NGX_CONF_ERROR;
 
165
 
 
166
        us->data = ulp.s.data;
 
167
        us->len = ulp.s.len;
 
168
 
 
169
        // TODO : check format of upstream
 
170
        // TODO : add automatic adding of http:// in upstreams?
 
171
 
 
172
        for (j=0; j<ulp.weight; j++, bucket++) {
 
173
 
 
174
            *bucket = us;
 
175
        }
 
176
    }
 
177
 
 
178
    return  NGX_CONF_OK;
 
179