~ubuntu-branches/debian/squeeze/nginx/squeeze

« back to all changes in this revision

Viewing changes to src/event/ngx_event.c

  • Committer: Bazaar Package Importer
  • Author(s): Fabio Tranchitella
  • Date: 2009-05-31 18:38:56 UTC
  • mfrom: (1.1.10 upstream) (4.1.12 experimental)
  • Revision ID: james.westby@ubuntu.com-20090531183856-3xhvf6wd0bw5556i
Tags: 0.7.59-1
* New upstream release, first in Debian for the 0.7 branch. Among other
  issues, it also fixes the problem with wildcard dns names used with SSL.
  (Closes: #515904)
* debian/watch: updated.
* debian/postinst: fixed a bashism. (Closes: #507913)
* debian/conf/nginx.conf: removed default_type. (Closes: #509390)
* debian/control: updated Standards-Version to 3.8.1, no changes needed.
* debian/NEWS.Debian: documented the issues with
  server_names_hash_bucket_size. (Closes: #524785)

Show diffs side-by-side

added added

removed removed

Lines of Context:
442
442
 
443
443
    ecf = (*cf)[ngx_event_core_module.ctx_index];
444
444
 
445
 
    if (!ngx_test_config) {
 
445
    if (!ngx_test_config && ngx_process <= NGX_PROCESS_MASTER) {
446
446
        ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0,
447
447
                      "using the \"%s\" event method", ecf->name);
448
448
    }
506
506
#endif
507
507
 
508
508
    shm.size = size;
 
509
    shm.name.len = sizeof("nginx_shared_zone");
 
510
    shm.name.data = (u_char *) "nginx_shared_zone";
509
511
    shm.log = cycle->log;
510
512
 
511
513
    if (ngx_shm_alloc(&shm) != NGX_OK) {
535
537
 
536
538
#endif
537
539
 
538
 
    *ngx_connection_counter = 1;
 
540
    (void) ngx_atomic_cmp_set(ngx_connection_counter, 0, 1);
539
541
 
540
542
    ngx_log_debug2(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
541
543
                   "counter: %p, %d",
596
598
        return NGX_ERROR;
597
599
    }
598
600
 
599
 
    cycle->connection_n = ecf->connections;
600
 
 
601
601
    for (m = 0; ngx_modules[m]; m++) {
602
602
        if (ngx_modules[m]->type != NGX_EVENT_MODULE) {
603
603
            continue;
604
604
        }
605
605
 
606
 
        if (ngx_modules[m]->ctx_index == ecf->use) {
607
 
            module = ngx_modules[m]->ctx;
608
 
            if (module->actions.init(cycle, ngx_timer_resolution) == NGX_ERROR)
609
 
            {
610
 
                /* fatal */
611
 
                exit(2);
612
 
            }
613
 
            break;
614
 
        }
 
606
        if (ngx_modules[m]->ctx_index != ecf->use) {
 
607
            continue;
 
608
        }
 
609
 
 
610
        module = ngx_modules[m]->ctx;
 
611
 
 
612
        if (module->actions.init(cycle, ngx_timer_resolution) != NGX_OK) {
 
613
            /* fatal */
 
614
            exit(2);
 
615
        }
 
616
 
 
617
        break;
615
618
    }
616
619
 
617
620
#if !(NGX_WIN32)
661
664
 
662
665
#endif
663
666
 
664
 
    cycle->connections = ngx_alloc(sizeof(ngx_connection_t) * ecf->connections,
665
 
                                   cycle->log);
 
667
    cycle->connections =
 
668
        ngx_alloc(sizeof(ngx_connection_t) * cycle->connection_n, cycle->log);
666
669
    if (cycle->connections == NULL) {
667
670
        return NGX_ERROR;
668
671
    }
669
672
 
670
673
    c = cycle->connections;
671
674
 
672
 
    cycle->read_events = ngx_alloc(sizeof(ngx_event_t) * ecf->connections,
 
675
    cycle->read_events = ngx_alloc(sizeof(ngx_event_t) * cycle->connection_n,
673
676
                                   cycle->log);
674
677
    if (cycle->read_events == NULL) {
675
678
        return NGX_ERROR;
685
688
#endif
686
689
    }
687
690
 
688
 
    cycle->write_events = ngx_alloc(sizeof(ngx_event_t) * ecf->connections,
 
691
    cycle->write_events = ngx_alloc(sizeof(ngx_event_t) * cycle->connection_n,
689
692
                                    cycle->log);
690
693
    if (cycle->write_events == NULL) {
691
694
        return NGX_ERROR;
719
722
    } while (i);
720
723
 
721
724
    cycle->free_connections = next;
722
 
    cycle->free_connection_n = ecf->connections;
 
725
    cycle->free_connection_n = cycle->connection_n;
723
726
 
724
727
    /* for each listening socket */
725
728
 
773
776
 
774
777
            rev->handler = ngx_event_acceptex;
775
778
 
 
779
            if (ngx_use_accept_mutex) {
 
780
                continue;
 
781
            }
 
782
 
776
783
            if (ngx_add_event(rev, 0, NGX_IOCP_ACCEPT) == NGX_ERROR) {
777
784
                return NGX_ERROR;
778
785
            }
789
796
        } else {
790
797
            rev->handler = ngx_event_accept;
791
798
 
 
799
            if (ngx_use_accept_mutex) {
 
800
                continue;
 
801
            }
 
802
 
792
803
            if (ngx_add_event(rev, NGX_READ_EVENT, 0) == NGX_ERROR) {
793
804
                return NGX_ERROR;
794
805
            }
1039
1050
    ngx_str_t          *value;
1040
1051
    ngx_event_debug_t  *dc;
1041
1052
    struct hostent     *h;
1042
 
    ngx_inet_cidr_t     in_cidr;
 
1053
    ngx_cidr_t          cidr;
1043
1054
 
1044
1055
    value = cf->args->elts;
1045
1056
 
1046
 
    /* AF_INET only */
1047
 
 
1048
1057
    dc = ngx_array_push(&ecf->debug_connection);
1049
1058
    if (dc == NULL) {
1050
1059
        return NGX_CONF_ERROR;
1051
1060
    }
1052
1061
 
1053
 
    dc->addr = inet_addr((char *) value[1].data);
1054
 
 
1055
 
    if (dc->addr != INADDR_NONE) {
1056
 
        dc->mask = 0xffffffff;
1057
 
        return NGX_CONF_OK;
1058
 
    }
1059
 
 
1060
 
    rc = ngx_ptocidr(&value[1], &in_cidr);
 
1062
    rc = ngx_ptocidr(&value[1], &cidr);
1061
1063
 
1062
1064
    if (rc == NGX_DONE) {
1063
1065
        ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
1066
1068
    }
1067
1069
 
1068
1070
    if (rc == NGX_OK) {
1069
 
        dc->mask = in_cidr.mask;
1070
 
        dc->addr = in_cidr.addr;
 
1071
 
 
1072
        /* AF_INET only */
 
1073
 
 
1074
        if (cidr.family != AF_INET) {
 
1075
            ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
 
1076
                               "\"debug_connection\" supports IPv4 only");
 
1077
            return NGX_CONF_ERROR;
 
1078
        }
 
1079
 
 
1080
        dc->mask = cidr.u.in.mask;
 
1081
        dc->addr = cidr.u.in.addr;
 
1082
 
1071
1083
        return NGX_CONF_OK;
1072
1084
    }
1073
1085
 
1137
1149
    ngx_uint_t           rtsig;
1138
1150
    ngx_core_conf_t     *ccf;
1139
1151
#endif
1140
 
    ngx_int_t            i, connections;
 
1152
    ngx_int_t            i;
1141
1153
    ngx_module_t        *module;
1142
1154
    ngx_event_module_t  *event_module;
1143
1155
 
1144
 
    connections = NGX_CONF_UNSET_UINT;
1145
1156
    module = NULL;
1146
1157
 
1147
1158
#if (NGX_HAVE_EPOLL) && !(NGX_TEST_BUILD_EPOLL)
1150
1161
 
1151
1162
    if (fd != -1) {
1152
1163
        close(fd);
1153
 
        connections = DEFAULT_CONNECTIONS;
1154
1164
        module = &ngx_epoll_module;
1155
1165
 
1156
1166
    } else if (ngx_errno != NGX_ENOSYS) {
1157
 
        connections = DEFAULT_CONNECTIONS;
1158
1167
        module = &ngx_epoll_module;
1159
1168
    }
1160
1169
 
1163
1172
#if (NGX_HAVE_RTSIG)
1164
1173
 
1165
1174
    if (module == NULL) {
1166
 
        connections = DEFAULT_CONNECTIONS;
1167
1175
        module = &ngx_rtsig_module;
1168
1176
        rtsig = 1;
1169
1177
 
1175
1183
 
1176
1184
#if (NGX_HAVE_DEVPOLL)
1177
1185
 
1178
 
    connections = DEFAULT_CONNECTIONS;
1179
1186
    module = &ngx_devpoll_module;
1180
1187
 
1181
1188
#endif
1182
1189
 
1183
1190
#if (NGX_HAVE_KQUEUE)
1184
1191
 
1185
 
    connections = DEFAULT_CONNECTIONS;
1186
1192
    module = &ngx_kqueue_module;
1187
1193
 
1188
1194
#endif
1190
1196
#if (NGX_HAVE_SELECT)
1191
1197
 
1192
1198
    if (module == NULL) {
1193
 
 
1194
 
#if (NGX_WIN32 || FD_SETSIZE >= DEFAULT_CONNECTIONS)
1195
 
        connections = DEFAULT_CONNECTIONS;
1196
 
#else
1197
 
        connections = FD_SETSIZE;
1198
 
#endif
1199
1199
        module = &ngx_select_module;
1200
1200
    }
1201
1201
 
1203
1203
 
1204
1204
    if (module == NULL) {
1205
1205
        for (i = 0; ngx_modules[i]; i++) {
1206
 
            if (ngx_modules[i]->type == NGX_EVENT_MODULE) {
1207
 
                event_module = ngx_modules[i]->ctx;
1208
 
 
1209
 
                if (ngx_strcmp(event_module->name->data, event_core_name.data)
1210
 
                    == 0)
1211
 
                {
1212
 
                    continue;
1213
 
                }
1214
 
 
1215
 
                module = ngx_modules[i];
1216
 
                break;
1217
 
            }
 
1206
 
 
1207
            if (ngx_modules[i]->type != NGX_EVENT_MODULE) {
 
1208
                continue;
 
1209
            }
 
1210
 
 
1211
            event_module = ngx_modules[i]->ctx;
 
1212
 
 
1213
            if (ngx_strcmp(event_module->name->data, event_core_name.data) == 0)
 
1214
            {
 
1215
                continue;
 
1216
            }
 
1217
 
 
1218
            module = ngx_modules[i];
 
1219
            break;
1218
1220
        }
1219
1221
    }
1220
1222
 
1223
1225
        return NGX_CONF_ERROR;
1224
1226
    }
1225
1227
 
1226
 
    ngx_conf_init_uint_value(ecf->connections, connections);
 
1228
    ngx_conf_init_uint_value(ecf->connections, DEFAULT_CONNECTIONS);
1227
1229
    cycle->connection_n = ecf->connections;
1228
1230
 
1229
1231
    ngx_conf_init_uint_value(ecf->use, module->ctx_index);