PeruserAttachments: httpd-2.2.3-peruser-0.3.0-dc3.patch
| File httpd-2.2.3-peruser-0.3.0-dc3.patch, 43.1 KB (added by mephisto23, 3 years ago) |
|---|
-
server/mpm/experimental/peruser/mpm_default.h
old new 77 77 #define DEFAULT_MIN_FREE_PROCESSORS 2 78 78 #endif 79 79 80 /* Maximum --- more than this, and idle processors will be killed (0 = disable) */ 81 82 #ifndef DEFAULT_MAX_FREE_PROCESSORS 83 #define DEFAULT_MAX_FREE_PROCESSORS 0 84 #endif 85 80 86 /* Maximum processors per ServerEnvironment */ 81 87 82 88 #ifndef DEFAULT_MAX_PROCESSORS … … 107 113 #define DEFAULT_MAX_REQUESTS_PER_CHILD 10000 108 114 #endif 109 115 116 /* Maximum multiplexers */ 117 118 #ifndef DEFAULT_MAX_MULTIPLEXERS 119 #define DEFAULT_MAX_MULTIPLEXERS 20 120 #endif 121 122 /* Minimum multiplexers */ 123 124 #ifndef DEFAULT_MIN_MULTIPLEXERS 125 #define DEFAULT_MIN_MULTIPLEXERS 3 126 #endif 127 128 /* Amount of time a child can run before it expires (0 = turn off) */ 129 130 #ifndef DEFAULT_EXPIRE_TIMEOUT 131 #define DEFAULT_EXPIRE_TIMEOUT 1800 132 #endif 133 134 /* Amount of time a child can stay idle (0 = turn off) */ 135 136 #ifndef DEFAULT_IDLE_TIMEOUT 137 #define DEFAULT_IDLE_TIMEOUT 900 138 #endif 139 140 /* Amount of time a multiplexer can stay idle (0 = turn off) */ 141 142 #ifndef DEFAULT_MULTIPLEXER_IDLE_TIMEOUT 143 #define DEFAULT_MULTIPLEXER_IDLE_TIMEOUT 0 144 #endif 145 146 /* Amount of maximum time a multiplexer can wait for processor if it is busy (0 = never wait) 147 * This is decreased with every busy request 148 */ 149 150 #ifndef DEFAULT_PROCESSOR_WAIT_TIMEOUT 151 #define DEFAULT_PROCESSOR_WAIT_TIMEOUT 5 152 #endif 153 154 /* The number of different levels there are when a multiplexer is waiting for processor 155 * (between maximum waiting time and no waiting) 156 */ 157 158 #ifndef DEFAULT_PROCESSOR_WAIT_STEPS 159 #define DEFAULT_PROCESSOR_WAIT_STEPS 10 160 #endif 161 110 162 #endif /* AP_MPM_DEFAULT_H */ -
server/mpm/experimental/peruser/mpm.h
old new 84 84 #define AP_MPM_USES_POD 1 85 85 #define MPM_CHILD_PID(i) (ap_scoreboard_image->parent[i].pid) 86 86 #define MPM_NOTE_CHILD_KILLED(i) (MPM_CHILD_PID(i) = 0) 87 #define MPM_VALID_PID(p) (getpgid(p) == getpgrp()) 87 88 #define MPM_ACCEPT_FUNC unixd_accept 88 89 89 90 extern int ap_threads_per_child; -
server/mpm/experimental/peruser/peruser.c
old new 195 195 196 196 #define CHILD_STATUS_STANDBY 0 /* wait for a request before starting */ 197 197 #define CHILD_STATUS_STARTING 1 /* wait for socket creation */ 198 #define CHILD_STATUS_READY 2 /* wait for mux to restart*/199 #define CHILD_STATUS_ACTIVE 3 /* ready to takerequests */198 #define CHILD_STATUS_READY 2 /* is ready to take requests */ 199 #define CHILD_STATUS_ACTIVE 3 /* is currently busy handling requests */ 200 200 #define CHILD_STATUS_RESTART 4 /* child about to die and restart */ 201 201 202 /* cgroup settings */ 203 #define CGROUP_TASKS_FILE "/tasks" 204 #define CGROUP_TASKS_FILE_LEN 7 205 202 206 /* config globals */ 203 207 204 208 int ap_threads_per_child=0; /* Worker threads per child */ 205 209 static apr_proc_mutex_t *accept_mutex; 206 210 static int ap_min_processors=DEFAULT_MIN_PROCESSORS; 207 211 static int ap_min_free_processors=DEFAULT_MIN_FREE_PROCESSORS; 212 static int ap_max_free_processors=DEFAULT_MAX_FREE_PROCESSORS; 208 213 static int ap_max_processors=DEFAULT_MAX_PROCESSORS; 214 static int ap_min_multiplexers=DEFAULT_MIN_MULTIPLEXERS; 215 static int ap_max_multiplexers=DEFAULT_MAX_MULTIPLEXERS; 209 216 static int ap_daemons_limit=0; /* MaxClients */ 210 static int expire_timeout=1800; 211 static int idle_timeout=900; 217 static int expire_timeout=DEFAULT_EXPIRE_TIMEOUT; 218 static int idle_timeout=DEFAULT_IDLE_TIMEOUT; 219 static int multiplexer_idle_timeout=DEFAULT_MULTIPLEXER_IDLE_TIMEOUT; 220 static int processor_wait_timeout=DEFAULT_PROCESSOR_WAIT_TIMEOUT; 221 static int processor_wait_steps=DEFAULT_PROCESSOR_WAIT_STEPS; 212 222 static int server_limit = DEFAULT_SERVER_LIMIT; 213 223 static int first_server_limit; 214 224 static int changed_limit_at_restart; … … 222 232 { 223 233 int processor_id; 224 234 235 const char *name; /* Server environment's unique string identifier */ 236 225 237 /* security settings */ 226 238 uid_t uid; /* user id */ 227 239 gid_t gid; /* group id */ 228 240 const char *chroot; /* directory to chroot() to, can be null */ 241 int nice_lvl; 242 const char *cgroup; /* cgroup directory, can be null */ 229 243 230 244 /* resource settings */ 231 245 int min_processors; 232 246 int min_free_processors; 247 int max_free_processors; 233 248 int max_processors; 249 int availability; 234 250 235 251 /* sockets */ 236 252 int input; /* The socket descriptor */ … … 437 453 return "UNKNOWN"; 438 454 } 439 455 456 char* scoreboard_status_string(int status) { 457 switch(status) 458 { 459 case SERVER_DEAD: return "DEAD"; 460 case SERVER_STARTING: return "STARTING"; 461 case SERVER_READY: return "READY"; 462 case SERVER_BUSY_READ: return "BUSY_READ"; 463 case SERVER_BUSY_WRITE: return "BUSY_WRITE"; 464 case SERVER_BUSY_KEEPALIVE: return "BUSY_KEEPALIVE"; 465 case SERVER_BUSY_LOG: return "BUSY_LOG"; 466 case SERVER_BUSY_DNS: return "BUSY_DNS"; 467 case SERVER_CLOSING: return "CLOSING"; 468 case SERVER_GRACEFUL: return "GRACEFUL"; 469 case SERVER_NUM_STATUS: return "NUM_STATUS"; 470 } 471 472 return "UNKNOWN"; 473 } 474 440 475 void dump_child_table() 441 476 { 442 477 #ifdef MPM_PERUSER_DEBUG … … 511 546 512 547 static void accept_mutex_on(void) 513 548 { 514 /* for some reason this fails if we listen on the pipe_of_death.515 fortunately I don't think we currently need it */516 517 #if 0518 549 apr_status_t rv = apr_proc_mutex_lock(accept_mutex); 519 550 if (rv != APR_SUCCESS) { 520 551 const char *msg = "couldn't grab the accept mutex"; … … 529 560 exit(APEXIT_CHILDFATAL); 530 561 } 531 562 } 532 #endif533 563 } 534 564 535 565 static void accept_mutex_off(void) 536 566 { 537 #if 0538 567 apr_status_t rv = apr_proc_mutex_unlock(accept_mutex); 539 568 if (rv != APR_SUCCESS) { 540 569 const char *msg = "couldn't release the accept mutex"; … … 552 581 exit(APEXIT_CHILDFATAL); 553 582 } 554 583 } 555 #endif556 584 } 557 585 558 586 /* On some architectures it's safe to do unserialized accept()s in the single … … 715 743 ret = apr_socket_recv(lr->sd, &pipe_read_char, &n); 716 744 if (APR_STATUS_IS_EAGAIN(ret)) 717 745 { 718 /* It lost the lottery. It must continue to suffer 719 * through a life of servitude. */ 746 /* It lost the lottery. It must continue to suffer 747 * through a life of servitude. */ 748 _DBG("POD read EAGAIN"); 749 return ret; 720 750 } 721 751 else 722 752 { … … 1087 1117 for(i = 0, total = 0; i < NUM_CHILDS; ++i) 1088 1118 { 1089 1119 if(CHILD_INFO_TABLE[i].senv == CHILD_INFO_TABLE[child_num].senv && 1090 (SCOREBOARD_STATUS(i) == SERVER_STARTING || 1091 SCOREBOARD_STATUS(i) == SERVER_READY)) 1120 (CHILD_INFO_TABLE[i].status == CHILD_STATUS_READY)) 1092 1121 { 1093 1122 total++; 1094 1123 } … … 1116 1145 apr_bucket *bucket; 1117 1146 const apr_array_header_t *headers_in_array; 1118 1147 const apr_table_entry_t *headers_in; 1119 int counter ;1148 int counter, wait_time, wait_step_size; 1120 1149 1121 1150 apr_socket_t *thesock = ap_get_module_config(r->connection->conn_config, &core_module); 1122 1151 … … 1137 1166 apr_table_get(r->headers_in, "Host"), my_child_num, processor->senv->output); 1138 1167 _DBG("r->the_request=\"%s\" len=%d", r->the_request, strlen(r->the_request)); 1139 1168 1140 ap_get_brigade(r->connection->input_filters, bb, AP_MODE_EXHAUSTIVE, APR_NONBLOCK_READ, len);1169 wait_step_size = 100 / processor_wait_steps; 1141 1170 1142 /* Scan the brigade looking for heap-buckets */ 1171 /* Check if the processor is available */ 1172 if (total_processors(processor->id) == processor->senv->max_processors && 1173 idle_processors(processor->id) == 0) { 1174 /* The processor is currently busy, try to wait (a little) */ 1175 _DBG("processor seems to be busy, trying to wait for it"); 1176 1177 if (processor->senv->availability == 0) { 1178 processor->senv->availability = 0; 1179 1180 _DBG("processor is very busy (availability = 0) - not passing request"); 1181 1182 ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ap_server_conf, 1183 "Too many requests for processor %s, increase MaxProcessors", processor->senv->name); 1184 1185 /* No point in waiting for the processor, it's very busy */ 1186 return -1; 1187 } 1188 1189 /* We sleep a little (depending how available the processor usually is) */ 1190 int i; 1191 1192 wait_time = (processor_wait_timeout / processor_wait_steps) * 1000000; 1193 1194 for(i = 0; i <= processor->senv->availability; i += wait_step_size) { 1195 usleep(wait_time); 1143 1196 1197 /* Check if the processor is ready */ 1198 if (total_processors(processor->id) < processor->senv->max_processors || 1199 idle_processors(processor->id) > 0) { 1200 /* The processor has freed - lets use it */ 1201 _DBG("processor freed before wait time expired"); 1202 break; 1203 } 1204 } 1205 1206 if (processor->senv->availability <= wait_step_size) { 1207 processor->senv->availability = 0; 1208 } 1209 else processor->senv->availability -= wait_step_size; 1210 1211 /* Check if we waited all the time */ 1212 if (i > processor->senv->availability) { 1213 _DBG("processor is busy - not passing request (availability = %d)", 1214 processor->senv->availability); 1215 ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ap_server_conf, 1216 "Too many requests for processor %s, increase MaxProcessors", processor->senv->name); 1217 return -1; 1218 } 1219 1220 /* We could increase the availability a little here, 1221 * because the processor got freed eventually 1222 */ 1223 } 1224 else { 1225 /* Smoothly increment the availability back to 100 */ 1226 if (processor->senv->availability >= 100-wait_step_size) { 1227 processor->senv->availability = 100; 1228 } 1229 else processor->senv->availability += wait_step_size; 1230 } 1231 1232 ap_get_brigade(r->connection->input_filters, bb, AP_MODE_EXHAUSTIVE, APR_NONBLOCK_READ, len); 1233 1234 /* Scan the brigade looking for heap-buckets */ 1235 1144 1236 _DBG("Scanning the brigade",0); 1145 1237 bucket = APR_BRIGADE_FIRST(bb); 1146 1238 while (bucket != APR_BRIGADE_SENTINEL(bb) && … … 1294 1386 /* -- receive data from socket -- */ 1295 1387 apr_os_sock_get(&ctrl_sock_fd, lr->sd); 1296 1388 _DBG("receiving from sock_fd=%d", ctrl_sock_fd); 1297 ret = recvmsg(ctrl_sock_fd, &msg, 0);1298 1389 1299 if(ret == -1) 1300 _DBG("recvmsg failed with error \"%s\"", strerror(errno)); 1301 else 1302 _DBG("recvmsg returned %d", ret); 1390 // Don't block 1391 ret = recvmsg(ctrl_sock_fd, &msg, MSG_DONTWAIT); 1392 1393 if (ret == -1 && errno == EAGAIN) { 1394 _DBG("receive_from_multiplexer recvmsg() EAGAIN, someone was faster"); 1395 1396 return APR_EAGAIN; 1397 } 1398 else if (ret == -1) { 1399 _DBG("recvmsg failed with error \"%s\"", strerror(errno)); 1400 1401 // Error, better kill this child to be on the safe side 1402 return APR_EGENERAL; 1403 } 1404 else _DBG("recvmsg returned %d", ret); 1303 1405 1304 1406 /* -- extract socket from the cmsg -- */ 1305 1407 memcpy(&trans_sock_fd, CMSG_DATA(cmsg), sizeof(trans_sock_fd)); … … 1399 1501 return 0; 1400 1502 } 1401 1503 1402 static int peruser_setup_child(int childnum) 1504 static int peruser_setup_cgroup(int childnum, server_env_t *senv, apr_pool_t *pool) 1505 { 1506 apr_file_t *file; 1507 int length; 1508 apr_size_t content_len; 1509 char *tasks_file, *content, *pos; 1510 1511 _DBG("starting to add pid to cgroup %s", senv->cgroup); 1512 1513 length = strlen(senv->cgroup) + CGROUP_TASKS_FILE_LEN; 1514 tasks_file = malloc(length); 1515 1516 if (!tasks_file) return -1; 1517 1518 pos = apr_cpystrn(tasks_file, senv->cgroup, length); 1519 apr_cpystrn(pos, CGROUP_TASKS_FILE, CGROUP_TASKS_FILE_LEN); 1520 1521 /* Prepare the data to be written to tasks file */ 1522 content = apr_itoa(pool, ap_my_pid); 1523 content_len = strlen(content); 1524 1525 _DBG("writing pid %s to tasks file %s", content, tasks_file); 1526 1527 if (apr_file_open(&file, tasks_file, APR_WRITE, APR_OS_DEFAULT, pool)) { 1528 ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL, 1529 "cgroup: unable to open file %s", 1530 tasks_file); 1531 free(tasks_file); 1532 return OK; /* don't fail if cgroup not available */ 1533 } 1534 1535 if (apr_file_write(file, content, &content_len)) { 1536 ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL, 1537 "cgroup: unable to write pid to file %s", 1538 tasks_file); 1539 } 1540 1541 apr_file_close(file); 1542 1543 free(tasks_file); 1544 1545 return OK; 1546 } 1547 1548 static int peruser_setup_child(int childnum, apr_pool_t *pool) 1403 1549 { 1404 1550 server_env_t *senv = CHILD_INFO_TABLE[childnum].senv; 1405 1551 1552 if (senv->nice_lvl != 0) { 1553 nice(senv->nice_lvl); 1554 } 1555 1406 1556 if(senv->chroot) { 1407 1557 _DBG("chdir to %s", senv->chroot); 1408 1558 if(chdir(senv->chroot)) { … … 1421 1571 } 1422 1572 } 1423 1573 1574 if(senv->cgroup) { 1575 peruser_setup_cgroup(childnum, senv, pool); 1576 } 1577 1424 1578 if (senv->uid == -1 && senv->gid == -1) { 1425 1579 return unixd_setup_child(); 1426 1580 } … … 1594 1748 { 1595 1749 case CHILD_TYPE_MULTIPLEXER: 1596 1750 _DBG("MULTIPLEXER %d", my_child_num); 1597 1598 /* update status on processors that are ready to accept requests */1599 _DBG("updating processor stati", 0);1600 for(i = 0; i < NUM_CHILDS; ++i)1601 {1602 if(CHILD_INFO_TABLE[i].status == CHILD_STATUS_READY)1603 CHILD_INFO_TABLE[i].status = CHILD_STATUS_ACTIVE;1604 }1605 1606 1751 break; 1607 1752 1608 1753 case CHILD_TYPE_PROCESSOR: … … 1626 1771 apr_os_sock_put(&pod_sock, &fd, pconf); 1627 1772 listen_add(pconf, pod_sock, check_pipe_of_death); 1628 1773 1629 if(peruser_setup_child(my_child_num ) != 0)1774 if(peruser_setup_child(my_child_num, pchild) != 0) 1630 1775 clean_child_exit(APEXIT_CHILDFATAL); 1631 1776 1632 1777 ap_run_child_init(pchild, ap_server_conf); … … 1670 1815 clean_child_exit(0); 1671 1816 } 1672 1817 1673 (void) ap_update_child_status(sbh, SERVER_READY, (request_rec *) NULL); 1818 (void) ap_update_child_status(sbh, SERVER_READY, (request_rec *) NULL); 1819 1820 CHILD_INFO_TABLE[my_child_num].status = CHILD_STATUS_READY; 1821 _DBG("Child %d (%s) is now ready", my_child_num, child_type_string(CHILD_INFO_TABLE[my_child_num].type)); 1674 1822 1675 1823 /* 1676 1824 * Wait for an acceptable connection to arrive. 1677 1825 */ 1678 1826 1679 /* Lock around "accept", if necessary */ 1680 SAFE_ACCEPT(accept_mutex_on()); 1827 /* Lock around "accept", if necessary */ 1828 if (CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_MULTIPLEXER) { 1829 SAFE_ACCEPT(accept_mutex_on()); 1830 } 1681 1831 1682 1832 if (num_listensocks == 1) { 1683 1833 offset = 0; … … 1729 1879 * defer the exit 1730 1880 */ 1731 1881 status = listensocks[offset].accept_func((void *)&sock, &listensocks[offset], ptrans); 1732 SAFE_ACCEPT(accept_mutex_off()); /* unlock after "accept" */ 1882 1883 if (CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_MULTIPLEXER) { 1884 SAFE_ACCEPT(accept_mutex_off()); /* unlock after "accept" */ 1885 } 1733 1886 1734 1887 if (status == APR_EGENERAL) { 1735 1888 /* resource shortage or should-not-occur occured */ 1736 1889 clean_child_exit(1); 1737 1890 } 1738 else if (status != APR_SUCCESS || die_now ) {1891 else if (status != APR_SUCCESS || die_now || sock == NULL) { 1739 1892 continue; 1740 1893 } 1741 1894 1895 if (CHILD_INFO_TABLE[my_child_num].status == CHILD_STATUS_READY) { 1896 CHILD_INFO_TABLE[my_child_num].status = CHILD_STATUS_ACTIVE; 1897 _DBG("Child %d (%s) is now active", my_child_num, child_type_string(CHILD_INFO_TABLE[my_child_num].type)); 1898 } 1899 1742 1900 if (CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_PROCESSOR || 1743 CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_WORKER) 1901 CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_WORKER || 1902 CHILD_INFO_TABLE[my_child_num].type == CHILD_TYPE_MULTIPLEXER) 1744 1903 { 1745 1904 _DBG("CHECKING IF WE SHOULD CLONE A CHILD..."); 1746 1905 … … 1754 1913 1755 1914 if(total_processors(my_child_num) < 1756 1915 CHILD_INFO_TABLE[my_child_num].senv->max_processors && 1757 idle_processors(my_child_num) <= 1758 CHILD_INFO_TABLE[my_child_num].senv->min_free_processors) 1916 (idle_processors(my_child_num) <= 1917 CHILD_INFO_TABLE[my_child_num].senv->min_free_processors || 1918 total_processors(my_child_num) < 1919 CHILD_INFO_TABLE[my_child_num].senv->min_processors 1920 )) 1759 1921 { 1760 1922 _DBG("CLONING CHILD"); 1761 1923 child_clone(); … … 1804 1966 clean_child_exit(0); 1805 1967 } 1806 1968 1807 static server_env_t* senv_add(int uid, int gid, const char* chroot) 1808 { 1969 static server_env_t* find_senv_by_name(const char *name) { 1809 1970 int i; 1810 int socks[2];1811 1971 1812 _DBG("Searching for matching senv..."); 1972 if (name == NULL) return NULL; 1973 1974 _DBG("name=%s", name); 1975 1976 for(i = 0; i < NUM_SENV; i++) 1977 { 1978 if(SENV[i].name != NULL && !strcmp(SENV[i].name, name)) { 1979 return &SENV[i]; 1980 } 1981 } 1982 1983 return NULL; 1984 } 1985 1986 static server_env_t* find_matching_senv(server_env_t* senv) { 1987 int i; 1988 1989 _DBG("name=%s uid=%d gid=%d chroot=%s", senv->name, senv->uid, senv->gid, senv->chroot); 1813 1990 1814 1991 for(i = 0; i < NUM_SENV; i++) 1815 {1816 if(SENV[i].uid == uid && SENV[i].gid == gid &&1817 (SENV[i].chroot == NULL || !strcmp(SENV[i].chroot, chroot)))1818 1992 { 1819 _DBG("Found existing senv: %i", i); 1820 return &SENV[i]; 1993 if((senv->name != NULL && SENV[i].name != NULL && !strcmp(SENV[i].name, senv->name)) || 1994 (senv->name == NULL && SENV[i].uid == senv->uid && SENV[i].gid == senv->gid && 1995 ( 1996 (SENV[i].chroot == NULL && senv->chroot == NULL) || 1997 ((SENV[i].chroot != NULL || senv->chroot != NULL) && !strcmp(SENV[i].chroot, senv->chroot))) 1998 ) 1999 ) { 2000 return &SENV[i]; 2001 } 1821 2002 } 2003 2004 return NULL; 2005 } 2006 2007 static server_env_t* senv_add(server_env_t *senv) 2008 { 2009 int socks[2]; 2010 server_env_t *old_senv; 2011 2012 _DBG("Searching for matching senv..."); 2013 2014 old_senv = find_matching_senv(senv); 2015 2016 if (old_senv) { 2017 _DBG("Found existing senv"); 2018 senv = old_senv; 2019 return old_senv; 1822 2020 } 1823 2021 1824 2022 if(NUM_SENV >= server_limit) 1825 {1826 _DBG("server_limit reached!");1827 return NULL;1828 }2023 { 2024 _DBG("server_limit reached!"); 2025 return NULL; 2026 } 1829 2027 1830 2028 _DBG("Creating new senv"); 1831 2029 1832 SENV[NUM_SENV].uid = uid; 1833 SENV[NUM_SENV].gid = gid; 1834 SENV[NUM_SENV].chroot = chroot; 1835 1836 SENV[NUM_SENV].min_processors = ap_min_processors; 1837 SENV[NUM_SENV].min_free_processors = ap_min_free_processors; 1838 SENV[NUM_SENV].max_processors = ap_max_processors; 2030 memcpy(&SENV[NUM_SENV], senv, sizeof(server_env_t)); 2031 2032 SENV[NUM_SENV].availability = 100; 1839 2033 1840 2034 socketpair(PF_UNIX, SOCK_STREAM, 0, socks); 1841 2035 SENV[NUM_SENV].input = socks[0]; 1842 2036 SENV[NUM_SENV].output = socks[1]; 1843 2037 2038 senv = &SENV[NUM_SENV]; 1844 2039 return &SENV[server_env_image->control->num++]; 1845 2040 } 1846 2041 2042 1847 2043 static const char* child_clone() 1848 2044 { 1849 2045 int i; … … 1869 2065 new = &CHILD_INFO_TABLE[i]; 1870 2066 1871 2067 new->senv = this->senv; 1872 new->type = CHILD_TYPE_WORKER; 2068 2069 if (this->type == CHILD_TYPE_MULTIPLEXER) { 2070 new->type = CHILD_TYPE_MULTIPLEXER; 2071 } 2072 else { 2073 new->type = CHILD_TYPE_WORKER; 2074 } 2075 1873 2076 new->sock_fd = this->sock_fd; 1874 2077 new->status = CHILD_STATUS_STARTING; 1875 2078 … … 1878 2081 } 1879 2082 1880 2083 static const char* child_add(int type, int status, 1881 apr_pool_t *pool, uid_t uid, gid_t gid, const char* chroot)2084 apr_pool_t *pool, server_env_t *senv) 1882 2085 { 1883 2086 _DBG("adding child #%d", NUM_CHILDS); 1884 2087 … … 1888 2091 "Increase NumServers in your config file."; 1889 2092 } 1890 2093 1891 if ( chroot && !ap_is_directory(pool,chroot))1892 return apr_psprintf(pool, "Error: chroot directory [%s] does not exist", chroot);2094 if (senv->chroot && !ap_is_directory(pool, senv->chroot)) 2095 return apr_psprintf(pool, "Error: chroot directory [%s] does not exist", senv->chroot); 1893 2096 1894 CHILD_INFO_TABLE[NUM_CHILDS].senv = senv_add( uid, gid, chroot);2097 CHILD_INFO_TABLE[NUM_CHILDS].senv = senv_add(senv); 1895 2098 1896 2099 if(CHILD_INFO_TABLE[NUM_CHILDS].senv == NULL) 1897 2100 { … … 1907 2110 CHILD_INFO_TABLE[NUM_CHILDS].status = status; 1908 2111 1909 2112 _DBG("[%d] uid=%d gid=%d type=%d chroot=%s", 1910 NUM_CHILDS, uid,gid, type,1911 chroot);2113 NUM_CHILDS, senv->uid, senv->gid, type, 2114 senv->chroot); 1912 2115 1913 if ( uid == 0 ||gid == 0)2116 if (senv->uid == 0 || senv->gid == 0) 1914 2117 { 1915 2118 _DBG("Assigning root user/group to a child.", 0); 1916 2119 } … … 1957 2160 (void) ap_update_child_status_from_indexes(slot, 0, SERVER_STARTING, 1958 2161 (request_rec *) NULL); 1959 2162 1960 CHILD_INFO_TABLE[slot].status = CHILD_STATUS_ ACTIVE;2163 CHILD_INFO_TABLE[slot].status = CHILD_STATUS_READY; 1961 2164 1962 2165 1963 2166 #ifdef _OSD_POSIX … … 2062 2265 if(CHILD_INFO_TABLE[i].status == CHILD_STATUS_STARTING) 2063 2266 make_child(ap_server_conf, i); 2064 2267 } 2065 else if(((CHILD_INFO_TABLE[i].type == CHILD_TYPE_PROCESSOR || 2066 CHILD_INFO_TABLE[i].type == CHILD_TYPE_WORKER) && 2067 ap_scoreboard_image->parent[i].pid > 1) && 2068 (idle_processors (i) > 1 || total_processes (i) == 1) && ( 2069 (expire_timeout > 0 && ap_scoreboard_image->servers[i][0].status != SERVER_DEAD && 2070 apr_time_sec(now - ap_scoreboard_image->servers[i][0].last_used) > expire_timeout) || 2071 (idle_timeout > 0 && ap_scoreboard_image->servers[i][0].status == SERVER_READY && 2072 apr_time_sec(now - ap_scoreboard_image->servers[i][0].last_used) > idle_timeout))) 2268 else if( 2269 (((CHILD_INFO_TABLE[i].type == CHILD_TYPE_PROCESSOR || 2270 CHILD_INFO_TABLE[i].type == CHILD_TYPE_WORKER) && 2271 ap_scoreboard_image->parent[i].pid > 1) && 2272 (idle_processors (i) > CHILD_INFO_TABLE[i].senv->min_free_processors || CHILD_INFO_TABLE[i].senv->min_free_processors == 0) && 2273 total_processes (i) > CHILD_INFO_TABLE[i].senv->min_processors && 2274 ( 2275 (expire_timeout > 0 && ap_scoreboard_image->servers[i][0].status != SERVER_DEAD && 2276 apr_time_sec(now - ap_scoreboard_image->servers[i][0].last_used) > expire_timeout) || 2277 (idle_timeout > 0 && ap_scoreboard_image->servers[i][0].status == SERVER_READY && 2278 apr_time_sec(now - ap_scoreboard_image->servers[i][0].last_used) > idle_timeout) || 2279 (CHILD_INFO_TABLE[i].senv->max_free_processors > 0 && CHILD_INFO_TABLE[i].status == CHILD_STATUS_READY && 2280 idle_processors(i) > CHILD_INFO_TABLE[i].senv->max_free_processors)) 2281 ) 2282 || (CHILD_INFO_TABLE[i].type == CHILD_TYPE_MULTIPLEXER && 2283 (multiplexer_idle_timeout > 0 && ap_scoreboard_image->servers[i][0].status == SERVER_READY && 2284 apr_time_sec(now - ap_scoreboard_image->servers[i][0].last_used) > multiplexer_idle_timeout) && 2285 total_processors(i) > CHILD_INFO_TABLE[i].senv->min_processors 2286 ) 2287 ) 2073 2288 { 2074 2289 CHILD_INFO_TABLE[i].pid = 0; 2075 2290 CHILD_INFO_TABLE[i].status = CHILD_STATUS_STANDBY; 2076 2291 2077 if(CHILD_INFO_TABLE[i].type == CHILD_TYPE_WORKER )2292 if(CHILD_INFO_TABLE[i].type == CHILD_TYPE_WORKER || CHILD_INFO_TABLE[i].type == CHILD_TYPE_MULTIPLEXER) 2078 2293 { 2079 2294 /* completely free up this slot */ 2080 2295 … … 2173 2388 return 1; 2174 2389 } 2175 2390 2176 #if 02177 2391 #if APR_USE_SYSVSEM_SERIALIZE 2178 2392 if (ap_accept_lock_mech == APR_LOCK_DEFAULT || 2179 2393 ap_accept_lock_mech == APR_LOCK_SYSVSEM) { … … 2189 2403 return 1; 2190 2404 } 2191 2405 } 2192 #endif2193 2406 2194 2407 if (!is_graceful) { 2195 2408 if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) { … … 2598 2811 ap_listen_pre_config(); 2599 2812 ap_min_processors = DEFAULT_MIN_PROCESSORS; 2600 2813 ap_min_free_processors = DEFAULT_MIN_FREE_PROCESSORS; 2814 ap_max_free_processors = DEFAULT_MAX_FREE_PROCESSORS; 2601 2815 ap_max_processors = DEFAULT_MAX_PROCESSORS; 2816 ap_min_multiplexers = DEFAULT_MIN_MULTIPLEXERS; 2817 ap_max_multiplexers = DEFAULT_MAX_MULTIPLEXERS; 2602 2818 ap_daemons_limit = server_limit; 2603 2819 ap_pid_fname = DEFAULT_PIDLOG; 2604 2820 ap_lock_fname = DEFAULT_LOCKFILE; … … 2608 2824 ap_max_mem_free = APR_ALLOCATOR_MAX_FREE_UNLIMITED; 2609 2825 #endif 2610 2826 2827 expire_timeout = DEFAULT_EXPIRE_TIMEOUT; 2828 idle_timeout = DEFAULT_IDLE_TIMEOUT; 2829 multiplexer_idle_timeout = DEFAULT_MULTIPLEXER_IDLE_TIMEOUT; 2830 processor_wait_timeout = DEFAULT_PROCESSOR_WAIT_TIMEOUT; 2831 processor_wait_steps = DEFAULT_PROCESSOR_WAIT_STEPS; 2832 2833 2611 2834 apr_cpystrn(ap_coredump_dir, ap_server_root, sizeof(ap_coredump_dir)); 2612 2835 2613 2836 /* we need to know ServerLimit and ThreadLimit before we start processing … … 2709 2932 server_env_image->control = (server_env_control*)shmem; 2710 2933 shmem += sizeof(server_env_control*); 2711 2934 server_env_image->table = (server_env_t*)shmem; 2935 } 2712 2936 2937 if(restart_num <= 2) { 2938 _DBG("Cleaning server environments table"); 2939 2713 2940 server_env_image->control->num = 0; 2714 2715 for (i = 0; i < tmp_server_limit; i++) 2716 { 2941 for (i = 0; i < tmp_server_limit; i++) { 2717 2942 SENV[i].processor_id = -1; 2718 2943 SENV[i].uid = -1; 2719 2944 SENV[i].gid = -1; … … 2781 3006 if (pass_request(r, processor) == -1) 2782 3007 { 2783 3008 ap_log_error(APLOG_MARK, APLOG_ERR, 0, 2784 ap_server_conf, "Could not pass request to proper " "child, request will not be honoured.");2785 return DECLINED;3009 ap_server_conf, "Could not pass request to processor %s (virtualhost %s), request will not be honoured.", 3010 processor->senv->name, r->hostname); 2786 3011 } 2787 3012 _DBG("doing longjmp",0); 2788 3013 longjmp(CHILD_INFO_TABLE[my_child_num].jmpbuffer, 1); … … 2859 3084 ap_rputs("<hr>\n", r); 2860 3085 ap_rputs("<h2>peruser status</h2>\n", r); 2861 3086 ap_rputs("<table border=\"0\">\n", r); 2862 ap_rputs("<tr><td>ID</td><td>PID</td><td>STATUS</td><td> TYPE</td><td>UID</td>"2863 "<td>GID</td><td>CHROOT</td><td> INPUT</td>"3087 ap_rputs("<tr><td>ID</td><td>PID</td><td>STATUS</td><td>SB STATUS</td><td>TYPE</td><td>UID</td>" 3088 "<td>GID</td><td>CHROOT</td><td>NICE</td><td>INPUT</td>" 2864 3089 "<td>OUTPUT</td><td>SOCK_FD</td>" 2865 3090 "<td>TOTAL PROCESSORS</td><td>MAX PROCESSORS</td>" 2866 "<td>IDLE PROCESSORS</td><td>MIN FREE PROCESSORS</td></tr>\n", r); 3091 "<td>IDLE PROCESSORS</td><td>MIN FREE PROCESSORS</td>" 3092 "<td>AVAIL</td>" 3093 "</tr>\n", r); 2867 3094 for (x = 0; x < NUM_CHILDS; x++) 2868 3095 { 2869 3096 senv = CHILD_INFO_TABLE[x].senv; 2870 ap_rprintf(r, "<tr><td>%3d</td><td>%5d</td><td>%8s</td><td>% 12s</td>"2871 "<td>%4d</td><td>%4d</td><td>%25s</td><td>% 5d</td>"3097 ap_rprintf(r, "<tr><td>%3d</td><td>%5d</td><td>%8s</td><td>%8s</td><td>%12s</td>" 3098 "<td>%4d</td><td>%4d</td><td>%25s</td><td>%3d</td><td>%5d</td>" 2872 3099 "<td>%6d</td><td>%7d</td><td>%d</td><td>%d</td>" 2873 "<td>%d</td><td>%d</td>< /tr>\n",3100 "<td>%d</td><td>%d</td><td>%3d</td></tr>\n", 2874 3101 CHILD_INFO_TABLE[x].id, 2875 3102 CHILD_INFO_TABLE[x].pid, 2876 3103 child_status_string(CHILD_INFO_TABLE[x].status), 3104 scoreboard_status_string(SCOREBOARD_STATUS(x)), 2877 3105 child_type_string(CHILD_INFO_TABLE[x].type), 2878 3106 senv == NULL ? -1 : senv->uid, 2879 3107 senv == NULL ? -1 : senv->gid, 2880 3108 senv == NULL ? NULL : senv->chroot, 3109 senv == NULL ? 0 : senv->nice_lvl, 2881 3110 senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->input, 2882 3111 senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->output, 2883 3112 CHILD_INFO_TABLE[x].sock_fd, 2884 3113 total_processors(x), 2885 3114 senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->max_processors, 2886 3115 idle_processors(x), 2887 senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->min_free_processors 3116 senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->min_free_processors, 3117 senv == NULL ? -1 : CHILD_INFO_TABLE[x].senv->availability 2888 3118 ); 2889 3119 } 2890 3120 ap_rputs("</table>\n", r); … … 2938 3168 APR_OPTIONAL_HOOK(ap, status_hook, peruser_status_hook, NULL, NULL, APR_HOOK_MIDDLE); 2939 3169 } 2940 3170 2941 /* we define an Processor w/ specific uid/gid */ 2942 static const char *cf_Processor(cmd_parms *cmd, void *dummy, 2943 const char *user_name, const char *group_name, const char *chroot) 3171 static const char *cf_Processor(cmd_parms *cmd, void *dummy, const char *arg) 2944 3172 { 2945 uid_t uid = ap_uname2id(user_name); 2946 gid_t gid = ap_gname2id(group_name); 3173 const char *user_name = NULL, *group_name = NULL, *directive; 3174 server_env_t senv; 3175 ap_directive_t *current; 3176 3177 const char *endp = ap_strrchr_c(arg, '>'); 3178 3179 if (endp == NULL) { 3180 return apr_psprintf(cmd->temp_pool, 3181 "Error: Directive %s> missing closing '>'", cmd->cmd->name); 3182 } 3183 3184 arg = apr_pstrndup(cmd->pool, arg, endp - arg); 3185 3186 if (!arg) { 3187 return apr_psprintf(cmd->temp_pool, 3188 "Error: %s> must specify a processor name", cmd->cmd->name); 3189 } 3190 3191 senv.name = ap_getword_conf(cmd->pool, &arg); 3192 _DBG("processor_name: %s", senv.name); 3193 3194 if (strlen(senv.name) == 0) { 3195 return apr_psprintf(cmd->temp_pool, 3196 "Error: Directive %s> takes one argument", cmd->cmd->name); 3197 } 3198 3199 /* Check for existing processors on first launch and between gracefuls */ 3200 if (restart_num == 1 || is_graceful) { 3201 server_env_t *old_senv = find_senv_by_name(senv.name); 3202 3203 if (old_senv) { 3204 return apr_psprintf(cmd->temp_pool, 3205 "Error: Processor %s already defined", senv.name); 3206 } 3207 } 3208 3209 senv.nice_lvl = 0; 3210 senv.chroot = NULL; 3211 senv.cgroup = NULL; 3212 senv.min_processors = ap_min_processors; 3213 senv.min_free_processors = ap_min_free_processors; 3214 senv.max_free_processors = ap_max_free_processors; 3215 senv.max_processors = ap_max_processors; 3216 3217 current = cmd->directive->first_child; 3218 3219 int proc_temp = 0; 3220 for(; current != NULL; current = current->next) { 3221 directive = current->directive; 3222 3223 if (!strcasecmp(directive, "user")) { 3224 user_name = current->args; 3225 } 3226 else if (!strcasecmp(directive, "group")) { 3227 group_name = current->args; 3228 } 3229 else if (!strcasecmp(directive, "chroot")) { 3230 senv.chroot = ap_getword_conf(cmd->pool, ¤t->args); 3231 } 3232 else if (!strcasecmp(directive, "nicelevel")) { 3233 senv.nice_lvl = atoi(current->args); 3234 } 3235 else if (!strcasecmp(directive, "maxprocessors")) { 3236 proc_temp = atoi(current->args); 3237 3238 if (proc_temp < 1) { 3239 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, 3240 "WARNING: Require MaxProcessors > 0, setting to 1"); 3241 proc_temp = 1; 3242 } 3243 3244 senv.max_processors = proc_temp; 3245 } 3246 else if (!strcasecmp(directive, "minprocessors")) { 3247 proc_temp = atoi(current->args); 3248 3249 if (proc_temp < 0) { 3250 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, 3251 "WARNING: Require MinProcessors >= 0, setting to 0"); 3252 proc_temp = 0; 3253 } 3254 3255 senv.min_processors = proc_temp; 3256 } 3257 else if (!strcasecmp(directive, "minspareprocessors")) { 3258 proc_temp = atoi(current->args); 2947 3259 2948 _DBG("user=%s:%d group=%s:%d chroot=%s", 2949 user_name, uid, group_name, gid, chroot); 3260 if (proc_temp < 0) { 3261 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, 3262 "WARNING: Require MinSpareProcessors >= 0, setting to 0"); 3263 proc_temp = 0; 3264 } 3265 3266 senv.min_free_processors = proc_temp; 3267 } 3268 else if (!strcasecmp(directive, "maxspareprocessors")) { 3269 proc_temp = atoi(current->args); 3270 3271 if (proc_temp < 0) { 3272 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, 3273 "WARNING: Require MaxSpareProcessors >= 0, setting to 0"); 3274 proc_temp = 0; 3275 } 3276 3277 senv.max_free_processors = proc_temp; 3278 } 3279 else if (!strcasecmp(directive, "cgroup")) { 3280 senv.cgroup = ap_getword_conf(cmd->pool, ¤t->args); 3281 } 3282 else { 3283 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, 3284 "Unknown directive %s in %s>", directive, cmd->cmd->name); 3285 } 3286 } 3287 3288 if (user_name == NULL || group_name == NULL) { 3289 return apr_psprintf(cmd->temp_pool, 3290 "Error: User or Group must be set in %s>", cmd->cmd->name); 3291 } 3292 3293 senv.uid = ap_uname2id(user_name); 3294 senv.gid = ap_gname2id(group_name); 3295 3296 _DBG("name=%s user=%s:%d group=%s:%d chroot=%s nice_lvl=%d", 3297 senv.name, user_name, senv.uid, group_name, senv.gid, senv.chroot, senv.nice_lvl); 3298 3299 _DBG("min_processors=%d min_free_processors=%d max_spare_processors=%d max_processors=%d", 3300 senv.min_processors, senv.min_free_processors, senv.max_free_processors, senv.max_processors); 2950 3301 2951 3302 return child_add(CHILD_TYPE_PROCESSOR, CHILD_STATUS_STANDBY, 2952 cmd->pool, uid, gid, chroot);3303 cmd->pool, &senv); 2953 3304 } 2954 3305 2955 3306 /* we define an Multiplexer child w/ specific uid/gid */ 2956 3307 static const char *cf_Multiplexer(cmd_parms *cmd, void *dummy, 2957 3308 const char *user_name, const char *group_name, const char *chroot) 2958 3309 { 2959 uid_t uid = ap_uname2id(user_name); 2960 gid_t gid = ap_gname2id(group_name); 3310 server_env_t senv; 3311 3312 senv.name = NULL; 3313 3314 senv.uid = ap_uname2id(user_name); 3315 senv.gid = ap_gname2id(group_name); 3316 senv.nice_lvl = 0; 3317 senv.cgroup = NULL; 3318 senv.chroot = chroot; 3319 3320 senv.min_processors = ap_min_multiplexers; 3321 senv.min_free_processors = ap_min_free_processors; 3322 senv.max_free_processors = ap_max_free_processors; 3323 senv.max_processors = ap_max_multiplexers; 2961 3324 2962 3325 _DBG("user=%s:%d group=%s:%d chroot=%s [multiplexer id %d]", 2963 user_name, uid, group_name, gid,chroot, NUM_CHILDS);3326 user_name, senv.uid, group_name, senv.gid, senv.chroot, NUM_CHILDS); 2964 3327 2965 3328 return child_add(CHILD_TYPE_MULTIPLEXER, CHILD_STATUS_STARTING, 2966 cmd->pool, uid, gid, chroot);3329 cmd->pool, &senv); 2967 3330 } 2968 3331 2969 3332 static const char* cf_ServerEnvironment(cmd_parms *cmd, void *dummy, 2970 const char * user_name, const char *group_name, const char *chroot)3333 const char *name) 2971 3334 { 2972 int uid = ap_uname2id(user_name);2973 int gid = ap_gname2id(group_name);2974 3335 peruser_server_conf *sconf = PERUSER_SERVER_CONF(cmd->server->module_config); 2975 3336 2976 3337 _DBG("function entered", 0); 2977 3338 2978 if (chroot && !ap_is_directory(cmd->pool, chroot)) 2979 return apr_psprintf(cmd->pool, "Error: chroot directory [%s] does not exist", chroot); 3339 sconf->senv = find_senv_by_name(name); 2980 3340 2981 sconf->senv = senv_add(uid, gid, chroot); 3341 if (sconf->senv == NULL) { 3342 return apr_psprintf(cmd->pool, 3343 "Error: Processor %s not defined", name); 3344 } 2982 3345 2983 _DBG("user=% s:%d group=%s:%d chroot=%s numchilds=%d",2984 user_name, uid, group_name, gid,chroot, NUM_CHILDS);3346 _DBG("user=%d group=%d chroot=%s numchilds=%d", 3347 sconf->senv->uid, sconf->senv->gid, sconf->senv->chroot, NUM_CHILDS); 2985 3348 2986 3349 return NULL; 2987 3350 } … … 3046 3409 3047 3410 min_procs = atoi(arg); 3048 3411 3049 if (min_procs < 1) {3412 if (min_procs < 0) { 3050 3413 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, 3051 "WARNING: Require M axProcessors > 0, setting to 1");3052 min_procs = 1;3414 "WARNING: Require MinProcessors >= 0, setting to 0"); 3415 min_procs = 0; 3053 3416 } 3054 3417 3055 3418 if (ap_check_cmd_context(cmd, NOT_IN_VIRTUALHOST) != NULL) { … … 3075 3438 3076 3439 min_free_procs = atoi(arg); 3077 3440 3078 if (min_free_procs < 1) {3441 if (min_free_procs < 0) { 3079 3442 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, 3080 "WARNING: Require MinSpareProcessors > 0, setting to 1");3081 min_free_procs = 1;3443 "WARNING: Require MinSpareProcessors >= 0, setting to 0"); 3444 min_free_procs = 0; 3082 3445 } 3083 3446 3084 3447 if (ap_check_cmd_context(cmd, NOT_IN_VIRTUALHOST) != NULL) { … … 3092 3455 return NULL; 3093 3456 } 3094 3457 3458 static const char *set_max_free_processors (cmd_parms *cmd, void *dummy, const char *arg) 3459 { 3460 peruser_server_conf *sconf; 3461 int max_free_procs; 3462 const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); 3463 3464 if (err != NULL) { 3465 return err; 3466 } 3467 3468 max_free_procs = atoi(arg); 3469 3470 if (max_free_procs < 0) { 3471 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, 3472 "WARNING: Require MaxSpareProcessors >= 0, setting to 0"); 3473 max_free_procs = 0; 3474 } 3475 3476 if (ap_check_cmd_context(cmd, NOT_IN_VIRTUALHOST) != NULL) { 3477 sconf = PERUSER_SERVER_CONF(cmd->server->module_config); 3478 sconf->senv->max_free_processors = max_free_procs; 3479 } 3480 else { 3481 ap_max_free_processors = max_free_procs; 3482 } 3483 3484 return NULL; 3485 } 3486 3095 3487 static const char *set_max_processors (cmd_parms *cmd, void *dummy, const char *arg) 3096 3488 { 3097 3489 peruser_server_conf *sconf; … … 3121 3513 return NULL; 3122 3514 } 3123 3515 3516 static const char *set_min_multiplexers (cmd_parms *cmd, void *dummy, const char *arg) 3517 { 3518 int min_multiplexers; 3519 const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); 3520 3521 if (err != NULL) { 3522 return err; 3523 } 3524 3525 min_multiplexers = atoi(arg); 3526 3527 if (min_multiplexers < 1) { 3528 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, 3529 "WARNING: Require MinMultiplexers > 0, setting to 1"); 3530 min_multiplexers = 1; 3531 } 3532 3533 ap_min_multiplexers = min_multiplexers; 3534 3535 return NULL; 3536 } 3537 3538 static const char *set_max_multiplexers (cmd_parms *cmd, void *dummy, const char *arg) 3539 { 3540 int max_multiplexers; 3541 const char *err = ap_check_cmd_context(cmd, NOT_IN_DIR_LOC_FILE|NOT_IN_LIMIT); 3542 3543 if (err != NULL) { 3544 return err; 3545 } 3546 3547 max_multiplexers = atoi(arg); 3548 3549 if (max_multiplexers < 1) { 3550 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, 3551 "WARNING: Require MaxMultiplexers > 0, setting to 1"); 3552 max_multiplexers = 1; 3553 } 3554 3555 ap_max_multiplexers = max_multiplexers; 3556 3557 return NULL; 3558 } 3559 3124 3560 static const char *set_server_limit (cmd_parms *cmd, void *dummy, const char *arg) 3125 3561 { 3126 3562 int tmp_server_limit; … … 3183 3619 return NULL; 3184 3620 } 3185 3621 3622 static const char *set_multiplexer_idle_timeout (cmd_parms *cmd, void *dummy, const char *arg) { 3623 const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); 3624 3625 if (err != NULL) { 3626 return err; 3627 } 3628 3629 multiplexer_idle_timeout = atoi(arg); 3630 3631 return NULL; 3632 } 3633 3634 static const char *set_processor_wait_timeout (cmd_parms *cmd, void *dummy, const char *timeout, const char *steps) { 3635 const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); 3636 3637 if (err != NULL) { 3638 return err; 3639 } 3640 3641 processor_wait_timeout = atoi(timeout); 3642 3643 if (steps != NULL) { 3644 int steps_tmp = atoi(steps); 3645 3646 if (steps_tmp < 1) { 3647 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, 3648 "WARNING: Require ProcessorWaitTimeout steps > 0, setting to 1"); 3649 steps_tmp = 1; 3650 } 3651 3652 processor_wait_steps = steps_tmp; 3653 } 3654 3655 return NULL; 3656 } 3657 3186 3658 static const command_rec peruser_cmds[] = { 3187 3659 UNIX_DAEMON_COMMANDS, 3188 3660 LISTEN_COMMANDS, … … 3190 3662 "Minimum number of idle children, to handle request spikes"), 3191 3663 AP_INIT_TAKE1("MinSpareServers", set_min_free_servers, NULL, RSRC_CONF, 3192 3664 "Minimum number of idle children, to handle request spikes"), 3665 AP_INIT_TAKE1("MaxSpareProcessors", set_max_free_processors, NULL, RSRC_CONF, 3666 "Maximum number of idle children, 0 to disable"), 3193 3667 AP_INIT_TAKE1("MaxClients", set_max_clients, NULL, RSRC_CONF, 3194 3668 "Maximum number of children alive at the same time"), 3195 3669 AP_INIT_TAKE1("MinProcessors", set_min_processors, NULL, RSRC_CONF, 3196 3670 "Minimum number of processors per vhost"), 3197 3671 AP_INIT_TAKE1("MaxProcessors", set_max_processors, NULL, RSRC_CONF, 3198 3672 "Maximum number of processors per vhost"), 3673 AP_INIT_TAKE1("MinMultiplexers", set_min_multiplexers, NULL, RSRC_CONF, 3674 "Minimum number of multiplexers the server can have"), 3675 AP_INIT_TAKE1("MaxMultiplexers", set_max_multiplexers, NULL, RSRC_CONF, 3676 "Maximum number of multiplexers the server can have"), 3199 3677 AP_INIT_TAKE1("ServerLimit", set_server_limit, NULL, RSRC_CONF, 3200 3678 "Maximum value of MaxClients for this run of Apache"), 3201 3679 AP_INIT_TAKE1("ExpireTimeout", set_expire_timeout, NULL, RSRC_CONF, 3202 "Maximum idle time before a child is killed, 0 to disable"),3680 "Maximum time a child can live, 0 to disable"), 3203 3681 AP_INIT_TAKE1("IdleTimeout", set_idle_timeout, NULL, RSRC_CONF, 3204 3682 "Maximum time before a child is killed after being idle, 0 to disable"), 3683 AP_INIT_TAKE1("MultiplexerIdleTimeout", set_multiplexer_idle_timeout, NULL, RSRC_CONF, 3684 "Maximum time before a multiplexer is killed after being idle, 0 to disable"), 3685 AP_INIT_TAKE12("ProcessorWaitTimeout", set_processor_wait_timeout, NULL, RSRC_CONF, 3686 "Maximum time a multiplexer waits for the processor if it is busy"), 3205 3687 AP_INIT_TAKE23("Multiplexer", cf_Multiplexer, NULL, RSRC_CONF, 3206 3688 "Specify an Multiplexer Child configuration."), 3207 AP_INIT_ TAKE23("Processor", cf_Processor, NULL, RSRC_CONF,3208 "Specify a User and Group for a specific child process."),3209 AP_INIT_TAKE 23("ServerEnvironment", cf_ServerEnvironment, NULL, RSRC_CONF,3689 AP_INIT_RAW_ARGS("<Processor", cf_Processor, NULL, RSRC_CONF, 3690 "Specify settings for processor."), 3691 AP_INIT_TAKE1("ServerEnvironment", cf_ServerEnvironment, NULL, RSRC_CONF, 3210 3692 "Specify the server environment for this virtual host."), 3211 3693 { NULL } 3212 3694 };
