~ubuntu-branches/ubuntu/raring/nginx/raring-proposed

« back to all changes in this revision

Viewing changes to src/http/modules/ngx_http_uwsgi_module.c

  • Committer: Package Import Robot
  • Author(s): Kartik Mistry, Kartik Mistry, Michael Lustfield
  • Date: 2011-11-18 23:44:00 UTC
  • mfrom: (1.1.26)
  • Revision ID: package-import@ubuntu.com-20111118234400-iel4oagndsek0wi6
Tags: 1.1.8-1
[Kartik Mistry]
* New upstream release.
* debian/modules/chunkin-nginx-module:
  + Removed as of now, as it breaks with Perl 5.14 (Closes: #649061)

[Michael Lustfield]
* debian/control:
  + Added Map module to nginx-light modules list.
* debian/rules:
  + Removed --without-http_map_module form nginx-light.
* debian/nginx-common.install:
  + Changed ufw profile installation (LP: #825349).
    - debian/ufw.profile -> debian/ufw/nginx.
* debian/nginx-common.preinst:
  + Cleanup of moved nginx profile.
* debian/conf/nginx.conf:
  + Added a default map for $server_https (on|off).
* debian/conf/fastcgi_params:
  + Pass HTTPS so $_SERVER['HTTPS'] is set (LP: #857831).
* debian/conf/mime.types:
  + Added json type (LP: #883440).
* debian/conf/sites-available/default:
  + Added notes about PHP (Closes: #642995).
  + Changed location /doc from root to alias.
  + Changed location /doc to /doc/ for people that don't bother reading or
    learning anything about Nginx configuration files (LP: #840358).

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
static void *ngx_http_uwsgi_create_loc_conf(ngx_conf_t *cf);
51
51
static char *ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent,
52
52
    void *child);
 
53
static ngx_int_t ngx_http_uwsgi_merge_params(ngx_conf_t *cf,
 
54
    ngx_http_uwsgi_loc_conf_t *conf, ngx_http_uwsgi_loc_conf_t *prev);
53
55
 
54
56
static char *ngx_http_uwsgi_pass(ngx_conf_t *cf, ngx_command_t *cmd,
55
57
    void *conf);
123
125
      offsetof(ngx_http_uwsgi_loc_conf_t, upstream.store_access),
124
126
      NULL },
125
127
 
 
128
    { ngx_string("uwsgi_buffering"),
 
129
      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
 
130
      ngx_conf_set_flag_slot,
 
131
      NGX_HTTP_LOC_CONF_OFFSET,
 
132
      offsetof(ngx_http_uwsgi_loc_conf_t, upstream.buffering),
 
133
      NULL },
 
134
 
126
135
    { ngx_string("uwsgi_ignore_client_abort"),
127
136
      NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
128
137
      ngx_conf_set_flag_slot,
445
454
    u->abort_request = ngx_http_uwsgi_abort_request;
446
455
    u->finalize_request = ngx_http_uwsgi_finalize_request;
447
456
 
448
 
    u->buffering = 1;
 
457
    u->buffering = uwcf->upstream.buffering;
449
458
 
450
459
    u->pipe = ngx_pcalloc(r->pool, sizeof(ngx_event_pipe_t));
451
460
    if (u->pipe == NULL) {
1091
1100
    /* "uwsgi_cyclic_temp_file" is disabled */
1092
1101
    conf->upstream.cyclic_temp_file = 0;
1093
1102
 
 
1103
    conf->upstream.change_buffering = 1;
 
1104
 
1094
1105
    ngx_str_set(&conf->upstream.module, "uwsgi");
1095
1106
 
1096
1107
    return conf;
1103
1114
    ngx_http_uwsgi_loc_conf_t *prev = parent;
1104
1115
    ngx_http_uwsgi_loc_conf_t *conf = child;
1105
1116
 
1106
 
    u_char                       *p;
1107
1117
    size_t                        size;
1108
 
    uintptr_t                    *code;
1109
 
    ngx_uint_t                    i;
1110
 
    ngx_array_t                   headers_names;
1111
 
    ngx_keyval_t                 *src;
1112
 
    ngx_hash_key_t               *hk;
1113
1118
    ngx_hash_init_t               hash;
1114
1119
    ngx_http_core_loc_conf_t     *clcf;
1115
 
    ngx_http_script_compile_t     sc;
1116
 
    ngx_http_script_copy_code_t  *copy;
1117
1120
 
1118
1121
    if (conf->upstream.store != 0) {
1119
1122
        ngx_conf_merge_value(conf->upstream.store, prev->upstream.store, 0);
1356
1359
    ngx_conf_merge_uint_value(conf->modifier1, prev->modifier1, 0);
1357
1360
    ngx_conf_merge_uint_value(conf->modifier2, prev->modifier2, 0);
1358
1361
 
 
1362
    if (ngx_http_uwsgi_merge_params(cf, conf, prev) != NGX_OK) {
 
1363
        return NGX_CONF_ERROR;
 
1364
    }
 
1365
 
 
1366
    return NGX_CONF_OK;
 
1367
}
 
1368
 
 
1369
 
 
1370
static ngx_int_t
 
1371
ngx_http_uwsgi_merge_params(ngx_conf_t *cf, ngx_http_uwsgi_loc_conf_t *conf,
 
1372
    ngx_http_uwsgi_loc_conf_t *prev)
 
1373
{
 
1374
    u_char                       *p;
 
1375
    size_t                        size;
 
1376
    uintptr_t                    *code;
 
1377
    ngx_uint_t                    i, nsrc;
 
1378
    ngx_array_t                   headers_names;
 
1379
#if (NGX_HTTP_CACHE)
 
1380
    ngx_array_t                   params_merged;
 
1381
#endif
 
1382
    ngx_keyval_t                 *src;
 
1383
    ngx_hash_key_t               *hk;
 
1384
    ngx_hash_init_t               hash;
 
1385
    ngx_http_script_compile_t     sc;
 
1386
    ngx_http_script_copy_code_t  *copy;
 
1387
 
1359
1388
    if (conf->params_source == NULL) {
1360
 
        conf->flushes = prev->flushes;
1361
 
        conf->params_len = prev->params_len;
1362
 
        conf->params = prev->params;
1363
1389
        conf->params_source = prev->params_source;
1364
 
        conf->headers_hash = prev->headers_hash;
1365
 
 
1366
 
#if (NGX_HTTP_CACHE)
1367
 
 
1368
 
        if (conf->params_source == NULL) {
1369
 
 
1370
 
            if ((conf->upstream.cache == NULL)
1371
 
                == (prev->upstream.cache == NULL))
1372
 
            {
1373
 
                return NGX_CONF_OK;
1374
 
            }
1375
 
 
1376
 
            /* 6 is a number of ngx_http_uwsgi_cache_headers entries */
1377
 
            conf->params_source = ngx_array_create(cf->pool, 6,
1378
 
                                                   sizeof(ngx_keyval_t));
1379
 
            if (conf->params_source == NULL) {
1380
 
                return NGX_CONF_ERROR;
1381
 
            }
1382
 
        }
1383
 
#else
1384
 
 
1385
 
        if (conf->params_source == NULL) {
1386
 
            return NGX_CONF_OK;
1387
 
        }
1388
 
 
1389
 
#endif
 
1390
 
 
1391
        if (prev->headers_hash.buckets
 
1392
#if (NGX_HTTP_CACHE)
 
1393
            && ((conf->upstream.cache == NULL) == (prev->upstream.cache == NULL))
 
1394
#endif
 
1395
           )
 
1396
        {
 
1397
            conf->flushes = prev->flushes;
 
1398
            conf->params_len = prev->params_len;
 
1399
            conf->params = prev->params;
 
1400
            conf->headers_hash = prev->headers_hash;
 
1401
            conf->header_params = prev->header_params;
 
1402
 
 
1403
            return NGX_OK;
 
1404
        }
 
1405
    }
 
1406
 
 
1407
    if (conf->params_source == NULL
 
1408
#if (NGX_HTTP_CACHE)
 
1409
        && (conf->upstream.cache == NULL)
 
1410
#endif
 
1411
       )
 
1412
    {
 
1413
        conf->headers_hash.buckets = (void *) 1;
 
1414
        return NGX_OK;
1390
1415
    }
1391
1416
 
1392
1417
    conf->params_len = ngx_array_create(cf->pool, 64, 1);
1393
1418
    if (conf->params_len == NULL) {
1394
 
        return NGX_CONF_ERROR;
 
1419
        return NGX_ERROR;
1395
1420
    }
1396
1421
 
1397
1422
    conf->params = ngx_array_create(cf->pool, 512, 1);
1398
1423
    if (conf->params == NULL) {
1399
 
        return NGX_CONF_ERROR;
 
1424
        return NGX_ERROR;
1400
1425
    }
1401
1426
 
1402
1427
    if (ngx_array_init(&headers_names, cf->temp_pool, 4, sizeof(ngx_hash_key_t))
1403
1428
        != NGX_OK)
1404
1429
    {
1405
 
        return NGX_CONF_ERROR;
1406
 
    }
1407
 
 
1408
 
    src = conf->params_source->elts;
 
1430
        return NGX_ERROR;
 
1431
    }
 
1432
 
 
1433
    if (conf->params_source) {
 
1434
        src = conf->params_source->elts;
 
1435
        nsrc = conf->params_source->nelts;
 
1436
 
 
1437
    } else {
 
1438
        src = NULL;
 
1439
        nsrc = 0;
 
1440
    }
1409
1441
 
1410
1442
#if (NGX_HTTP_CACHE)
1411
1443
 
1412
1444
    if (conf->upstream.cache) {
1413
1445
        ngx_keyval_t  *h, *s;
1414
1446
 
1415
 
        for (h = ngx_http_uwsgi_cache_headers; h->key.len; h++) {
1416
 
 
1417
 
            for (i = 0; i < conf->params_source->nelts; i++) {
 
1447
        if (ngx_array_init(&params_merged, cf->temp_pool, 4, sizeof(ngx_keyval_t))
 
1448
            != NGX_OK)
 
1449
        {
 
1450
            return NGX_ERROR;
 
1451
        }
 
1452
 
 
1453
        for (i = 0; i < nsrc; i++) {
 
1454
 
 
1455
            s = ngx_array_push(&params_merged);
 
1456
            if (s == NULL) {
 
1457
                return NGX_ERROR;
 
1458
            }
 
1459
 
 
1460
            *s = src[i];
 
1461
        }
 
1462
 
 
1463
        h = ngx_http_uwsgi_cache_headers;
 
1464
 
 
1465
        while (h->key.len) {
 
1466
 
 
1467
            src = params_merged.elts;
 
1468
            nsrc = params_merged.nelts;
 
1469
 
 
1470
            for (i = 0; i < nsrc; i++) {
1418
1471
                if (ngx_strcasecmp(h->key.data, src[i].key.data) == 0) {
1419
1472
                    goto next;
1420
1473
                }
1421
1474
            }
1422
1475
 
1423
 
            s = ngx_array_push(conf->params_source);
 
1476
            s = ngx_array_push(&params_merged);
1424
1477
            if (s == NULL) {
1425
 
                return NGX_CONF_ERROR;
 
1478
                return NGX_ERROR;
1426
1479
            }
1427
1480
 
1428
1481
            *s = *h;
1429
1482
 
1430
 
            src = conf->params_source->elts;
1431
 
 
1432
1483
        next:
1433
1484
 
1434
1485
            h++;
1435
1486
        }
 
1487
 
 
1488
        src = params_merged.elts;
 
1489
        nsrc = params_merged.nelts;
1436
1490
    }
1437
1491
 
1438
1492
#endif
1439
1493
 
1440
 
    for (i = 0; i < conf->params_source->nelts; i++) {
 
1494
    for (i = 0; i < nsrc; i++) {
1441
1495
 
1442
1496
        if (src[i].key.len > sizeof("HTTP_") - 1
1443
1497
            && ngx_strncmp(src[i].key.data, "HTTP_", sizeof("HTTP_") - 1) == 0)
1444
1498
        {
1445
1499
            hk = ngx_array_push(&headers_names);
1446
1500
            if (hk == NULL) {
1447
 
                return NGX_CONF_ERROR;
 
1501
                return NGX_ERROR;
1448
1502
            }
1449
1503
 
1450
1504
            hk->key.len = src[i].key.len - 5;
1460
1514
        copy = ngx_array_push_n(conf->params_len,
1461
1515
                                sizeof(ngx_http_script_copy_code_t));
1462
1516
        if (copy == NULL) {
1463
 
            return NGX_CONF_ERROR;
 
1517
            return NGX_ERROR;
1464
1518
        }
1465
1519
 
1466
1520
        copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
1473
1527
 
1474
1528
        copy = ngx_array_push_n(conf->params, size);
1475
1529
        if (copy == NULL) {
1476
 
            return NGX_CONF_ERROR;
 
1530
            return NGX_ERROR;
1477
1531
        }
1478
1532
 
1479
1533
        copy->code = ngx_http_script_copy_code;
1492
1546
        sc.values = &conf->params;
1493
1547
 
1494
1548
        if (ngx_http_script_compile(&sc) != NGX_OK) {
1495
 
            return NGX_CONF_ERROR;
 
1549
            return NGX_ERROR;
1496
1550
        }
1497
1551
 
1498
1552
        code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
1499
1553
        if (code == NULL) {
1500
 
            return NGX_CONF_ERROR;
 
1554
            return NGX_ERROR;
1501
1555
        }
1502
1556
 
1503
1557
        *code = (uintptr_t) NULL;
1505
1559
 
1506
1560
        code = ngx_array_push_n(conf->params, sizeof(uintptr_t));
1507
1561
        if (code == NULL) {
1508
 
            return NGX_CONF_ERROR;
 
1562
            return NGX_ERROR;
1509
1563
        }
1510
1564
 
1511
1565
        *code = (uintptr_t) NULL;
1513
1567
 
1514
1568
    code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
1515
1569
    if (code == NULL) {
1516
 
        return NGX_CONF_ERROR;
 
1570
        return NGX_ERROR;
1517
1571
    }
1518
1572
 
1519
1573
    *code = (uintptr_t) NULL;
1528
1582
    hash.pool = cf->pool;
1529
1583
    hash.temp_pool = NULL;
1530
1584
 
1531
 
    if (ngx_hash_init(&hash, headers_names.elts, headers_names.nelts) != NGX_OK)
1532
 
    {
1533
 
        return NGX_CONF_ERROR;
1534
 
    }
1535
 
 
1536
 
    return NGX_CONF_OK;
 
1585
    return ngx_hash_init(&hash, headers_names.elts, headers_names.nelts);
1537
1586
}
1538
1587
 
1539
1588