1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001
|
/* uWSGI */
/* indent -i8 -br -brs -brf -l0 -npsl -nip -npcs -npsl -di1 -il0 */
#ifdef __cplusplus
extern "C" {
#endif
#define UWSGI_PLUGIN_API 1
#define UWSGI_HAS_OFFLOAD_UBUFS 1
#define UMAX16 65536
#define UMAX8 256
#define UMAX64_STR "18446744073709551615"
#define MAX64_STR "-9223372036854775808"
#define UWSGI_END_OF_OPTIONS { NULL, 0, 0, NULL, NULL, NULL, 0},
#define uwsgi_error(x) uwsgi_log("%s: %s [%s line %d]\n", x, strerror(errno), __FILE__, __LINE__);
#define uwsgi_error_realpath(x) uwsgi_log("realpath() of %s failed: %s [%s line %d]\n", x, strerror(errno), __FILE__, __LINE__);
#define uwsgi_log_safe(x) if (uwsgi.original_log_fd != 2) dup2(uwsgi.original_log_fd, 2) ; uwsgi_log(x);
#define uwsgi_error_safe(x) if (uwsgi.original_log_fd != 2) dup2(uwsgi.original_log_fd, 2) ; uwsgi_log("%s: %s [%s line %d]\n", x, strerror(errno), __FILE__, __LINE__);
#define uwsgi_log_initial if (!uwsgi.no_initial_output) uwsgi_log
#define uwsgi_log_alarm(x, ...) uwsgi_log("[uwsgi-alarm" x, __VA_ARGS__)
#define uwsgi_fatal_error(x) uwsgi_error(x); exit(1);
#define uwsgi_error_open(x) uwsgi_log("open(\"%s\"): %s [%s line %d]\n", x, strerror(errno), __FILE__, __LINE__);
#define uwsgi_req_error(x) if (wsgi_req->uri_len > 0 && wsgi_req->method_len > 0 && wsgi_req->remote_addr_len > 0) uwsgi_log_verbose("%s: %s [%s line %d] during %.*s %.*s (%.*s)\n", x, strerror(errno), __FILE__, __LINE__,\
wsgi_req->method_len, wsgi_req->method, wsgi_req->uri_len, wsgi_req->uri, wsgi_req->remote_addr_len, wsgi_req->remote_addr); else uwsgi_log_verbose("%s %s [%s line %d] \n",x, strerror(errno), __FILE__, __LINE__);
#define uwsgi_debug(x, ...) uwsgi_log("[uWSGI DEBUG] " x, __VA_ARGS__);
#define uwsgi_rawlog(x) if (write(2, x, strlen(x)) != strlen(x)) uwsgi_error("write()")
#define uwsgi_str(x) uwsgi_concat2(x, (char *)"")
#define uwsgi_notify(x) if (uwsgi.notify) uwsgi.notify(x)
#define uwsgi_notify_ready() uwsgi.shared->ready = 1 ; if (uwsgi.notify_ready) uwsgi.notify_ready()
#define uwsgi_apps uwsgi.workers[uwsgi.mywid].apps
#define uwsgi_apps_cnt uwsgi.workers[uwsgi.mywid].apps_cnt
#define wsgi_req_time ((wsgi_req->end_of_request-wsgi_req->start_of_request)/1000)
#define thunder_lock if (!uwsgi.is_et) {\
if (uwsgi.use_thunder_lock) {\
uwsgi_lock(uwsgi.the_thunder_lock);\
}\
else if (uwsgi.threads > 1) {\
pthread_mutex_lock(&uwsgi.thunder_mutex);\
}\
}
#define thunder_unlock if (!uwsgi.is_et) {\
if (uwsgi.use_thunder_lock) {\
uwsgi_unlock(uwsgi.the_thunder_lock);\
}\
else if (uwsgi.threads > 1) {\
pthread_mutex_unlock(&uwsgi.thunder_mutex);\
}\
}
#define uwsgi_n64(x) strtoul(x, NULL, 10)
#define ushared uwsgi.shared
#define UWSGI_OPT_IMMEDIATE (1 << 0)
#define UWSGI_OPT_MASTER (1 << 1)
#define UWSGI_OPT_LOG_MASTER (1 << 2)
#define UWSGI_OPT_THREADS (1 << 3)
#define UWSGI_OPT_CHEAPER (1 << 4)
#define UWSGI_OPT_VHOST (1 << 5)
#define UWSGI_OPT_MEMORY (1 << 6)
#define UWSGI_OPT_PROCNAME (1 << 7)
#define UWSGI_OPT_LAZY (1 << 8)
#define UWSGI_OPT_NO_INITIAL (1 << 9)
#define UWSGI_OPT_NO_SERVER (1 << 10)
#define UWSGI_OPT_POST_BUFFERING (1 << 11)
#define UWSGI_OPT_CLUSTER (1 << 12)
#define UWSGI_OPT_MIME (1 << 13)
#define UWSGI_OPT_REQ_LOG_MASTER (1 << 14)
#define UWSGI_OPT_METRICS (1 << 15)
#define MAX_GENERIC_PLUGINS 128
#define MAX_GATEWAYS 64
#define MAX_TIMERS 64
#define MAX_CRONS 64
#define UWSGI_VIA_SENDFILE 1
#define UWSGI_VIA_ROUTE 2
#define UWSGI_VIA_OFFLOAD 3
#ifndef UWSGI_LOAD_EMBEDDED_PLUGINS
#define UWSGI_LOAD_EMBEDDED_PLUGINS
#endif
#ifndef UWSGI_DECLARE_EMBEDDED_PLUGINS
#define UWSGI_DECLARE_EMBEDDED_PLUGINS
#endif
#ifdef UWSGI_EMBED_CONFIG
extern char UWSGI_EMBED_CONFIG;
extern char UWSGI_EMBED_CONFIG_END;
#endif
#define UDEP(pname) extern struct uwsgi_plugin pname##_plugin;
#define ULEP(pname)\
if (pname##_plugin.request) {\
uwsgi.p[pname##_plugin.modifier1] = &pname##_plugin;\
if (uwsgi.p[pname##_plugin.modifier1]->on_load)\
uwsgi.p[pname##_plugin.modifier1]->on_load();\
}\
else {\
if (uwsgi.gp_cnt >= MAX_GENERIC_PLUGINS) {\
uwsgi_log("you have embedded too much generic plugins !!!\n");\
exit(1);\
}\
uwsgi.gp[uwsgi.gp_cnt] = &pname##_plugin;\
if (uwsgi.gp[uwsgi.gp_cnt]->on_load)\
uwsgi.gp[uwsgi.gp_cnt]->on_load();\
uwsgi.gp_cnt++;\
}\
#define fill_plugin_table(x, up)\
if (up->request) {\
uwsgi.p[x] = up;\
}\
else {\
if (uwsgi.gp_cnt >= MAX_GENERIC_PLUGINS) {\
uwsgi_log("you have embedded too much generic plugins !!!\n");\
exit(1);\
}\
uwsgi.gp[uwsgi.gp_cnt] = up;\
uwsgi.gp_cnt++;\
}\
#define uwsgi_foreach(x, y) for(x=y;x;x = x->next)
#define uwsgi_foreach_token(x, y, z, w) for(z=strtok_r(x, y, &w);z;z = strtok_r(NULL, y, &w))
#ifndef __need_IOV_MAX
#define __need_IOV_MAX
#endif
#ifdef __sun__
#ifndef _XPG4_2
#define _XPG4_2
#endif
#ifndef __EXTENSIONS__
#define __EXTENSIONS__
#endif
#endif
#if defined(__linux__) || defined(__GNUC__)
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#ifndef __USE_GNU
#define __USE_GNU
#endif
#endif
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <signal.h>
#include <math.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
#ifdef __linux__
#ifndef MSG_FASTOPEN
#define MSG_FASTOPEN 0x20000000
#endif
#endif
#include <netinet/in.h>
#include <termios.h>
#ifdef UWSGI_UUID
#include <uuid/uuid.h>
#endif
#include <string.h>
#include <sys/stat.h>
#include <netinet/tcp.h>
#ifdef __linux__
#ifndef TCP_FASTOPEN
#define TCP_FASTOPEN 23
#endif
#endif
#include <netdb.h>
#if defined(__GNU_kFreeBSD__)
#include <bsd/unistd.h>
#endif
#if defined(__FreeBSD__) || defined(__GNU_kFreeBSD__)
#include <sys/sysctl.h>
#include <sys/param.h>
#include <sys/cpuset.h>
#include <sys/jail.h>
#ifdef UWSGI_HAS_FREEBSD_LIBJAIL
#include <jail.h>
#endif
#endif
#include <sys/ipc.h>
#include <sys/sem.h>
#include <stdarg.h>
#include <errno.h>
#ifndef __USE_ISOC99
#define __USE_ISOC99
#endif
#include <ctype.h>
#include <sys/time.h>
#include <unistd.h>
#ifdef UWSGI_HAS_IFADDRS
#include <ifaddrs.h>
#endif
#include <pwd.h>
#include <grp.h>
#include <sys/utsname.h>
#ifdef __linux__
#include <sched.h>
#include <sys/prctl.h>
#include <linux/limits.h>
#endif
#if defined(__linux) || defined(__FreeBSD__) || defined(__GNU_kFreeBSD__)
#include <sys/mount.h>
#endif
#ifdef __linux__
extern int pivot_root(const char *new_root, const char *put_old);
#endif
#include <limits.h>
#include <dirent.h>
#ifndef UWSGI_PLUGIN_BASE
#define UWSGI_PLUGIN_BASE ""
#endif
#include <arpa/inet.h>
#include <sys/mman.h>
#include <sys/file.h>
#include <stdint.h>
#include <sys/wait.h>
#ifndef WAIT_ANY
#define WAIT_ANY (-1)
#endif
#ifdef __APPLE__
#ifndef MAC_OS_X_VERSION_MIN_REQUIRED
#define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4
#endif
#include <mach-o/dyld.h>
#endif
#include <dlfcn.h>
#include <poll.h>
#include <sys/uio.h>
#include <sys/un.h>
#include <fcntl.h>
#include <pthread.h>
#include <sys/resource.h>
#include <getopt.h>
#ifdef __APPLE__
#include <libkern/OSAtomic.h>
#include <mach/task.h>
#include <mach/mach_init.h>
#endif
#ifdef _POSIX_C_SOURCE
#undef _POSIX_C_SOURCE
#endif
#if defined(__sun__)
#define WAIT_ANY (-1)
#include <sys/filio.h>
#define PRIO_MAX 20
#endif
#if defined(__HAIKU__) || defined(__CYGWIN__)
#ifndef WAIT_ANY
#define WAIT_ANY (-1)
#endif
#define PRIO_MAX 20
#endif
#include <sys/ioctl.h>
#ifdef __linux__
#include <sys/sendfile.h>
#include <sys/epoll.h>
#elif defined(__GNU_kFreeBSD__)
#include <sys/sendfile.h>
#include <sys/event.h>
#elif defined(__sun__)
#include <sys/sendfile.h>
#include <sys/devpoll.h>
#elif defined(__HAIKU__)
#elif defined(__CYGWIN__)
#elif defined(__HURD__)
#else
#include <sys/event.h>
#endif
#ifdef UWSGI_CAP
#include <sys/capability.h>
#endif
#ifdef __HAIKU__
#include <kernel/OS.h>
#endif
#undef _XOPEN_SOURCE
#ifdef __sun__
#undef __EXTENSIONS__
#endif
#ifdef _GNU_SOURCE
#undef _GNU_SOURCE
#endif
#define UWSGI_CACHE_FLAG_UNGETTABLE 0x01
#define UWSGI_CACHE_FLAG_UPDATE 1 << 1
#define UWSGI_CACHE_FLAG_LOCAL 1 << 2
#define UWSGI_CACHE_FLAG_ABSEXPIRE 1 << 3
#define UWSGI_CACHE_FLAG_MATH 1 << 4
#define UWSGI_CACHE_FLAG_INC 1 << 5
#define UWSGI_CACHE_FLAG_DEC 1 << 6
#define UWSGI_CACHE_FLAG_MUL 1 << 7
#define UWSGI_CACHE_FLAG_DIV 1 << 8
#define UWSGI_CACHE_FLAG_FIXEXPIRE 1 << 9
#ifdef UWSGI_SSL
#include <openssl/conf.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#if OPENSSL_VERSION_NUMBER < 0x10100000L
#define UWSGI_SSL_SESSION_CACHE
#endif
#endif
#include <glob.h>
#ifdef __CYGWIN__
#define __WINCRYPT_H__
#include <windows.h>
#ifdef UWSGI_UUID
#undef uuid_t
#endif
#undef CMSG_DATA
#define CMSG_DATA(cmsg) \
((unsigned char *) ((struct cmsghdr *)(cmsg) + 1))
#endif
struct uwsgi_buffer {
char *buf;
size_t pos;
size_t len;
size_t limit;
#ifdef UWSGI_DEBUG_BUFFER
int freed;
#endif
};
struct uwsgi_string_list {
char *value;
size_t len;
uint64_t custom;
uint64_t custom2;
void *custom_ptr;
struct uwsgi_string_list *next;
};
struct uwsgi_custom_option {
char *name;
char *value;
int has_args;
struct uwsgi_custom_option *next;
};
struct uwsgi_lock_item {
char *id;
void *lock_ptr;
int rw;
pid_t pid;
int can_deadlock;
struct uwsgi_lock_item *next;
};
struct uwsgi_lock_ops {
struct uwsgi_lock_item *(*lock_init) (char *);
pid_t(*lock_check) (struct uwsgi_lock_item *);
void (*lock) (struct uwsgi_lock_item *);
void (*unlock) (struct uwsgi_lock_item *);
struct uwsgi_lock_item *(*rwlock_init) (char *);
pid_t(*rwlock_check) (struct uwsgi_lock_item *);
void (*rlock) (struct uwsgi_lock_item *);
void (*wlock) (struct uwsgi_lock_item *);
void (*rwunlock) (struct uwsgi_lock_item *);
};
#define uwsgi_lock_init(x) uwsgi.lock_ops.lock_init(x)
#define uwsgi_lock_check(x) uwsgi.lock_ops.lock_check(x)
#define uwsgi_lock(x) uwsgi.lock_ops.lock(x)
#define uwsgi_unlock(x) uwsgi.lock_ops.unlock(x)
#define uwsgi_rwlock_init(x) uwsgi.lock_ops.rwlock_init(x)
#define uwsgi_rwlock_check(x) uwsgi.lock_ops.rwlock_check(x)
#define uwsgi_rlock(x) uwsgi.lock_ops.rlock(x)
#define uwsgi_wlock(x) uwsgi.lock_ops.wlock(x)
#define uwsgi_rwunlock(x) uwsgi.lock_ops.rwunlock(x)
#define uwsgi_wait_read_req(x) uwsgi.wait_read_hook(x->fd, uwsgi.socket_timeout) ; x->switches++
#define uwsgi_wait_write_req(x) uwsgi.wait_write_hook(x->fd, uwsgi.socket_timeout) ; x->switches++
#if defined(UWSGI_PCRE) || defined(UWSGI_PCRE2)
#ifdef UWSGI_PCRE2
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
#define PCRE_OVECTOR_BYTESIZE(n) (n+1)*2
typedef pcre2_code uwsgi_pcre;
#else
#include <pcre.h>
#define PCRE_OVECTOR_BYTESIZE(n) (n+1)*3
typedef struct {
pcre *p;
pcre_extra *extra;
} uwsgi_pcre;
#endif
#endif
struct uwsgi_dyn_dict {
char *key;
int keylen;
char *value;
int vallen;
uint64_t hits;
int status;
struct uwsgi_dyn_dict *prev;
struct uwsgi_dyn_dict *next;
#if defined(UWSGI_PCRE) || defined(UWSGI_PCRE2)
uwsgi_pcre *pattern;
#endif
};
struct uwsgi_hook {
char *name;
int (*func)(char *);
struct uwsgi_hook *next;
};
#if defined(UWSGI_PCRE) || defined(UWSGI_PCRE2)
struct uwsgi_regexp_list {
uwsgi_pcre *pattern;
uint64_t custom;
char *custom_str;
void *custom_ptr;
struct uwsgi_regexp_list *next;
};
#endif
struct uwsgi_rbtree {
struct uwsgi_rb_timer *root;
struct uwsgi_rb_timer *sentinel;
};
struct uwsgi_rb_timer {
uint8_t color;
struct uwsgi_rb_timer *parent;
struct uwsgi_rb_timer *left;
struct uwsgi_rb_timer *right;
uint64_t value;
void *data;
};
struct uwsgi_rbtree *uwsgi_init_rb_timer(void);
struct uwsgi_rb_timer *uwsgi_min_rb_timer(struct uwsgi_rbtree *, struct uwsgi_rb_timer *);
struct uwsgi_rb_timer *uwsgi_add_rb_timer(struct uwsgi_rbtree *, uint64_t, void *);
void uwsgi_del_rb_timer(struct uwsgi_rbtree *, struct uwsgi_rb_timer *);
union uwsgi_sockaddr {
struct sockaddr sa;
struct sockaddr_in sa_in;
struct sockaddr_un sa_un;
#ifdef AF_INET6
struct sockaddr_in6 sa_in6;
#endif
};
union uwsgi_sockaddr_ptr {
struct sockaddr *sa;
struct sockaddr_in *sa_in;
struct sockaddr_un *sa_un;
#ifdef AF_INET6
struct sockaddr_in6 *sa_in6;
#endif
};
// Gateways are processes (managed by the master) that extends the
// server core features
// -- Gateways can prefork or spawn threads --
struct uwsgi_gateway {
char *name;
char *fullname;
void (*loop) (int, void *);
pid_t pid;
int num;
int use_signals;
int internal_subscription_pipe[2];
uint64_t respawns;
uid_t uid;
gid_t gid;
void *data;
};
struct uwsgi_gateway_socket {
char *name;
size_t name_len;
int fd;
char *zerg;
char *port;
int port_len;
int no_defer;
void *data;
int subscription;
int shared;
char *owner;
struct uwsgi_gateway *gateway;
struct uwsgi_gateway_socket *next;
// could be useful for ssl
void *ctx;
// could be useful for plugins
int mode;
};
// Daemons are external processes maintained by the master
struct uwsgi_daemon {
char *command;
pid_t pid;
uint64_t respawns;
time_t born;
time_t last_spawn;
int status;
int registered;
int has_daemonized;
char *pidfile;
int daemonize;
// this is incremented every time a pidfile is not found
uint64_t pidfile_checks;
// frequency of pidfile checks (default 10 secs)
int freq;
int control;
struct uwsgi_daemon *next;
int stop_signal;
int reload_signal;
uid_t uid;
uid_t gid;
int honour_stdin;
struct uwsgi_string_list *touch;
#ifdef UWSGI_SSL
char *legion;
#endif
int ns_pid;
int throttle;
char *chdir;
int max_throttle;
int notifypid;
};
struct uwsgi_logger {
char *name;
char *id;
ssize_t(*func) (struct uwsgi_logger *, char *, size_t);
int configured;
int fd;
void *data;
union uwsgi_sockaddr addr;
socklen_t addr_len;
int count;
struct msghdr msg;
char *buf;
// used by choosen logger
char *arg;
struct uwsgi_logger *next;
};
#ifdef UWSGI_SSL
struct uwsgi_legion_node {
char *name;
uint16_t name_len;
uint64_t valor;
char uuid[37];
char *scroll;
uint16_t scroll_len;
uint64_t checksum;
uint64_t lord_valor;
char lord_uuid[36];
time_t last_seen;
struct uwsgi_legion_node *prev;
struct uwsgi_legion_node *next;
};
struct uwsgi_legion {
char *legion;
uint16_t legion_len;
uint64_t valor;
char *addr;
char *name;
uint16_t name_len;
pid_t pid;
char uuid[37];
int socket;
int quorum;
int changed;
// if set the next packet will be a death-announce
int dead;
// set to 1 first time when quorum is reached
int joined;
uint64_t checksum;
char *scroll;
uint16_t scroll_len;
char *lord_scroll;
uint16_t lord_scroll_len;
uint16_t lord_scroll_size;
char lord_uuid[36];
uint64_t lord_valor;
time_t i_am_the_lord;
time_t unix_check;
time_t last_warning;
struct uwsgi_lock_item *lock;
EVP_CIPHER_CTX *encrypt_ctx;
EVP_CIPHER_CTX *decrypt_ctx;
char *scrolls;
uint64_t scrolls_len;
uint64_t scrolls_max_size;
// found nodes dynamic lists
struct uwsgi_legion_node *nodes_head;
struct uwsgi_legion_node *nodes_tail;
// static list of nodes to send announces to
struct uwsgi_string_list *nodes;
struct uwsgi_string_list *lord_hooks;
struct uwsgi_string_list *unlord_hooks;
struct uwsgi_string_list *setup_hooks;
struct uwsgi_string_list *death_hooks;
struct uwsgi_string_list *join_hooks;
struct uwsgi_string_list *node_joined_hooks;
struct uwsgi_string_list *node_left_hooks;
time_t suspended_til;
struct uwsgi_legion *next;
};
struct uwsgi_legion_action {
char *name;
int (*func) (struct uwsgi_legion *, char *);
char *log_msg;
struct uwsgi_legion_action *next;
};
#endif
struct uwsgi_queue_header {
uint64_t pos;
uint64_t pull_pos;
};
struct uwsgi_queue_item {
uint64_t size;
time_t ts;
};
struct uwsgi_hash_algo {
char *name;
uint32_t(*func) (char *, uint64_t);
struct uwsgi_hash_algo *next;
};
struct uwsgi_hash_algo *uwsgi_hash_algo_get(char *);
void uwsgi_hash_algo_register(char *, uint32_t(*)(char *, uint64_t));
void uwsgi_hash_algo_register_all(void);
struct uwsgi_sharedarea {
int id;
int pages;
int fd;
struct uwsgi_lock_item *lock;
char *area;
uint64_t max_pos;
uint64_t updates;
uint64_t hits;
uint8_t honour_used;
uint64_t used;
void *obj;
};
// maintain alignment here !!!
struct uwsgi_cache_item {
// item specific flags
uint64_t flags;
// size of the key
uint64_t keysize;
// hash of the key
uint64_t hash;
// size of the value (64bit)
uint64_t valsize;
// block position (in non-bitmap mode maps to the key index)
uint64_t first_block;
// 64bit expiration (0 for immortal)
uint64_t expires;
// 64bit hits
uint64_t hits;
// previous same-hash item
uint64_t prev;
// next same-hash item
uint64_t next;
// previous lru item
uint64_t lru_prev;
// next lru item
uint64_t lru_next;
// key characters follows...
char key[];
} __attribute__ ((__packed__));
struct uwsgi_cache {
char *name;
uint16_t name_len;
uint64_t keysize;
uint64_t blocks;
uint64_t blocksize;
struct uwsgi_hash_algo *hash;
uint64_t *hashtable;
uint32_t hashsize;
uint64_t first_available_block;
uint64_t *unused_blocks_stack;
uint64_t unused_blocks_stack_ptr;
uint8_t use_blocks_bitmap;
uint8_t *blocks_bitmap;
uint64_t blocks_bitmap_pos;
uint64_t blocks_bitmap_size;
uint64_t max_items;
uint64_t max_item_size;
uint64_t n_items;
struct uwsgi_cache_item *items;
uint8_t use_last_modified;
time_t last_modified_at;
void *data;
uint8_t no_expire;
uint64_t full;
uint64_t hits;
uint64_t miss;
char *store;
uint64_t filesize;
uint64_t store_sync;
int64_t math_initial;
struct uwsgi_string_list *nodes;
int udp_node_socket;
struct uwsgi_string_list *sync_nodes;
struct uwsgi_string_list *udp_servers;
struct uwsgi_lock_item *lock;
struct uwsgi_cache *next;
int ignore_full;
uint64_t next_scan;
int purge_lru;
uint64_t lru_head;
uint64_t lru_tail;
int store_delete;
int lazy_expire;
uint64_t sweep_on_full;
int clear_on_full;
};
struct uwsgi_option {
char *name;
int type;
int shortcut;
char *help;
void (*func) (char *, char *, void *);
void *data;
uint64_t flags;
};
struct uwsgi_opt {
char *key;
char *value;
int configured;
};
#define UWSGI_OK 0
#define UWSGI_AGAIN 1
#define UWSGI_ACCEPTING 2
#define UWSGI_PAUSED 3
#ifdef __linux__
#include <endian.h>
#if defined(__BYTE_ORDER__)
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define __BIG_ENDIAN__ 1
#endif
#endif
#elif defined(__sun__)
#include <sys/byteorder.h>
#ifdef _BIG_ENDIAN
#define __BIG_ENDIAN__ 1
#endif
#elif defined(__APPLE__)
#include <libkern/OSByteOrder.h>
#elif defined(__HAIKU__)
#elif defined(__HURD__)
#define PATH_MAX 8192
#define RTLD_DEFAULT ((void *) 0)
#else
#include <machine/endian.h>
#endif
#define UWSGI_SPOOLER_EXTERNAL 1
#define UWSGI_MODIFIER_ADMIN_REQUEST 10
#define UWSGI_MODIFIER_SPOOL_REQUEST 17
#define UWSGI_MODIFIER_EVAL 22
#define UWSGI_MODIFIER_FASTFUNC 26
#define UWSGI_MODIFIER_MANAGE_PATH_INFO 30
#define UWSGI_MODIFIER_MESSAGE 31
#define UWSGI_MODIFIER_MESSAGE_ARRAY 32
#define UWSGI_MODIFIER_MESSAGE_MARSHAL 33
#define UWSGI_MODIFIER_MULTICAST_ANNOUNCE 73
#define UWSGI_MODIFIER_MULTICAST 74
#define UWSGI_MODIFIER_PING 100
#define UWSGI_MODIFIER_RESPONSE 255
#define NL_SIZE 2
#define H_SEP_SIZE 2
#define UWSGI_RELOAD_CODE 17
#define UWSGI_END_CODE 30
#define UWSGI_EXILE_CODE 26
#define UWSGI_FAILED_APP_CODE 22
#define UWSGI_DE_HIJACKED_CODE 173
#define UWSGI_EXCEPTION_CODE 5
#define UWSGI_QUIET_CODE 29
#define UWSGI_BRUTAL_RELOAD_CODE 31
#define UWSGI_GO_CHEAP_CODE 15
#define MAX_VARS 64
struct uwsgi_loop {
char *name;
void (*loop) (void);
struct uwsgi_loop *next;
};
struct wsgi_request;
struct uwsgi_socket {
int fd;
char *name;
int name_len;
int family;
int bound;
int arg;
void *ctx;
uint64_t queue;
uint64_t max_queue;
int no_defer;
int auto_port;
// true if connection must be initialized for each core
int per_core;
// this is the protocol internal name
char *proto_name;
// call that when a request is accepted
int (*proto_accept) (struct wsgi_request *, int);
// call that to parse the request (without the body)
int (*proto) (struct wsgi_request *);
// call that to write reponse
int (*proto_write) (struct wsgi_request *, char *, size_t);
// call that to write headers (if a special case is needed for them)
int (*proto_write_headers) (struct wsgi_request *, char *, size_t);
// call that when sendfile() is invoked
int (*proto_sendfile) (struct wsgi_request *, int, size_t, size_t);
// call that to read the body of a request (could map to a simple read())
ssize_t(*proto_read_body) (struct wsgi_request *, char *, size_t);
// hook to call when a new series of response headers is created
struct uwsgi_buffer *(*proto_prepare_headers) (struct wsgi_request *, char *, uint16_t);
// hook to call when a header must be added
struct uwsgi_buffer *(*proto_add_header) (struct wsgi_request *, char *, uint16_t, char *, uint16_t);
// last function to call before sending headers to the client
int (*proto_fix_headers) (struct wsgi_request *);
// hook to call when a request is closed
void (*proto_close) (struct wsgi_request *);
// special hook to call (if needed) in multithread mode
void (*proto_thread_fixup) (struct uwsgi_socket *, int);
// optimization for vectors
int (*proto_writev) (struct wsgi_request *, struct iovec *, size_t *);
int edge_trigger;
int *retry;
int can_offload;
// this is a special map for having socket->thread mapping
int *fd_threads;
// generally used by zeromq handlers
char uuid[37];
void *pub;
void *pull;
pthread_key_t key;
pthread_mutex_t lock;
char *receiver;
int disabled;
int recv_flag;
struct uwsgi_socket *next;
int lazy;
int shared;
int from_shared;
// used for avoiding vacuum mess
ino_t inode;
#ifdef UWSGI_SSL
SSL_CTX *ssl_ctx;
#endif
};
struct uwsgi_protocol {
char *name;
void (*func)(struct uwsgi_socket *);
struct uwsgi_protocol *next;
};
struct uwsgi_server;
struct uwsgi_instance;
struct uwsgi_plugin {
const char *name;
const char *alias;
uint8_t modifier1;
void *data;
void (*on_load) (void);
int (*init) (void);
void (*post_init) (void);
void (*post_fork) (void);
struct uwsgi_option *options;
void (*enable_threads) (void);
void (*init_thread) (int);
int (*request) (struct wsgi_request *);
void (*after_request) (struct wsgi_request *);
void (*preinit_apps) (void);
void (*init_apps) (void);
void (*postinit_apps) (void);
void (*fixup) (void);
void (*master_fixup) (int);
void (*master_cycle) (void);
int (*mount_app) (char *, char *);
int (*manage_udp) (char *, int, char *, int);
void (*suspend) (struct wsgi_request *);
void (*resume) (struct wsgi_request *);
void (*harakiri) (int);
void (*hijack_worker) (void);
void (*spooler_init) (void);
void (*atexit) (void);
int (*magic) (char *, char *);
void *(*encode_string) (char *);
char *(*decode_string) (void *);
int (*signal_handler) (uint8_t, void *);
char *(*code_string) (char *, char *, char *, char *, uint16_t);
int (*spooler) (char *, char *, uint16_t, char *, size_t);
uint64_t(*rpc) (void *, uint8_t, char **, uint16_t *, char **);
void (*jail) (int (*)(void *), char **);
void (*post_jail) (void);
void (*before_privileges_drop) (void);
int (*mule) (char *);
int (*mule_msg) (char *, size_t);
void (*master_cleanup) (void);
struct uwsgi_buffer* (*backtrace)(struct wsgi_request *);
struct uwsgi_buffer* (*exception_class)(struct wsgi_request *);
struct uwsgi_buffer* (*exception_msg)(struct wsgi_request *);
struct uwsgi_buffer* (*exception_repr)(struct wsgi_request *);
void (*exception_log)(struct wsgi_request *);
void (*vassal)(struct uwsgi_instance *);
void (*vassal_before_exec)(struct uwsgi_instance *);
int (*worker)(void);
void (*early_post_jail) (void);
void (*pre_uwsgi_fork) (void);
void (*post_uwsgi_fork) (int);
};
#if defined(UWSGI_PCRE) || defined(UWSGI_PCRE2)
int uwsgi_regexp_build(char *, uwsgi_pcre **);
int uwsgi_regexp_match(uwsgi_pcre *, const char *, int);
int uwsgi_regexp_match_ovec(uwsgi_pcre *, const char *, int, int *, int);
int uwsgi_regexp_ovector(const uwsgi_pcre *);
char *uwsgi_regexp_apply_ovec(char *, int, char *, int, int *, int);
int uwsgi_regexp_match_pattern(char *pattern, char *str);
#endif
struct uwsgi_app {
uint8_t modifier1;
char mountpoint[0xff];
uint8_t mountpoint_len;
void *interpreter;
void *callable;
void **args;
void **environ;
void *sendfile;
void *input;
void *error;
void *stream;
// custom values you can use for internal purpose
void *responder0;
void *responder1;
void *responder2;
void *eventfd_read;
void *eventfd_write;
void *(*request_subhandler) (struct wsgi_request *, struct uwsgi_app *);
int (*response_subhandler) (struct wsgi_request *);
int argc;
uint64_t requests;
uint64_t exceptions;
char chdir[0xff];
char touch_reload[0xff];
time_t touch_reload_mtime;
void *gateway_version;
void *uwsgi_version;
void *uwsgi_node;
time_t started_at;
time_t startup_time;
uint64_t avg_response_time;
};
struct uwsgi_spooler {
char dir[PATH_MAX];
pid_t pid;
uint64_t respawned;
uint64_t tasks;
struct uwsgi_lock_item *lock;
time_t harakiri;
time_t user_harakiri;
int mode;
int running;
int signal_pipe[2];
struct uwsgi_spooler *next;
time_t cursed_at;
time_t no_mercy_at;
};
#ifdef UWSGI_ROUTING
// go to the next route
#define UWSGI_ROUTE_NEXT 0
// continue to the request handler
#define UWSGI_ROUTE_CONTINUE 1
// close the request
#define UWSGI_ROUTE_BREAK 2
struct uwsgi_route {
uwsgi_pcre *pattern;
char *orig_route;
// one for each core
int *ovn;
int **ovector;
struct uwsgi_buffer **condition_ub;
char *subject_str;
size_t subject_str_len;
size_t subject;
size_t subject_len;
int (*if_func)(struct wsgi_request *, struct uwsgi_route *);
int if_negate;
int if_status;
int (*func) (struct wsgi_request *, struct uwsgi_route *);
void *data;
size_t data_len;
void *data2;
size_t data2_len;
void *data3;
size_t data3_len;
void *data4;
size_t data4_len;
// 64bit value for custom usage
uint64_t custom;
uint64_t pos;
char *label;
size_t label_len;
char *regexp;
char *action;
// this is used by virtual route to free resources
void (*free)(struct uwsgi_route *);
struct uwsgi_route *next;
};
struct uwsgi_route_condition {
char *name;
int (*func)(struct wsgi_request *, struct uwsgi_route *);
struct uwsgi_route_condition *next;
};
struct uwsgi_route_var {
char *name;
uint16_t name_len;
char *(*func)(struct wsgi_request *, char *, uint16_t, uint16_t *);
int need_free;
struct uwsgi_route_var *next;
};
struct uwsgi_router {
char *name;
int (*func) (struct uwsgi_route *, char *);
struct uwsgi_router *next;
};
#endif
struct uwsgi_alarm;
struct uwsgi_alarm_instance {
char *name;
char *arg;
void *data_ptr;
uint8_t data8;
uint16_t data16;
uint32_t data32;
uint64_t data64;
time_t last_run;
char *last_msg;
size_t last_msg_size;
struct uwsgi_alarm *alarm;
struct uwsgi_alarm_instance *next;
};
struct uwsgi_alarm {
char *name;
void (*init) (struct uwsgi_alarm_instance *);
void (*func) (struct uwsgi_alarm_instance *, char *, size_t);
struct uwsgi_alarm *next;
};
struct uwsgi_alarm_fd {
int fd;
size_t buf_len;
void *buf;
char *msg;
size_t msg_len;
struct uwsgi_alarm_instance *alarm;
struct uwsgi_alarm_fd *next;
};
struct uwsgi_alarm_fd *uwsgi_add_alarm_fd(int, char *, size_t, char *, size_t);
#if defined(UWSGI_PCRE) || defined(UWSGI_PCRE2)
struct uwsgi_alarm_ll {
struct uwsgi_alarm_instance *alarm;
struct uwsgi_alarm_ll *next;
};
struct uwsgi_alarm_log {
uwsgi_pcre *pattern;
int negate;
struct uwsgi_alarm_ll *alarms;
struct uwsgi_alarm_log *next;
};
#endif
struct __attribute__ ((packed)) uwsgi_header {
uint8_t modifier1;
uint16_t pktsize;
uint8_t modifier2;
};
struct uwsgi_async_fd {
int fd;
int event;
struct uwsgi_async_fd *prev;
struct uwsgi_async_fd *next;
};
struct uwsgi_logvar {
char key[256];
uint8_t keylen;
char val[256];
uint8_t vallen;
struct uwsgi_logvar *next;
};
struct uwsgi_log_encoder {
char *name;
char *(*func)(struct uwsgi_log_encoder *, char *, size_t, size_t *);
int configured;
char *use_for;
char *args;
void *data;
struct uwsgi_log_encoder *next;
};
struct uwsgi_transformation {
int (*func)(struct wsgi_request *, struct uwsgi_transformation *);
struct uwsgi_buffer *chunk;
uint8_t can_stream;
uint8_t is_final;
uint8_t flushed;
void *data;
uint64_t round;
int fd;
struct uwsgi_buffer *ub;
uint64_t len;
uint64_t custom64;
struct uwsgi_transformation *next;
};
enum uwsgi_range {
UWSGI_RANGE_NOT_PARSED,
UWSGI_RANGE_PARSED,
UWSGI_RANGE_VALID,
UWSGI_RANGE_INVALID,
};
struct wsgi_request {
int fd;
struct uwsgi_header *uh;
int app_id;
int dynamic;
int parsed;
char *appid;
uint16_t appid_len;
// This structure should not be used any more
// in favor of the union client_addr at the end
struct sockaddr_un c_addr;
int c_len;
//iovec
struct iovec *hvec;
uint64_t start_of_request;
uint64_t start_of_request_in_sec;
uint64_t end_of_request;
char *uri;
uint16_t uri_len;
char *remote_addr;
uint16_t remote_addr_len;
char *remote_user;
uint16_t remote_user_len;
char *query_string;
uint16_t query_string_len;
char *protocol;
uint16_t protocol_len;
char *method;
uint16_t method_len;
char *scheme;
uint16_t scheme_len;
char *https;
uint16_t https_len;
char *script_name;
uint16_t script_name_len;
int script_name_pos;
char *host;
uint16_t host_len;
char *content_type;
uint16_t content_type_len;
char *document_root;
uint16_t document_root_len;
char *user_agent;
uint16_t user_agent_len;
char *encoding;
uint16_t encoding_len;
char *referer;
uint16_t referer_len;
char *cookie;
uint16_t cookie_len;
char *path_info;
uint16_t path_info_len;
int path_info_pos;
char *authorization;
uint16_t authorization_len;
uint16_t via;
char *script;
uint16_t script_len;
char *module;
uint16_t module_len;
char *callable;
uint16_t callable_len;
char *home;
uint16_t home_len;
char *file;
uint16_t file_len;
char *paste;
uint16_t paste_len;
char *chdir;
uint16_t chdir_len;
char *touch_reload;
uint16_t touch_reload_len;
char *cache_get;
uint16_t cache_get_len;
char *if_modified_since;
uint16_t if_modified_since_len;
int fd_closed;
int sendfile_fd;
size_t sendfile_fd_chunk;
size_t sendfile_fd_size;
off_t sendfile_fd_pos;
void *sendfile_obj;
uint16_t var_cnt;
uint16_t header_cnt;
int do_not_log;
int do_not_add_to_async_queue;
int do_not_account;
int status;
struct uwsgi_buffer *headers;
size_t response_size;
size_t headers_size;
int async_id;
int async_status;
int switches;
size_t write_pos;
int async_timed_out;
int async_ready_fd;
int async_last_ready_fd;
struct uwsgi_rb_timer *async_timeout;
struct uwsgi_async_fd *waiting_fds;
void *async_app;
void *async_result;
void *async_placeholder;
void *async_args;
void *async_environ;
void *async_input;
void *async_sendfile;
int async_force_again;
int async_plagued;
int suspended;
uint64_t write_errors;
uint64_t read_errors;
int *ovector;
size_t post_cl;
size_t post_pos;
size_t post_readline_size;
size_t post_readline_pos;
size_t post_readline_watermark;
FILE *post_file;
char *post_readline_buf;
// this is used when no post buffering is in place
char *post_read_buf;
size_t post_read_buf_size;
char *post_buffering_buf;
// when set, do not send warnings about bad behaviours
int post_warning;
// deprecated fields: size_t is 32bit on 32bit platform
size_t __range_from;
size_t __range_to;
// current socket mapped to request
struct uwsgi_socket *socket;
// check if headers are already sent
int headers_sent;
int headers_hvec;
uint64_t proto_parser_pos;
uint64_t proto_parser_move;
int64_t proto_parser_status;
void *proto_parser_buf;
uint64_t proto_parser_buf_size;
void *proto_parser_remains_buf;
size_t proto_parser_remains;
char *buffer;
int log_this;
int sigwait;
int signal_received;
struct uwsgi_logvar *logvars;
struct uwsgi_string_list *additional_headers;
struct uwsgi_string_list *remove_headers;
struct uwsgi_buffer *websocket_buf;
struct uwsgi_buffer *websocket_send_buf;
size_t websocket_need;
int websocket_phase;
uint8_t websocket_opcode;
size_t websocket_has_mask;
size_t websocket_size;
size_t websocket_pktsize;
time_t websocket_last_ping;
time_t websocket_last_pong;
int websocket_closed;
// websocket specific headers
char *http_sec_websocket_key;
uint16_t http_sec_websocket_key_len;
char *http_origin;
uint16_t http_origin_len;
char *http_sec_websocket_protocol;
uint16_t http_sec_websocket_protocol_len;
struct uwsgi_buffer *chunked_input_buf;
uint8_t chunked_input_parser_status;
ssize_t chunked_input_chunk_len;
size_t chunked_input_need;
uint8_t chunked_input_complete;
size_t chunked_input_decapitate;
uint64_t stream_id;
// avoid routing loops
int is_routing;
int is_final_routing;
int is_error_routing;
int is_response_routing;
int routes_applied;
int response_routes_applied;
// internal routing vm program counter
uint32_t route_pc;
uint32_t error_route_pc;
uint32_t response_route_pc;
uint32_t final_route_pc;
// internal routing goto instruction
uint32_t route_goto;
uint32_t error_route_goto;
uint32_t response_route_goto;
uint32_t final_route_goto;
int ignore_body;
struct uwsgi_transformation *transformations;
char *transformed_chunk;
size_t transformed_chunk_len;
int is_raw;
#ifdef UWSGI_SSL
SSL *ssl;
#endif
// do not update avg_rt after request
int do_not_account_avg_rt;
// used for protocol parsers requiring EOF signaling
int proto_parser_eof;
// 64bit range, deprecates size_t __range_from, __range_to
enum uwsgi_range range_parsed;
int64_t range_from;
int64_t range_to;
char * if_range;
uint16_t if_range_len;
// client address in a type-safe fashion; always use this over
// c_addr (which only exists to maintain binary compatibility in this
// struct)
union address {
struct sockaddr_in sin;
struct sockaddr_in6 sin6;
struct sockaddr_un sun;
} client_addr;
uint8_t websocket_is_fin;
};
struct uwsgi_fmon {
char filename[0xff];
int fd;
int id;
int registered;
uint8_t sig;
};
struct uwsgi_timer {
int value;
int fd;
int id;
int registered;
uint8_t sig;
};
struct uwsgi_signal_rb_timer {
int value;
int registered;
int iterations;
int iterations_done;
uint8_t sig;
struct uwsgi_rb_timer *uwsgi_rb_timer;
};
struct uwsgi_cheaper_algo {
char *name;
int (*func) (int);
struct uwsgi_cheaper_algo *next;
};
struct uwsgi_emperor_scanner;
struct uwsgi_imperial_monitor {
char *scheme;
void (*init) (struct uwsgi_emperor_scanner *);
void (*func) (struct uwsgi_emperor_scanner *);
struct uwsgi_imperial_monitor *next;
};
struct uwsgi_clock {
char *name;
time_t(*seconds) (void);
uint64_t(*microseconds) (void);
struct uwsgi_clock *next;
};
struct uwsgi_subscribe_slot;
struct uwsgi_stats_pusher;
struct uwsgi_stats_pusher_instance;
#define UWSGI_PROTO_MIN_CHECK 4
#define UWSGI_PROTO_MAX_CHECK 28
struct uwsgi_offload_engine;
// these are the possible states of an instance
struct uwsgi_instance_status {
int gracefully_reloading;
int brutally_reloading;
int gracefully_destroying;
int brutally_destroying;
int chain_reloading;
int workers_reloading;
int is_cheap;
int is_cleaning;
int dying_for_need_app;
};
struct uwsgi_configurator {
char *name;
void (*func)(char *, char **);
struct uwsgi_configurator *next;
};
struct uwsgi_configurator *uwsgi_register_configurator(char *, void (*)(char *, char **));
void uwsgi_opt_load_config(char *, char *, void *);
#define uwsgi_instance_is_dying (uwsgi.status.gracefully_destroying || uwsgi.status.brutally_destroying)
#define uwsgi_instance_is_reloading (uwsgi.status.gracefully_reloading || uwsgi.status.brutally_reloading)
#define exit(x) uwsgi_exit(x)
struct uwsgi_metric;
struct uwsgi_logging_options {
int enabled;
int memory_report;
int zero;
int _4xx;
int _5xx;
int sendfile;
int ioerror;
uint32_t slow;
uint64_t big;
int log_x_forwarded_for;
};
struct uwsgi_harakiri_options {
int workers;
int spoolers;
int mules;
};
struct uwsgi_fsmon {
char *path;
int fd;
int id;
void *data;
void (*func)(struct uwsgi_fsmon *);
struct uwsgi_fsmon *next;
};
struct uwsgi_server {
// store the machine hostname
char hostname[256];
int hostname_len;
// used to store the exit code for atexit hooks
int last_exit_code;
int (*proto_hooks[UWSGI_PROTO_MAX_CHECK]) (struct wsgi_request *, char *, char *, uint16_t);
struct uwsgi_configurator *configurators;
char **orig_argv;
char **argv;
int argc;
int max_procname;
int auto_procname;
char **environ;
char *procname_prefix;
char *procname_append;
char *procname_master;
char *procname;
struct uwsgi_logging_options logging_options;
struct uwsgi_harakiri_options harakiri_options;
int socket_timeout;
int reaper;
int cgi_mode;
uint64_t max_requests;
uint64_t min_worker_lifetime;
uint64_t max_worker_lifetime;
// daemontools-like envdir
struct uwsgi_string_list *envdirs;
char *requested_clock;
struct uwsgi_clock *clocks;
struct uwsgi_clock *clock;
char *empty;
// quiet startup
int no_initial_output;
struct uwsgi_instance_status status;
struct uwsgi_string_list *get_list;
// enable threads
int has_threads;
int no_threads_wait;
// default app id
int default_app;
char *logto2;
char *logformat;
int logformat_strftime;
int logformat_vectors;
struct uwsgi_logchunk *logchunks;
struct uwsgi_logchunk *registered_logchunks;
void (*logit) (struct wsgi_request *);
struct iovec **logvectors;
// autoload plugins
int autoload;
struct uwsgi_string_list *plugins_dir;
struct uwsgi_string_list *blacklist;
struct uwsgi_string_list *whitelist;
char *blacklist_context;
char *whitelist_context;
unsigned int reloads;
// leave master running as root
int master_as_root;
// postpone privileges drop
int drop_after_init;
int drop_after_apps;
int master_is_reforked;
struct uwsgi_string_list *master_fifo;
int master_fifo_fd;
int master_fifo_slot;
// kill the stack on SIGTERM (instead of brutal reloading)
int die_on_term;
// force the first gateway without a master
int force_gateway;
// disable fd passing on unix socket
int no_fd_passing;
// store the current time
time_t current_time;
uint64_t master_cycles;
int reuse_port;
int tcp_fast_open;
int tcp_fast_open_client;
int enable_proxy_protocol;
uint64_t fastcgi_modifier1;
uint64_t fastcgi_modifier2;
uint64_t http_modifier1;
uint64_t http_modifier2;
uint64_t https_modifier1;
uint64_t https_modifier2;
uint64_t scgi_modifier1;
uint64_t scgi_modifier2;
uint64_t raw_modifier1;
uint64_t raw_modifier2;
// enable lazy mode
int lazy;
// enable lazy-apps mode
int lazy_apps;
// enable cheaper mode
int cheaper;
char *requested_cheaper_algo;
struct uwsgi_cheaper_algo *cheaper_algos;
int (*cheaper_algo) (int);
int cheaper_step;
uint64_t cheaper_overload;
// minimal number of running workers in cheaper mode
int cheaper_count;
int cheaper_initial;
// enable idle mode
int idle;
// cheaper mode memory usage limits
uint64_t cheaper_rss_limit_soft;
uint64_t cheaper_rss_limit_hard;
int cheaper_fifo_delta;
// destroy the stack when idle
int die_on_idle;
// store the screen session
char *screen_session;
// true if run under the emperor
int has_emperor;
char *emperor_procname;
char *emperor_proxy;
int emperor_fd;
int emperor_fd_proxy;
int emperor_queue;
int emperor_nofollow;
int emperor_tyrant;
int emperor_tyrant_nofollow;
int emperor_fd_config;
int early_emperor;
int emperor_throttle;
int emperor_freq;
int emperor_max_throttle;
int emperor_magic_exec;
int emperor_heartbeat;
int emperor_curse_tolerance;
struct uwsgi_string_list *emperor_extra_extension;
// search for a file with the specified extension at the same level of the vassal file
char *emperor_on_demand_extension;
// bind to a unix socket on the specified directory named directory/vassal.socket
char *emperor_on_demand_directory;
// run a shell script passing the vassal as the only argument, the stdout is used as the socket
char *emperor_on_demand_exec;
int disable_nuclear_blast;
time_t next_heartbeat;
int heartbeat;
struct uwsgi_string_list *emperor;
struct uwsgi_imperial_monitor *emperor_monitors;
char *emperor_absolute_dir;
char *emperor_pidfile;
pid_t emperor_pid;
int emperor_broodlord;
int emperor_broodlord_count;
uint64_t emperor_broodlord_num;
char *emperor_stats;
int emperor_stats_fd;
struct uwsgi_string_list *vassals_templates;
struct uwsgi_string_list *vassals_includes;
struct uwsgi_string_list *vassals_templates_before;
struct uwsgi_string_list *vassals_includes_before;
struct uwsgi_string_list *vassals_set;
// true if loyal to the emperor
int loyal;
// emperor hook (still in development)
char *vassals_start_hook;
char *vassals_stop_hook;
struct uwsgi_string_list *additional_headers;
struct uwsgi_string_list *remove_headers;
struct uwsgi_string_list *collect_headers;
// set cpu affinity
int cpu_affinity;
int reload_mercy;
int worker_reload_mercy;
// map reloads to death
int exit_on_reload;
// store options
int dirty_config;
int option_index;
int (*logic_opt) (char *, char *);
char *logic_opt_arg;
char *logic_opt_data;
int logic_opt_running;
int logic_opt_cycles;
struct uwsgi_option *options;
struct option *long_options;
char *short_options;
struct uwsgi_opt **exported_opts;
int exported_opts_cnt;
struct uwsgi_custom_option *custom_options;
// dump the whole set of options
int dump_options;
// show ini representation of the current config
int show_config;
// enable strict mode (only registered options can be used)
int strict;
// list loaded features
int cheaper_algo_list;
#ifdef UWSGI_ROUTING
int router_list;
#endif
int imperial_monitor_list;
int plugins_list;
int loggers_list;
int loop_list;
int clock_list;
int alarms_list;
struct wsgi_request *wsgi_req;
char *remap_modifier;
// enable zerg mode
int *zerg;
char *zerg_server;
struct uwsgi_string_list *zerg_node;
int zerg_fallback;
int zerg_server_fd;
// security
char *chroot;
gid_t gid;
uid_t uid;
char *uidname;
char *gidname;
int no_initgroups;
struct uwsgi_string_list *additional_gids;
#ifdef UWSGI_CAP
cap_value_t *cap;
int cap_count;
cap_value_t *emperor_cap;
int emperor_cap_count;
#endif
#ifdef __linux__
int unshare;
int unshare2;
int emperor_clone;
char *pivot_root;
char *setns_socket;
struct uwsgi_string_list *setns_socket_skip;
char *setns;
int setns_socket_fd;
int setns_preopen;
int setns_fds[64];
int setns_fds_count;
#endif
char *emperor_wrapper;
int jailed;
#if defined(__FreeBSD__) || defined(__GNU_kFreeBSD__)
char *jail;
struct uwsgi_string_list *jail_ip4;
#ifdef AF_INET6
struct uwsgi_string_list *jail_ip6;
#endif
struct uwsgi_string_list *jail2;
char *jidfile;
char *jail_attach;
#endif
int refork;
int refork_as_root;
int refork_post_jail;
int ignore_sigpipe;
int ignore_write_errors;
uint64_t write_errors_tolerance;
int write_errors_exception_only;
int disable_write_exception;
// still working on it
char *profiler;
// the weight of the instance, used by various cluster/lb components
uint64_t weight;
int auto_weight;
// mostly useless
char *mode;
// binary patch the worker image
char *worker_exec;
char *worker_exec2;
// this must be UN-shared
struct uwsgi_gateway_socket *gateway_sockets;
int ignore_script_name;
int manage_script_name;
int reload_on_exception;
int catch_exceptions;
struct uwsgi_string_list *reload_on_exception_type;
struct uwsgi_string_list *reload_on_exception_value;
struct uwsgi_string_list *reload_on_exception_repr;
struct uwsgi_exception_handler *exception_handlers;
struct uwsgi_string_list *exception_handlers_instance;
struct uwsgi_thread *exception_handler_thread;
uint64_t exception_handler_msg_size;
int no_default_app;
// exit if no-app is loaded
int need_app;
int forkbomb_delay;
int logdate;
int log_micros;
char *log_strftime;
int honour_stdin;
struct termios termios;
int restore_tc;
// honour the HTTP Range header
int honour_range;
// route all of the logs to the master process
int req_log_master;
int log_master;
char *log_master_buf;
size_t log_master_bufsize;
int log_master_stream;
int log_master_req_stream;
int log_reopen;
int log_truncate;
uint64_t log_maxsize;
char *log_backupname;
int original_log_fd;
int req_log_fd;
// static file serving
int file_serve_mode;
int build_mime_dict;
struct uwsgi_string_list *mime_file;
struct uwsgi_hook *hooks;
struct uwsgi_string_list *hook_touch;
struct uwsgi_string_list *hook_asap;
struct uwsgi_string_list *hook_pre_jail;
struct uwsgi_string_list *hook_post_jail;
struct uwsgi_string_list *hook_in_jail;
struct uwsgi_string_list *hook_as_root;
struct uwsgi_string_list *hook_as_user;
struct uwsgi_string_list *hook_as_user_atexit;
struct uwsgi_string_list *hook_pre_app;
struct uwsgi_string_list *hook_post_app;
struct uwsgi_string_list *hook_accepting;
struct uwsgi_string_list *hook_accepting1;
struct uwsgi_string_list *hook_accepting_once;
struct uwsgi_string_list *hook_accepting1_once;
struct uwsgi_string_list *hook_emperor_start;
struct uwsgi_string_list *hook_master_start;
struct uwsgi_string_list *hook_emperor_stop;
struct uwsgi_string_list *hook_emperor_reload;
struct uwsgi_string_list *hook_emperor_lost;
struct uwsgi_string_list *hook_as_vassal;
struct uwsgi_string_list *hook_as_emperor;
struct uwsgi_string_list *hook_as_mule;
struct uwsgi_string_list *hook_as_gateway;
struct uwsgi_string_list *exec_asap;
struct uwsgi_string_list *exec_pre_jail;
struct uwsgi_string_list *exec_post_jail;
struct uwsgi_string_list *exec_in_jail;
struct uwsgi_string_list *exec_as_root;
struct uwsgi_string_list *exec_as_user;
struct uwsgi_string_list *exec_as_user_atexit;
struct uwsgi_string_list *exec_pre_app;
struct uwsgi_string_list *exec_post_app;
struct uwsgi_string_list *exec_as_vassal;
struct uwsgi_string_list *exec_as_emperor;
struct uwsgi_string_list *call_asap;
struct uwsgi_string_list *call_pre_jail;
struct uwsgi_string_list *call_post_jail;
struct uwsgi_string_list *call_in_jail;
struct uwsgi_string_list *call_as_root;
struct uwsgi_string_list *call_as_user;
struct uwsgi_string_list *call_as_user_atexit;
struct uwsgi_string_list *call_pre_app;
struct uwsgi_string_list *call_post_app;
struct uwsgi_string_list *call_as_vassal;
struct uwsgi_string_list *call_as_vassal1;
struct uwsgi_string_list *call_as_vassal3;
struct uwsgi_string_list *call_as_emperor;
struct uwsgi_string_list *call_as_emperor1;
struct uwsgi_string_list *call_as_emperor2;
struct uwsgi_string_list *call_as_emperor4;
struct uwsgi_string_list *mount_asap;
struct uwsgi_string_list *mount_pre_jail;
struct uwsgi_string_list *mount_post_jail;
struct uwsgi_string_list *mount_in_jail;
struct uwsgi_string_list *mount_as_root;
struct uwsgi_string_list *mount_as_vassal;
struct uwsgi_string_list *mount_as_emperor;
struct uwsgi_string_list *umount_asap;
struct uwsgi_string_list *umount_pre_jail;
struct uwsgi_string_list *umount_post_jail;
struct uwsgi_string_list *umount_in_jail;
struct uwsgi_string_list *umount_as_root;
struct uwsgi_string_list *umount_as_vassal;
struct uwsgi_string_list *umount_as_emperor;
struct uwsgi_string_list *after_request_hooks;
struct uwsgi_string_list *wait_for_interface;
int wait_for_interface_timeout;
char *privileged_binary_patch;
char *unprivileged_binary_patch;
char *privileged_binary_patch_arg;
char *unprivileged_binary_patch_arg;
struct uwsgi_logger *loggers;
struct uwsgi_logger *choosen_logger;
struct uwsgi_logger *choosen_req_logger;
struct uwsgi_string_list *requested_logger;
struct uwsgi_string_list *requested_req_logger;
struct uwsgi_log_encoder *log_encoders;
struct uwsgi_string_list *requested_log_encoders;
struct uwsgi_string_list *requested_log_req_encoders;
#if defined(UWSGI_PCRE) || defined(UWSGI_PCRE2)
int pcre_jit;
struct uwsgi_regexp_list *log_drain_rules;
struct uwsgi_regexp_list *log_filter_rules;
struct uwsgi_regexp_list *log_route;
struct uwsgi_regexp_list *log_req_route;
#endif
int use_abort;
int alarm_freq;
uint64_t alarm_msg_size;
struct uwsgi_string_list *alarm_list;
struct uwsgi_string_list *alarm_logs_list;
struct uwsgi_alarm_fd *alarm_fds;
struct uwsgi_string_list *alarm_fd_list;
struct uwsgi_string_list *alarm_segfault;
struct uwsgi_string_list *alarm_backlog;
struct uwsgi_alarm *alarms;
struct uwsgi_alarm_instance *alarm_instances;
struct uwsgi_alarm_log *alarm_logs;
struct uwsgi_thread *alarm_thread;
int threaded_logger;
pthread_mutex_t threaded_logger_lock;
int *safe_fds;
int safe_fds_cnt;
int daemons_honour_stdin;
struct uwsgi_daemon *daemons;
int daemons_cnt;
#ifdef UWSGI_SSL
char *subscriptions_sign_check_dir;
int subscriptions_sign_check_tolerance;
const EVP_MD *subscriptions_sign_check_md;
struct uwsgi_string_list *subscriptions_sign_skip_uid;
#endif
struct uwsgi_string_list *subscriptions_credentials_check_dir;
int subscriptions_use_credentials;
struct uwsgi_dyn_dict *static_maps;
struct uwsgi_dyn_dict *static_maps2;
struct uwsgi_dyn_dict *check_static;
struct uwsgi_dyn_dict *mimetypes;
struct uwsgi_string_list *static_skip_ext;
struct uwsgi_string_list *static_index;
struct uwsgi_string_list *static_safe;
struct uwsgi_hash_algo *hash_algos;
int use_static_cache_paths;
char *static_cache_paths_name;
struct uwsgi_cache *static_cache_paths;
int cache_expire_freq;
int cache_report_freed_items;
int cache_no_expire;
uint64_t cache_max_items;
uint64_t cache_blocksize;
char *cache_store;
int cache_store_sync;
struct uwsgi_string_list *cache2;
int cache_setup;
int locking_setup;
int cache_use_last_modified;
struct uwsgi_dyn_dict *static_expires_type;
struct uwsgi_dyn_dict *static_expires_type_mtime;
struct uwsgi_dyn_dict *static_expires;
struct uwsgi_dyn_dict *static_expires_mtime;
struct uwsgi_dyn_dict *static_expires_uri;
struct uwsgi_dyn_dict *static_expires_uri_mtime;
struct uwsgi_dyn_dict *static_expires_path_info;
struct uwsgi_dyn_dict *static_expires_path_info_mtime;
int static_gzip_all;
struct uwsgi_string_list *static_gzip_dir;
struct uwsgi_string_list *static_gzip_ext;
#if defined(UWSGI_PCRE) || defined(UWSGI_PCRE2)
struct uwsgi_regexp_list *static_gzip;
#endif
struct uwsgi_offload_engine *offload_engines;
struct uwsgi_offload_engine *offload_engine_sendfile;
struct uwsgi_offload_engine *offload_engine_transfer;
struct uwsgi_offload_engine *offload_engine_memory;
struct uwsgi_offload_engine *offload_engine_pipe;
int offload_threads;
int offload_threads_events;
struct uwsgi_thread **offload_thread;
int check_static_docroot;
int disable_sendfile;
char *daemonize;
char *daemonize2;
int do_not_change_umask;
char *logfile;
int logfile_chown;
// enable vhost mode
int vhost;
int vhost_host;
// async commodity
struct wsgi_request **async_waiting_fd_table;
struct wsgi_request **async_proto_fd_table;
struct uwsgi_async_request *async_runqueue;
struct uwsgi_async_request *async_runqueue_last;
struct uwsgi_rbtree *rb_async_timeouts;
int async_queue_unused_ptr;
struct wsgi_request **async_queue_unused;
// store rlimit
struct rlimit rl;
struct rlimit rl_nproc;
size_t limit_post;
// set process priority
int prio;
// funny reload systems
int force_get_memusage;
rlim_t reload_on_as;
rlim_t reload_on_rss;
rlim_t evil_reload_on_as;
rlim_t evil_reload_on_rss;
struct uwsgi_string_list *reload_on_fd;
struct uwsgi_string_list *brutal_reload_on_fd;
struct uwsgi_string_list *touch_reload;
struct uwsgi_string_list *touch_chain_reload;
struct uwsgi_string_list *touch_workers_reload;
struct uwsgi_string_list *touch_gracefully_stop;
struct uwsgi_string_list *touch_logrotate;
struct uwsgi_string_list *touch_logreopen;
struct uwsgi_string_list *touch_exec;
struct uwsgi_string_list *touch_signal;
struct uwsgi_string_list *fs_reload;
struct uwsgi_string_list *fs_brutal_reload;
struct uwsgi_string_list *fs_signal;
struct uwsgi_fsmon *fsmon;
struct uwsgi_string_list *signal_timers;
struct uwsgi_string_list *rb_signal_timers;
struct uwsgi_string_list *mountpoints_check;
int propagate_touch;
// enable grunt mode
int grunt;
// store the binary path
char *binary_path;
int is_a_reload;
char *udp_socket;
int multicast_ttl;
int multicast_loop;
char *multicast_group;
struct uwsgi_spooler *spoolers;
int spooler_numproc;
struct uwsgi_spooler *i_am_a_spooler;
char *spooler_chdir;
int spooler_max_tasks;
int spooler_ordered;
int spooler_quiet;
int spooler_frequency;
int snmp;
char *snmp_addr;
char *snmp_community;
struct uwsgi_lock_item *snmp_lock;
int snmp_fd;
int udp_fd;
uint16_t buffer_size;
int signal_bufsize;
// post buffering
size_t post_buffering;
int post_buffering_harakiri;
size_t post_buffering_bufsize;
size_t body_read_warning;
int master_process;
int master_queue;
int master_interval;
// mainly useful for broodlord mode
int vassal_sos_backlog;
int no_defer_accept;
int so_keepalive;
int so_send_timeout;
uint64_t so_sndbuf;
uint64_t so_rcvbuf;
int page_size;
int cpus;
char *pidfile;
char *pidfile2;
char *flock2;
char *flock_wait2;
int backtrace_depth;
int harakiri_verbose;
int harakiri_no_arh;
int magic_table_first_round;
char *magic_table[256];
int numproc;
int async;
int async_running;
int async_queue;
int async_nevents;
time_t async_queue_is_full;
int max_vars;
int vec_size;
// shared area
struct uwsgi_string_list *sharedareas_list;
int sharedareas_cnt;
struct uwsgi_sharedarea **sharedareas;
// avoid thundering herd in threaded modes
pthread_mutex_t thunder_mutex;
pthread_mutex_t lock_static;
int use_thunder_lock;
struct uwsgi_lock_item *the_thunder_lock;
/* the list of workers */
struct uwsgi_worker *workers;
int max_apps;
/* the list of mules */
struct uwsgi_string_list *mules_patches;
struct uwsgi_mule *mules;
struct uwsgi_string_list *farms_list;
struct uwsgi_farm *farms;
int mule_msg_size;
pid_t mypid;
int mywid;
int muleid;
int mules_cnt;
int farms_cnt;
rlim_t requested_max_fd;
rlim_t max_fd;
struct timeval start_tv;
int abstract_socket;
#ifdef __linux__
int freebind;
#endif
int chmod_socket;
char *chown_socket;
mode_t chmod_socket_value;
mode_t chmod_logfile_value;
int listen_queue;
char *fallback_config;
#ifdef UWSGI_ROUTING
struct uwsgi_router *routers;
struct uwsgi_route *routes;
struct uwsgi_route *final_routes;
struct uwsgi_route *error_routes;
struct uwsgi_route *response_routes;
struct uwsgi_route_condition *route_conditions;
struct uwsgi_route_var *route_vars;
#endif
struct uwsgi_string_list *error_page_403;
struct uwsgi_string_list *error_page_404;
struct uwsgi_string_list *error_page_500;
int single_interpreter;
struct uwsgi_shared *shared;
int no_orphans;
int skip_zero;
int skip_atexit;
char *force_cwd;
char *chdir;
char *chdir2;
struct uwsgi_string_list *binsh;
int vacuum;
int no_server;
int command_mode;
int xml_round2;
char *cwd;
// conditional logging
int log_slow_requests;
int log_zero_headers;
int log_empty_body;
int log_high_memory;
#ifdef __linux__
struct uwsgi_string_list *cgroup;
struct uwsgi_string_list *cgroup_opt;
char *cgroup_dir_mode;
char *ns;
char *ns_net;
struct uwsgi_string_list *ns_keep_mount;
#endif
struct uwsgi_string_list *file_write_list;
char *protocol;
int signal_socket;
int my_signal_socket;
struct uwsgi_protocol *protocols;
struct uwsgi_socket *sockets;
struct uwsgi_socket *shared_sockets;
int is_et;
struct uwsgi_string_list *map_socket;
struct uwsgi_cron *crons;
time_t cron_harakiri;
time_t respawn_delta;
struct uwsgi_string_list *mounts;
int cores;
int threads;
pthread_attr_t threads_attr;
size_t threads_stacksize;
//this key old the u_request structure per core / thread
pthread_key_t tur_key;
struct wsgi_request *(*current_wsgi_req) (void);
void (*notify) (char *);
void (*notify_ready) (void);
int notification_fd;
void *notification_object;
// usedby suspend/resume loops
void (*schedule_to_main) (struct wsgi_request *);
void (*schedule_to_req) (void);
void (*schedule_fix) (struct wsgi_request *);
void (*gbcw_hook) (void);
int close_on_exec;
int close_on_exec2;
int tcp_nodelay;
char *loop;
struct uwsgi_loop *loops;
struct uwsgi_plugin *p[256];
struct uwsgi_plugin *gp[MAX_GENERIC_PLUGINS];
int gp_cnt;
char *allowed_modifiers;
char *upload_progress;
struct uwsgi_lock_item *registered_locks;
struct uwsgi_lock_ops lock_ops;
char *lock_engine;
char *ftok;
char *lock_id;
size_t lock_size;
size_t rwlock_size;
struct uwsgi_string_list *add_cache_item;
struct uwsgi_string_list *load_file_in_cache;
#ifdef UWSGI_ZLIB
struct uwsgi_string_list *load_file_in_cache_gzip;
#endif
char *use_check_cache;
struct uwsgi_cache *check_cache;
struct uwsgi_cache *caches;
struct uwsgi_string_list *cache_udp_server;
struct uwsgi_string_list *cache_udp_node;
char *cache_sync;
// the stats server
char *stats;
int stats_fd;
int stats_http;
int stats_minified;
struct uwsgi_string_list *requested_stats_pushers;
struct uwsgi_stats_pusher *stats_pushers;
struct uwsgi_stats_pusher_instance *stats_pusher_instances;
int stats_pusher_default_freq;
uint64_t queue_size;
uint64_t queue_blocksize;
void *queue;
struct uwsgi_queue_header *queue_header;
char *queue_store;
size_t queue_filesize;
int queue_store_sync;
int locks;
int persistent_ipcsem;
struct uwsgi_lock_item *queue_lock;
struct uwsgi_lock_item **user_lock;
struct uwsgi_lock_item *signal_table_lock;
struct uwsgi_lock_item *fmon_table_lock;
struct uwsgi_lock_item *timer_table_lock;
struct uwsgi_lock_item *rb_timer_table_lock;
struct uwsgi_lock_item *cron_table_lock;
struct uwsgi_lock_item *rpc_table_lock;
struct uwsgi_lock_item *sa_lock;
struct uwsgi_lock_item *metrics_lock;
// rpc
uint64_t rpc_max;
struct uwsgi_rpc *rpc_table;
// subscription client
int subscriptions_blocked;
int subscribe_freq;
int subscription_tolerance;
int unsubscribe_on_graceful_reload;
struct uwsgi_string_list *subscriptions;
struct uwsgi_string_list *subscriptions2;
struct uwsgi_subscribe_node *(*subscription_algo) (struct uwsgi_subscribe_slot *, struct uwsgi_subscribe_node *);
int subscription_dotsplit;
int never_swap;
#ifdef UWSGI_SSL
int ssl_initialized;
int ssl_verbose;
char *ssl_sessions_use_cache;
int ssl_sessions_timeout;
struct uwsgi_cache *ssl_sessions_cache;
char *ssl_tmp_dir;
#if defined(UWSGI_PCRE) || defined(UWSGI_PCRE2)
struct uwsgi_regexp_list *sni_regexp;
#endif
struct uwsgi_string_list *sni;
char *sni_dir;
char *sni_dir_ciphers;
#endif
#ifdef UWSGI_SSL
struct uwsgi_legion *legions;
struct uwsgi_legion_action *legion_actions;
int legion_queue;
int legion_freq;
int legion_tolerance;
int legion_skew_tolerance;
uint16_t legion_scroll_max_size;
uint64_t legion_scroll_list_max_size;
int legion_death_on_lord_error;
#endif
#ifdef __linux__
#ifdef MADV_MERGEABLE
int linux_ksm;
int ksm_buffer_size;
char *ksm_mappings_last;
char *ksm_mappings_current;
size_t ksm_mappings_last_size;
size_t ksm_mappings_current_size;
#endif
#endif
struct uwsgi_buffer *websockets_ping;
struct uwsgi_buffer *websockets_pong;
struct uwsgi_buffer *websockets_close;
int websockets_ping_freq;
int websockets_pong_tolerance;
uint64_t websockets_max_size;
int chunked_input_timeout;
uint64_t chunked_input_limit;
struct uwsgi_metric *metrics;
struct uwsgi_metric_collector *metric_collectors;
int has_metrics;
char *metrics_dir;
int metrics_dir_restore;
uint64_t metrics_cnt;
struct uwsgi_string_list *additional_metrics;
struct uwsgi_string_list *metrics_threshold;
int (*wait_write_hook) (int, int);
int (*wait_read_hook) (int, int);
int (*wait_milliseconds_hook) (int);
int (*wait_read2_hook) (int, int, int, int *);
struct uwsgi_string_list *schemes;
// inject text files (useful for advanced templating)
struct uwsgi_string_list *inject_before;
struct uwsgi_string_list *inject_after;
// this is a unix socket receiving external notifications (like subscription replies)
char *notify_socket;
int notify_socket_fd;
char *subscription_notify_socket;
//uWSGI 2.0.5
int mule_reload_mercy;
int alarm_cheap;
int emperor_no_blacklist;
int metrics_no_cores;
int stats_no_cores;
int stats_no_metrics;
// uWSGI 2.0.7
int vassal_sos;
// uWSGI 2.0.8
struct uwsgi_string_list *wait_for_fs;
struct uwsgi_string_list *wait_for_dir;
struct uwsgi_string_list *wait_for_file;
int wait_for_fs_timeout;
struct uwsgi_string_list *wait_for_mountpoint;
#ifdef UWSGI_SSL
int sslv3;
struct uwsgi_string_list *ssl_options;
#endif
struct uwsgi_string_list *hook_post_fork;
// uWSGI 2.0.9
char *subscribe_with_modifier1;
struct uwsgi_string_list *pull_headers;
// uWSGI 2.0.10
struct uwsgi_string_list *emperor_wrapper_override;
struct uwsgi_string_list *emperor_wrapper_fallback;
// uWSGI 2.0.11
struct uwsgi_string_list *wait_for_socket;
int wait_for_socket_timeout;
int mem_collector_freq;
// uWSGI 2.0.14
struct uwsgi_string_list *touch_mules_reload;
struct uwsgi_string_list *touch_spoolers_reload;
int spooler_reload_mercy;
int skip_atexit_teardown;
// uWSGI 2.1 backport
int new_argc;
char **new_argv;
// uWSGI 2.0.16
#ifdef UWSGI_SSL
int ssl_verify_depth;
#endif
size_t response_header_limit;
char *safe_pidfile;
char *safe_pidfile2;
// uWSGI 2.0.17
int shutdown_sockets;
#ifdef UWSGI_SSL
int tlsv1;
#endif
// uWSGI 2.0.19
int emperor_graceful_shutdown;
int is_chrooted;
struct uwsgi_buffer *websockets_continuation_buffer;
uint64_t max_worker_lifetime_delta;
// uWSGI 2.0.22
int harakiri_graceful_timeout;
int harakiri_graceful_signal;
int harakiri_queue_threshold;
// uWSGI 2.0.27
// This pipe is used to stop event_queue_wait() in threaded workers.
int loop_stop_pipe[2];
// uWSGI 2.0.29
uint64_t max_requests_delta;
};
struct uwsgi_rpc {
char name[UMAX8];
void *func;
uint8_t args;
uint8_t shared;
struct uwsgi_plugin *plugin;
};
struct uwsgi_signal_entry {
int wid;
uint8_t modifier1;
char receiver[64];
void *handler;
};
/*
they are here for backwards compatibility
*/
#define SNMP_COUNTER32 0x41
#define SNMP_GAUGE 0x42
#define SNMP_COUNTER64 0x46
struct uwsgi_snmp_custom_value {
uint8_t type;
uint64_t val;
};
int uwsgi_setup_snmp(void);
struct uwsgi_snmp_server_value {
uint8_t type;
uint64_t *val;
};
struct uwsgi_cron {
int minute;
int hour;
int day;
int month;
int week;
time_t last_job;
uint8_t sig;
char *command;
void (*func)(struct uwsgi_cron *, time_t);
time_t started_at;
// next harakiri timestamp
time_t harakiri;
// number of seconds to wait before calling harakiri on cron
int mercy;
uint8_t unique;
pid_t pid;
struct uwsgi_cron *next;
#ifdef UWSGI_SSL
char *legion;
#endif
};
struct uwsgi_shared {
//vga 80 x25 specific !
char warning_message[81];
off_t logsize;
char snmp_community[72 + 1];
struct uwsgi_snmp_server_value snmp_gvalue[100];
struct uwsgi_snmp_custom_value snmp_value[100];
int worker_signal_pipe[2];
int spooler_frequency;
int spooler_signal_pipe[2];
int mule_signal_pipe[2];
int mule_queue_pipe[2];
// 256 items * (uwsgi.numproc + 1)
struct uwsgi_signal_entry *signal_table;
struct uwsgi_fmon files_monitored[64];
int files_monitored_cnt;
struct uwsgi_timer timers[MAX_TIMERS];
int timers_cnt;
struct uwsgi_signal_rb_timer rb_timers[MAX_TIMERS];
int rb_timers_cnt;
uint64_t *rpc_count;
int worker_log_pipe[2];
// used for request logging
int worker_req_log_pipe[2];
uint64_t load;
uint64_t max_load;
struct uwsgi_cron cron[MAX_CRONS];
int cron_cnt;
uint64_t backlog;
uint64_t backlog_errors;
// gateways
struct uwsgi_gateway gateways[MAX_GATEWAYS];
int gateways_cnt;
time_t gateways_harakiri[MAX_GATEWAYS];
uint64_t routed_signals;
uint64_t unrouted_signals;
uint64_t busy_workers;
uint64_t idle_workers;
uint64_t overloaded;
int ready;
};
struct uwsgi_core {
//time_t harakiri;
uint64_t requests;
uint64_t failed_requests;
uint64_t static_requests;
uint64_t routed_requests;
uint64_t offloaded_requests;
uint64_t write_errors;
uint64_t read_errors;
uint64_t exceptions;
pthread_t thread_id;
int offload_rr;
// one ts-perapp
void **ts;
int in_request;
char *buffer;
struct iovec *hvec;
char *post_buf;
struct wsgi_request req;
};
struct uwsgi_worker {
int id;
pid_t pid;
uint64_t status;
time_t last_spawn;
uint64_t respawn_count;
uint64_t requests;
uint64_t delta_requests;
uint64_t failed_requests;
time_t harakiri;
time_t user_harakiri;
uint64_t harakiri_count;
int pending_harakiri;
uint64_t vsz_size;
uint64_t rss_size;
uint64_t running_time;
int manage_next_request;
int destroy;
int apps_cnt;
struct uwsgi_app *apps;
uint64_t tx;
int hijacked;
uint64_t hijacked_count;
int cheaped;
int suspended;
int sig;
uint8_t signum;
time_t cursed_at;
time_t no_mercy_at;
// signals managed by this worker
uint64_t signals;
int signal_pipe[2];
uint64_t avg_response_time;
struct uwsgi_core *cores;
int accepting;
char name[0xff];
int shutdown_sockets;
};
struct uwsgi_mule {
int id;
pid_t pid;
int signal_pipe[2];
int queue_pipe[2];
time_t last_spawn;
uint64_t respawn_count;
char *patch;
// signals managed by this mule
uint64_t signals;
int sig;
uint8_t signum;
time_t harakiri;
time_t user_harakiri;
char name[0xff];
time_t cursed_at;
time_t no_mercy_at;
};
struct uwsgi_mule_farm {
struct uwsgi_mule *mule;
struct uwsgi_mule_farm *next;
};
struct uwsgi_farm {
int id;
char name[0xff];
int signal_pipe[2];
int queue_pipe[2];
struct uwsgi_mule_farm *mules;
};
char *uwsgi_get_cwd(void);
void warn_pipe(void);
void what_i_am_doing(void);
void goodbye_cruel_world(void);
void gracefully_kill(int);
void reap_them_all(int);
void kill_them_all(int);
void grace_them_all(int);
void end_me(int);
int bind_to_unix(char *, int, int, int);
int bind_to_tcp(char *, int, char *);
int bind_to_udp(char *, int, int);
int bind_to_unix_dgram(char *);
int timed_connect(struct pollfd *, const struct sockaddr *, int, int, int);
int uwsgi_connect(char *, int, int);
int uwsgi_connect_udp(char *);
int uwsgi_connectn(char *, uint16_t, int, int);
void daemonize(char *);
void logto(char *);
void log_request(struct wsgi_request *);
void get_memusage(uint64_t *, uint64_t *);
void harakiri(void);
void stats(int);
#ifdef UWSGI_XML
void uwsgi_xml_config(char *, struct wsgi_request *, char *[]);
#endif
void uwsgi_500(struct wsgi_request *);
void uwsgi_403(struct wsgi_request *);
void uwsgi_404(struct wsgi_request *);
void uwsgi_405(struct wsgi_request *);
void uwsgi_redirect_to_slash(struct wsgi_request *);
void manage_snmp(int, uint8_t *, int, struct sockaddr_in *);
void snmp_init(void);
void uwsgi_master_manage_snmp(int);
char *uwsgi_spool_request(struct wsgi_request *, char *, size_t, char *, size_t);
void spooler(struct uwsgi_spooler *);
pid_t spooler_start(struct uwsgi_spooler *);
int uwsgi_spooler_read_header(char *, int, struct uwsgi_header *);
int uwsgi_spooler_read_content(int, char *, char **, size_t *, struct uwsgi_header *, struct stat *);
#if defined(_GNU_SOURCE) || defined(__UCLIBC__)
#define uwsgi_versionsort versionsort
#else
int uwsgi_versionsort(const struct dirent **da, const struct dirent **db);
#endif
void uwsgi_curse(int, int);
void uwsgi_curse_mule(int, int);
void uwsgi_destroy_processes(void);
void set_harakiri(int);
void set_user_harakiri(int);
void set_mule_harakiri(int);
void set_spooler_harakiri(int);
void inc_harakiri(int);
#ifdef __BIG_ENDIAN__
uint16_t uwsgi_swap16(uint16_t);
uint32_t uwsgi_swap32(uint32_t);
uint64_t uwsgi_swap64(uint64_t);
#endif
int uwsgi_parse_request(int, struct wsgi_request *, int);
int uwsgi_parse_vars(struct wsgi_request *);
int uwsgi_enqueue_message(char *, int, uint8_t, uint8_t, char *, int, int);
void manage_opt(int, char *);
int uwsgi_ping_node(int, struct wsgi_request *);
void uwsgi_async_init(void);
void async_loop();
struct wsgi_request *find_first_available_wsgi_req(void);
struct wsgi_request *find_first_accepting_wsgi_req(void);
struct wsgi_request *find_wsgi_req_by_fd(int);
struct wsgi_request *find_wsgi_req_by_id(int);
void async_schedule_to_req_green(void);
void async_schedule_to_req(void);
int async_add_fd_write(struct wsgi_request *, int, int);
int async_add_fd_read(struct wsgi_request *, int, int);
void async_reset_request(struct wsgi_request *);
struct wsgi_request *next_wsgi_req(struct wsgi_request *);
void async_add_timeout(struct wsgi_request *, int);
void uwsgi_as_root(void);
void uwsgi_close_request(struct wsgi_request *);
void wsgi_req_setup(struct wsgi_request *, int, struct uwsgi_socket *);
int wsgi_req_recv(int, struct wsgi_request *);
int wsgi_req_async_recv(struct wsgi_request *);
int wsgi_req_accept(int, struct wsgi_request *);
int wsgi_req_simple_accept(struct wsgi_request *, int);
#define current_wsgi_req() (*uwsgi.current_wsgi_req)()
void sanitize_args(void);
void env_to_arg(char *, char *);
void parse_sys_envs(char **);
void uwsgi_log(const char *, ...);
void uwsgi_log_verbose(const char *, ...);
void uwsgi_logfile_write(const char *, ...);
void *uwsgi_load_plugin(int, char *, char *);
int unconfigured_hook(struct wsgi_request *);
void uwsgi_ini_config(char *, char *[]);
#ifdef UWSGI_YAML
void uwsgi_yaml_config(char *, char *[]);
#endif
#ifdef UWSGI_JSON
void uwsgi_json_config(char *, char *[]);
#endif
int uwsgi_strncmp(char *, int, char *, int);
int uwsgi_strnicmp(char *, int, char *, int);
int uwsgi_startswith(char *, char *, int);
char *uwsgi_concat(int, ...);
char *uwsgi_concatn(int, ...);
char *uwsgi_concat2(char *, char *);
char *uwsgi_concat2n(char *, int, char *, int);
char *uwsgi_concat2nn(char *, int, char *, int, int *);
char *uwsgi_concat3(char *, char *, char *);
char *uwsgi_concat3n(char *, int, char *, int, char *, int);
char *uwsgi_concat4(char *, char *, char *, char *);
char *uwsgi_concat4n(char *, int, char *, int, char *, int, char *, int);
int uwsgi_get_app_id(struct wsgi_request *, char *, uint16_t, int);
char *uwsgi_strncopy(char *, int);
int master_loop(char **, char **);
int find_worker_id(pid_t);
void simple_loop();
void *simple_loop_run(void *);
int uwsgi_count_options(struct uwsgi_option *);
struct wsgi_request *simple_current_wsgi_req(void);
struct wsgi_request *threaded_current_wsgi_req(void);
void build_options(void);
int uwsgi_postbuffer_do_in_disk(struct wsgi_request *);
int uwsgi_postbuffer_do_in_mem(struct wsgi_request *);
void uwsgi_register_loop(char *, void (*)(void));
void *uwsgi_get_loop(char *);
void add_exported_option(char *, char *, int);
void add_exported_option_do(char *, char *, int, int);
ssize_t uwsgi_send_empty_pkt(int, char *, uint8_t, uint8_t);
int uwsgi_waitfd_event(int, int, int);
#define uwsgi_waitfd(a, b) uwsgi_waitfd_event(a, b, POLLIN)
#define uwsgi_waitfd_write(a, b) uwsgi_waitfd_event(a, b, POLLOUT)
int uwsgi_hooked_parse_dict_dgram(int, char *, size_t, uint8_t, uint8_t, void (*)(char *, uint16_t, char *, uint16_t, void *), void *);
int uwsgi_hooked_parse(char *, size_t, void (*)(char *, uint16_t, char *, uint16_t, void *), void *);
int uwsgi_hooked_parse_array(char *, size_t, void (*) (uint16_t, char *, uint16_t, void *), void *);
int uwsgi_get_dgram(int, struct wsgi_request *);
int uwsgi_string_sendto(int, uint8_t, uint8_t, struct sockaddr *, socklen_t, char *, size_t);
void uwsgi_stdin_sendto(char *, uint8_t, uint8_t);
char *generate_socket_name(char *);
#define UMIN(a,b) ((a)>(b)?(b):(a))
#define UMAX(a,b) ((a)<(b)?(b):(a))
ssize_t uwsgi_send_message(int, uint8_t, uint8_t, char *, uint16_t, int, ssize_t, int);
int uwsgi_cache_set2(struct uwsgi_cache *, char *, uint16_t, char *, uint64_t, uint64_t, uint64_t);
int uwsgi_cache_del2(struct uwsgi_cache *, char *, uint16_t, uint64_t, uint16_t);
char *uwsgi_cache_get2(struct uwsgi_cache *, char *, uint16_t, uint64_t *);
char *uwsgi_cache_get3(struct uwsgi_cache *, char *, uint16_t, uint64_t *, uint64_t *);
char *uwsgi_cache_get4(struct uwsgi_cache *, char *, uint16_t, uint64_t *, uint64_t *);
uint32_t uwsgi_cache_exists2(struct uwsgi_cache *, char *, uint16_t);
struct uwsgi_cache *uwsgi_cache_create(char *);
struct uwsgi_cache *uwsgi_cache_by_name(char *);
struct uwsgi_cache *uwsgi_cache_by_namelen(char *, uint16_t);
void uwsgi_cache_create_all(void);
void uwsgi_cache_sync_from_nodes(struct uwsgi_cache *);
void uwsgi_cache_setup_nodes(struct uwsgi_cache *);
int64_t uwsgi_cache_num2(struct uwsgi_cache *, char *, uint16_t);
void uwsgi_cache_sync_all(void);
void uwsgi_cache_start_sweepers(void);
void uwsgi_cache_start_sync_servers(void);
void *uwsgi_malloc(size_t);
void *uwsgi_calloc(size_t);
int event_queue_init(void);
void *event_queue_alloc(int);
int event_queue_add_fd_read(int, int);
int event_queue_add_fd_write(int, int);
int event_queue_del_fd(int, int, int);
int event_queue_wait(int, int, int *);
int event_queue_wait_multi(int, int, void *, int);
int event_queue_interesting_fd(void *, int);
int event_queue_interesting_fd_has_error(void *, int);
int event_queue_fd_write_to_read(int, int);
int event_queue_fd_read_to_write(int, int);
int event_queue_fd_readwrite_to_read(int, int);
int event_queue_fd_readwrite_to_write(int, int);
int event_queue_fd_read_to_readwrite(int, int);
int event_queue_fd_write_to_readwrite(int, int);
int event_queue_interesting_fd_is_read(void *, int);
int event_queue_interesting_fd_is_write(void *, int);
int event_queue_add_timer(int, int *, int);
struct uwsgi_timer *event_queue_ack_timer(int);
int event_queue_add_file_monitor(int, char *, int *);
struct uwsgi_fmon *event_queue_ack_file_monitor(int, int);
int uwsgi_register_signal(uint8_t, char *, void *, uint8_t);
int uwsgi_add_file_monitor(uint8_t, char *);
int uwsgi_add_timer(uint8_t, int);
int uwsgi_signal_add_rb_timer(uint8_t, int, int);
int uwsgi_signal_handler(uint8_t);
void uwsgi_route_signal(uint8_t);
int uwsgi_start(void *);
int uwsgi_register_rpc(char *, struct uwsgi_plugin *, uint8_t, void *);
uint64_t uwsgi_rpc(char *, uint8_t, char **, uint16_t *, char **);
char *uwsgi_do_rpc(char *, char *, uint8_t, char **, uint16_t *, uint64_t *);
void uwsgi_rpc_init(void);
char *uwsgi_cheap_string(char *, int);
int uwsgi_parse_array(char *, uint16_t, char **, uint16_t *, uint8_t *);
struct uwsgi_gateway *register_gateway(char *, void (*)(int, void *), void *);
void gateway_respawn(int);
void uwsgi_gateway_go_cheap(char *, int, int *);
char *uwsgi_open_and_read(char *, size_t *, int, char *[]);
char *uwsgi_get_last_char(char *, char);
char *uwsgi_get_last_charn(char *, size_t, char);
void uwsgi_spawn_daemon(struct uwsgi_daemon *);
void uwsgi_detach_daemons();
void emperor_loop(void);
char *uwsgi_num2str(int);
char *uwsgi_float2str(float);
char *uwsgi_64bit2str(int64_t);
char *uwsgi_size2str(size_t);
char *magic_sub(char *, size_t, size_t *, char *[]);
void init_magic_table(char *[]);
char *uwsgi_req_append(struct wsgi_request *, char *, uint16_t, char *, uint16_t);
int uwsgi_req_append_path_info_with_index(struct wsgi_request *, char *, uint16_t);
int is_unix(char *, int);
int is_a_number(char *);
char *uwsgi_resolve_ip(char *);
void uwsgi_init_queue(void);
char *uwsgi_queue_get(uint64_t, uint64_t *);
char *uwsgi_queue_pull(uint64_t *);
int uwsgi_queue_push(char *, uint64_t);
char *uwsgi_queue_pop(uint64_t *);
int uwsgi_queue_set(uint64_t, char *, uint64_t);
struct uwsgi_subscribe_req {
char *key;
uint16_t keylen;
char *address;
uint16_t address_len;
char *auth;
uint16_t auth_len;
uint8_t modifier1;
uint8_t modifier2;
uint64_t cores;
uint64_t load;
uint64_t weight;
char *sign;
uint16_t sign_len;
time_t unix_check;
char *base;
uint16_t base_len;
char *sni_key;
uint16_t sni_key_len;
char *sni_crt;
uint16_t sni_crt_len;
char *sni_ca;
uint16_t sni_ca_len;
pid_t pid;
uid_t uid;
gid_t gid;
char *notify;
uint16_t notify_len;
};
void uwsgi_nuclear_blast();
void uwsgi_unix_signal(int, void (*)(int));
char *uwsgi_get_exported_opt(char *);
char *uwsgi_manage_placeholder(char *);
int uwsgi_signal_add_cron(uint8_t, int, int, int, int, int);
int uwsgi_cron_task_needs_execution(struct tm *, int, int, int, int, int);
char *uwsgi_get_optname_by_index(int);
int uwsgi_list_has_num(char *, int);
int uwsgi_list_has_str(char *, char *);
void uwsgi_cache_fix(struct uwsgi_cache *);
struct uwsgi_async_request {
struct wsgi_request *wsgi_req;
struct uwsgi_async_request *prev;
struct uwsgi_async_request *next;
};
int event_queue_read(void);
int event_queue_write(void);
void uwsgi_help(char *, char *, void *);
void uwsgi_print_sym(char *, char *, void *);
int uwsgi_str2_num(char *);
int uwsgi_str3_num(char *);
int uwsgi_str4_num(char *);
#ifdef __linux__
#if !defined(__ia64__)
void linux_namespace_start(void *);
void linux_namespace_jail(void);
#endif
void uwsgi_master_manage_setns(int);
void uwsgi_setns(char *);
void uwsgi_setns_preopen(void);
#endif
int uwsgi_amqp_consume_queue(int, char *, char *, char *, char *, char *, char *);
char *uwsgi_amqp_consume(int, uint64_t *, char **);
int uwsgi_file_serve(struct wsgi_request *, char *, uint16_t, char *, uint16_t, int);
int uwsgi_starts_with(char *, int, char *, int);
int uwsgi_static_want_gzip(struct wsgi_request *, char *, size_t *, struct stat *);
#ifdef __sun__
time_t timegm(struct tm *);
#endif
uint64_t uwsgi_str_num(char *, int);
size_t uwsgi_str_occurence(char *, size_t, char);
int uwsgi_proto_base_write(struct wsgi_request *, char *, size_t);
int uwsgi_proto_base_writev(struct wsgi_request *, struct iovec *, size_t *);
#ifdef UWSGI_SSL
int uwsgi_proto_ssl_write(struct wsgi_request *, char *, size_t);
#endif
int uwsgi_proto_base_write_header(struct wsgi_request *, char *, size_t);
ssize_t uwsgi_proto_base_read_body(struct wsgi_request *, char *, size_t);
ssize_t uwsgi_proto_noop_read_body(struct wsgi_request *, char *, size_t);
#ifdef UWSGI_SSL
ssize_t uwsgi_proto_ssl_read_body(struct wsgi_request *, char *, size_t);
#endif
int uwsgi_proto_base_accept(struct wsgi_request *, int);
void uwsgi_proto_base_close(struct wsgi_request *);
#ifdef UWSGI_SSL
int uwsgi_proto_ssl_accept(struct wsgi_request *, int);
void uwsgi_proto_ssl_close(struct wsgi_request *);
#endif
uint16_t proto_base_add_uwsgi_header(struct wsgi_request *, char *, uint16_t, char *, uint16_t);
uint16_t proto_base_add_uwsgi_var(struct wsgi_request *, char *, uint16_t, char *, uint16_t);
// protocols
void uwsgi_proto_uwsgi_setup(struct uwsgi_socket *);
void uwsgi_proto_puwsgi_setup(struct uwsgi_socket *);
void uwsgi_proto_raw_setup(struct uwsgi_socket *);
void uwsgi_proto_http_setup(struct uwsgi_socket *);
void uwsgi_proto_http11_setup(struct uwsgi_socket *);
#ifdef UWSGI_SSL
void uwsgi_proto_https_setup(struct uwsgi_socket *);
void uwsgi_proto_suwsgi_setup(struct uwsgi_socket *);
#endif
#ifdef UWSGI_ZEROMQ
void uwsgi_proto_zmq_setup(struct uwsgi_socket *);
#endif
void uwsgi_proto_fastcgi_setup(struct uwsgi_socket *);
void uwsgi_proto_fastcgi_nph_setup(struct uwsgi_socket *);
void uwsgi_proto_scgi_setup(struct uwsgi_socket *);
void uwsgi_proto_scgi_nph_setup(struct uwsgi_socket *);
int uwsgi_num2str2(int, char *);
void uwsgi_add_socket_from_fd(struct uwsgi_socket *, int);
char *uwsgi_split3(char *, size_t, char, char **, size_t *, char **, size_t *, char **, size_t *);
char *uwsgi_split4(char *, size_t, char, char **, size_t *, char **, size_t *, char **, size_t *, char **, size_t *);
char *uwsgi_netstring(char *, size_t, char **, size_t *);
char *uwsgi_str_split_nget(char *, size_t, char, size_t, size_t *);
int uwsgi_get_socket_num(struct uwsgi_socket *);
struct uwsgi_socket *uwsgi_new_socket(char *);
struct uwsgi_socket *uwsgi_new_shared_socket(char *);
struct uwsgi_socket *uwsgi_del_socket(struct uwsgi_socket *);
void uwsgi_close_all_sockets(void);
void uwsgi_shutdown_all_sockets(void);
void uwsgi_close_all_unshared_sockets(void);
struct uwsgi_string_list *uwsgi_string_new_list(struct uwsgi_string_list **, char *);
#if defined(UWSGI_PCRE) || defined(UWSGI_PCRE2)
struct uwsgi_regexp_list *uwsgi_regexp_custom_new_list(struct uwsgi_regexp_list **, char *, char *);
#define uwsgi_regexp_new_list(x, y) uwsgi_regexp_custom_new_list(x, y, NULL);
#endif
void uwsgi_string_del_list(struct uwsgi_string_list **, struct uwsgi_string_list *);
void uwsgi_init_all_apps(void);
void uwsgi_init_worker_mount_apps(void);
void uwsgi_socket_nb(int);
void uwsgi_socket_b(int);
int uwsgi_write_nb(int, char *, size_t, int);
int uwsgi_read_nb(int, char *, size_t, int);
ssize_t uwsgi_read_true_nb(int, char *, size_t, int);
int uwsgi_read_whole_true_nb(int, char *, size_t, int);
int uwsgi_read_uh(int fd, struct uwsgi_header *, int);
int uwsgi_proxy_nb(struct wsgi_request *, char *, struct uwsgi_buffer *, size_t, int);
int uwsgi_read_with_realloc(int, char **, size_t *, int, uint8_t *, uint8_t *);
int uwsgi_write_true_nb(int, char *, size_t, int);
void uwsgi_destroy_request(struct wsgi_request *);
void uwsgi_systemd_init(char *);
void uwsgi_sig_pause(void);
void uwsgi_ignition(void);
int uwsgi_respawn_worker(int);
socklen_t socket_to_in_addr(char *, char *, int, struct sockaddr_in *);
socklen_t socket_to_un_addr(char *, struct sockaddr_un *);
socklen_t socket_to_in_addr6(char *, char *, int, struct sockaddr_in6 *);
int uwsgi_get_shared_socket_fd_by_num(int);
struct uwsgi_socket *uwsgi_get_shared_socket_by_num(int);
struct uwsgi_socket *uwsgi_get_socket_by_num(int);
int uwsgi_get_shared_socket_num(struct uwsgi_socket *);
#ifdef __linux__
void uwsgi_set_cgroup(void);
long uwsgi_num_from_file(char *, int);
#endif
void uwsgi_add_sockets_to_queue(int, int);
void uwsgi_del_sockets_from_queue(int);
int uwsgi_run_command_and_wait(char *, char *);
int uwsgi_run_command_putenv_and_wait(char *, char *, char **, unsigned int);
int uwsgi_call_symbol(char *);
void uwsgi_manage_signal_cron(time_t);
pid_t uwsgi_run_command(char *, int *, int);
void uwsgi_manage_command_cron(time_t);
int *uwsgi_attach_fd(int, int *, char *, size_t);
int uwsgi_count_sockets(struct uwsgi_socket *);
int uwsgi_file_exists(char *);
int uwsgi_signal_registered(uint8_t);
int uwsgi_endswith(char *, char *);
void uwsgi_chown(char *, char *);
char *uwsgi_get_binary_path(char *);
char *uwsgi_lower(char *, size_t);
int uwsgi_num2str2n(int, char *, int);
void create_logpipe(void);
char *uwsgi_str_contains(char *, int, char);
int uwsgi_simple_parse_vars(struct wsgi_request *, char *, char *);
void uwsgi_build_mime_dict(char *);
struct uwsgi_dyn_dict *uwsgi_dyn_dict_new(struct uwsgi_dyn_dict **, char *, int, char *, int);
void uwsgi_dyn_dict_del(struct uwsgi_dyn_dict *);
void uwsgi_apply_config_pass(char symbol, char *(*)(char *));
void uwsgi_mule(int);
char *uwsgi_string_get_list(struct uwsgi_string_list **, int, size_t *);
void uwsgi_fixup_fds(int, int, struct uwsgi_gateway *);
void uwsgi_set_processname(char *);
void http_url_decode(char *, uint16_t *, char *);
void http_url_encode(char *, uint16_t *, char *);
pid_t uwsgi_fork(char *);
struct uwsgi_mule *get_mule_by_id(int);
struct uwsgi_mule_farm *uwsgi_mule_farm_new(struct uwsgi_mule_farm **, struct uwsgi_mule *);
int uwsgi_farm_has_mule(struct uwsgi_farm *, int);
struct uwsgi_farm *get_farm_by_name(char *);
struct uwsgi_subscribe_node {
char name[0xff];
uint16_t len;
uint8_t modifier1;
uint8_t modifier2;
time_t last_check;
// absolute number of requests
uint64_t requests;
// number of requests since last subscription ping
uint64_t last_requests;
uint64_t tx;
uint64_t rx;
int death_mark;
uint64_t reference;
uint64_t cores;
uint64_t load;
uint64_t failcnt;
uint64_t weight;
uint64_t wrr;
time_t unix_check;
// used by unix credentials
pid_t pid;
uid_t uid;
gid_t gid;
char notify[102];
struct uwsgi_subscribe_slot *slot;
struct uwsgi_subscribe_node *next;
};
struct uwsgi_subscribe_slot {
char key[0xff];
uint16_t keylen;
uint32_t hash;
uint64_t hits;
struct uwsgi_subscribe_node *nodes;
struct uwsgi_subscribe_slot *prev;
struct uwsgi_subscribe_slot *next;
#ifdef UWSGI_SSL
EVP_PKEY *sign_public_key;
EVP_MD_CTX *sign_ctx;
uint8_t sni_enabled;
#endif
};
int mule_send_msg(int, char *, size_t);
uint32_t djb33x_hash(char *, uint64_t);
void create_signal_pipe(int *);
void create_msg_pipe(int *, int);
struct uwsgi_subscribe_slot *uwsgi_get_subscribe_slot(struct uwsgi_subscribe_slot **, char *, uint16_t);
struct uwsgi_subscribe_node *uwsgi_get_subscribe_node_by_name(struct uwsgi_subscribe_slot **, char *, uint16_t, char *, uint16_t);
struct uwsgi_subscribe_node *uwsgi_get_subscribe_node(struct uwsgi_subscribe_slot **, char *, uint16_t);
int uwsgi_remove_subscribe_node(struct uwsgi_subscribe_slot **, struct uwsgi_subscribe_node *);
struct uwsgi_subscribe_node *uwsgi_add_subscribe_node(struct uwsgi_subscribe_slot **, struct uwsgi_subscribe_req *);
ssize_t uwsgi_mule_get_msg(int, int, char *, size_t, int);
int uwsgi_signal_wait(int);
struct uwsgi_app *uwsgi_add_app(int, uint8_t, char *, int, void *, void *);
int uwsgi_signal_send(int, uint8_t);
int uwsgi_remote_signal_send(char *, uint8_t);
void uwsgi_configure();
int uwsgi_read_response(int, struct uwsgi_header *, int, char **);
char *uwsgi_simple_file_read(char *);
void uwsgi_send_subscription(char *, char *, size_t, uint8_t, uint8_t, uint8_t, char *, char *, char *, char *, char *);
void uwsgi_send_subscription_from_fd(int, char *, char *, size_t, uint8_t, uint8_t, uint8_t, char *, char *, char *, char *, char *);
void uwsgi_subscribe(char *, uint8_t);
void uwsgi_subscribe2(char *, uint8_t);
int uwsgi_is_bad_connection(int);
int uwsgi_long2str2n(unsigned long long, char *, int);
#ifdef __linux__
void uwsgi_build_unshare(char *, int *);
#ifdef MADV_MERGEABLE
void uwsgi_linux_ksm_map(void);
#endif
#endif
#ifdef UWSGI_CAP
int uwsgi_build_cap(char *, cap_value_t **);
void uwsgi_apply_cap(cap_value_t *, int);
#endif
void uwsgi_register_logger(char *, ssize_t(*func) (struct uwsgi_logger *, char *, size_t));
void uwsgi_append_logger(struct uwsgi_logger *);
void uwsgi_append_req_logger(struct uwsgi_logger *);
struct uwsgi_logger *uwsgi_get_logger(char *);
struct uwsgi_logger *uwsgi_get_logger_from_id(char *);
char *uwsgi_getsockname(int);
char *uwsgi_get_var(struct wsgi_request *, char *, uint16_t, uint16_t *);
struct uwsgi_gateway_socket *uwsgi_new_gateway_socket(char *, char *);
struct uwsgi_gateway_socket *uwsgi_new_gateway_socket_from_fd(int, char *);
void escape_shell_arg(char *, size_t, char *);
void escape_json(char *, size_t, char *);
void *uwsgi_malloc_shared(size_t);
void *uwsgi_calloc_shared(size_t);
struct uwsgi_spooler *uwsgi_new_spooler(char *);
struct uwsgi_spooler *uwsgi_get_spooler_by_name(char *, size_t);
int uwsgi_zerg_attach(char *);
int uwsgi_manage_opt(char *, char *);
void uwsgi_opt_print(char *, char *, void *);
void uwsgi_opt_true(char *, char *, void *);
void uwsgi_opt_false(char *, char *, void *);
void uwsgi_opt_set_str(char *, char *, void *);
void uwsgi_opt_custom(char *, char *, void *);
void uwsgi_opt_set_null(char *, char *, void *);
void uwsgi_opt_set_logger(char *, char *, void *);
void uwsgi_opt_set_req_logger(char *, char *, void *);
void uwsgi_opt_set_str_spaced(char *, char *, void *);
void uwsgi_opt_add_string_list(char *, char *, void *);
void uwsgi_opt_add_addr_list(char *, char *, void *);
void uwsgi_opt_add_string_list_custom(char *, char *, void *);
void uwsgi_opt_add_dyn_dict(char *, char *, void *);
void uwsgi_opt_binary_append_data(char *, char *, void *);
#if defined(UWSGI_PCRE) || defined(UWSGI_PCRE2)
void uwsgi_opt_pcre_jit(char *, char *, void *);
void uwsgi_opt_add_regexp_dyn_dict(char *, char *, void *);
void uwsgi_opt_add_regexp_list(char *, char *, void *);
void uwsgi_opt_add_regexp_custom_list(char *, char *, void *);
#endif
void uwsgi_opt_set_int(char *, char *, void *);
void uwsgi_opt_uid(char *, char *, void *);
void uwsgi_opt_gid(char *, char *, void *);
void uwsgi_opt_set_rawint(char *, char *, void *);
void uwsgi_opt_set_16bit(char *, char *, void *);
void uwsgi_opt_set_64bit(char *, char *, void *);
void uwsgi_opt_set_megabytes(char *, char *, void *);
void uwsgi_opt_set_dyn(char *, char *, void *);
void uwsgi_opt_set_placeholder(char *, char *, void *);
void uwsgi_opt_add_shared_socket(char *, char *, void *);
void uwsgi_opt_add_socket(char *, char *, void *);
#ifdef UWSGI_SSL
void uwsgi_opt_add_ssl_socket(char *, char *, void *);
#endif
void uwsgi_opt_add_socket_no_defer(char *, char *, void *);
void uwsgi_opt_add_lazy_socket(char *, char *, void *);
void uwsgi_opt_add_cron(char *, char *, void *);
void uwsgi_opt_add_cron2(char *, char *, void *);
void uwsgi_opt_add_unique_cron(char *, char *, void *);
void uwsgi_opt_load_plugin(char *, char *, void *);
void uwsgi_opt_load_dl(char *, char *, void *);
void uwsgi_opt_load(char *, char *, void *);
void uwsgi_opt_safe_fd(char *, char *, void *);
#ifdef UWSGI_SSL
void uwsgi_opt_add_legion_cron(char *, char *, void *);
void uwsgi_opt_add_unique_legion_cron(char *, char *, void *);
void uwsgi_opt_sni(char *, char *, void *);
struct uwsgi_string_list *uwsgi_ssl_add_sni_item(char *, char *, char *, char *, char *);
void uwsgi_ssl_del_sni_item(char *, uint16_t);
char *uwsgi_write_pem_to_file(char *, char *, size_t, char *);
#endif
void uwsgi_opt_flock(char *, char *, void *);
void uwsgi_opt_flock_wait(char *, char *, void *);
void uwsgi_opt_load_ini(char *, char *, void *);
#ifdef UWSGI_XML
void uwsgi_opt_load_xml(char *, char *, void *);
#endif
#ifdef UWSGI_YAML
void uwsgi_opt_load_yml(char *, char *, void *);
#endif
#ifdef UWSGI_JSON
void uwsgi_opt_load_json(char *, char *, void *);
#endif
void uwsgi_opt_set_umask(char *, char *, void *);
void uwsgi_opt_add_spooler(char *, char *, void *);
void uwsgi_opt_add_daemon(char *, char *, void *);
void uwsgi_opt_add_daemon2(char *, char *, void *);
void uwsgi_opt_set_uid(char *, char *, void *);
void uwsgi_opt_set_gid(char *, char *, void *);
void uwsgi_opt_set_immediate_uid(char *, char *, void *);
void uwsgi_opt_set_immediate_gid(char *, char *, void *);
void uwsgi_opt_set_env(char *, char *, void *);
void uwsgi_opt_unset_env(char *, char *, void *);
void uwsgi_opt_pidfile_signal(char *, char *, void *);
void uwsgi_opt_check_static(char *, char *, void *);
void uwsgi_opt_fileserve_mode(char *, char *, void *);
void uwsgi_opt_static_map(char *, char *, void *);
void uwsgi_opt_add_mule(char *, char *, void *);
void uwsgi_opt_add_mules(char *, char *, void *);
void uwsgi_opt_add_farm(char *, char *, void *);
void uwsgi_opt_signal(char *, char *, void *);
void uwsgi_opt_snmp(char *, char *, void *);
void uwsgi_opt_snmp_community(char *, char *, void *);
void uwsgi_opt_logfile_chmod(char *, char *, void *);
void uwsgi_opt_log_date(char *, char *, void *);
void uwsgi_opt_chmod_socket(char *, char *, void *);
void uwsgi_opt_max_vars(char *, char *, void *);
void uwsgi_opt_deprecated(char *, char *, void *);
void uwsgi_opt_noop(char *, char *, void *);
void uwsgi_opt_logic(char *, char *, void *);
int uwsgi_logic_opt_for(char *, char *);
int uwsgi_logic_opt_for_glob(char *, char *);
int uwsgi_logic_opt_for_times(char *, char *);
int uwsgi_logic_opt_for_readline(char *, char *);
int uwsgi_logic_opt_if_env(char *, char *);
int uwsgi_logic_opt_if_not_env(char *, char *);
int uwsgi_logic_opt_if_opt(char *, char *);
int uwsgi_logic_opt_if_not_opt(char *, char *);
int uwsgi_logic_opt_if_exists(char *, char *);
int uwsgi_logic_opt_if_not_exists(char *, char *);
int uwsgi_logic_opt_if_file(char *, char *);
int uwsgi_logic_opt_if_not_file(char *, char *);
int uwsgi_logic_opt_if_dir(char *, char *);
int uwsgi_logic_opt_if_not_dir(char *, char *);
int uwsgi_logic_opt_if_reload(char *, char *);
int uwsgi_logic_opt_if_not_reload(char *, char *);
int uwsgi_logic_opt_if_plugin(char *, char *);
int uwsgi_logic_opt_if_not_plugin(char *, char *);
int uwsgi_logic_opt_if_hostname(char *, char *);
int uwsgi_logic_opt_if_not_hostname(char *, char *);
int uwsgi_logic_opt_if_hostname_match(char *, char *);
int uwsgi_logic_opt_if_not_hostname_match(char *, char *);
void uwsgi_opt_resolve(char *, char *, void *);
#ifdef UWSGI_CAP
void uwsgi_opt_set_cap(char *, char *, void *);
void uwsgi_opt_set_emperor_cap(char *, char *, void *);
#endif
#ifdef __linux__
void uwsgi_opt_set_unshare(char *, char *, void *);
#endif
int uwsgi_tmpfd();
FILE *uwsgi_tmpfile();
#ifdef UWSGI_ROUTING
struct uwsgi_router *uwsgi_register_router(char *, int (*)(struct uwsgi_route *, char *));
void uwsgi_opt_add_route(char *, char *, void *);
int uwsgi_apply_routes(struct wsgi_request *);
void uwsgi_apply_final_routes(struct wsgi_request *);
int uwsgi_apply_error_routes(struct wsgi_request *);
int uwsgi_apply_response_routes(struct wsgi_request *);
int uwsgi_apply_routes_do(struct uwsgi_route *, struct wsgi_request *, char *, uint16_t);
void uwsgi_register_embedded_routers(void);
void uwsgi_routing_dump();
struct uwsgi_buffer *uwsgi_routing_translate(struct wsgi_request *, struct uwsgi_route *, char *, uint16_t, char *, size_t);
int uwsgi_route_api_func(struct wsgi_request *, char *, char *);
struct uwsgi_route_condition *uwsgi_register_route_condition(char *, int (*) (struct wsgi_request *, struct uwsgi_route *));
void uwsgi_fixup_routes(struct uwsgi_route *);
#endif
void uwsgi_reload(char **);
char *uwsgi_chomp(char *);
char *uwsgi_chomp2(char *);
int uwsgi_file_to_string_list(char *, struct uwsgi_string_list **);
void uwsgi_backtrace(int);
void uwsgi_check_logrotate(void);
char *uwsgi_check_touches(struct uwsgi_string_list *);
void uwsgi_manage_zerg(int, int, int *);
time_t uwsgi_now(void);
int uwsgi_calc_cheaper(void);
int uwsgi_cheaper_algo_spare(int);
int uwsgi_cheaper_algo_backlog(int);
int uwsgi_cheaper_algo_backlog2(int);
int uwsgi_cheaper_algo_manual(int);
int uwsgi_master_log(void);
int uwsgi_master_req_log(void);
void uwsgi_flush_logs(void);
void uwsgi_register_cheaper_algo(char *, int (*)(int));
void uwsgi_setup_locking(void);
int uwsgi_fcntl_lock(int);
int uwsgi_fcntl_is_locked(int);
void uwsgi_emulate_cow_for_apps(int);
char *uwsgi_read_fd(int, size_t *, int);
void uwsgi_setup_post_buffering(void);
struct uwsgi_lock_item *uwsgi_lock_ipcsem_init(char *);
void uwsgi_write_pidfile(char *);
void uwsgi_write_pidfile_explicit(char *, pid_t);
int uwsgi_write_intfile(char *, int);
void uwsgi_protected_close(int);
ssize_t uwsgi_protected_read(int, void *, size_t);
int uwsgi_socket_uniq(struct uwsgi_socket *, struct uwsgi_socket *);
int uwsgi_socket_is_already_bound(char *name);
char *uwsgi_expand_path(char *, int, char *);
int uwsgi_try_autoload(char *);
uint64_t uwsgi_micros(void);
uint64_t uwsgi_millis(void);
int uwsgi_is_file(char *);
int uwsgi_is_file2(char *, struct stat *);
int uwsgi_is_dir(char *);
int uwsgi_is_link(char *);
void uwsgi_receive_signal(int, char *, int);
void uwsgi_exec_atexit(void);
struct uwsgi_stats {
char *base;
off_t pos;
size_t tabs;
size_t chunk;
size_t size;
int minified;
int dirty;
};
struct uwsgi_stats_pusher_instance;
struct uwsgi_stats_pusher {
char *name;
void (*func) (struct uwsgi_stats_pusher_instance *, time_t, char *, size_t);
int raw;
struct uwsgi_stats_pusher *next;
};
struct uwsgi_stats_pusher_instance {
struct uwsgi_stats_pusher *pusher;
char *arg;
void *data;
int raw;
int configured;
int freq;
time_t last_run;
// retries
int needs_retry;
int retries;
int max_retries;
int retry_delay;
time_t next_retry;
struct uwsgi_stats_pusher_instance *next;
};
struct uwsgi_thread;
void uwsgi_stats_pusher_loop(struct uwsgi_thread *);
void uwsgi_stats_pusher_setup(void);
void uwsgi_send_stats(int, struct uwsgi_stats *(*func) (void));
struct uwsgi_stats *uwsgi_master_generate_stats(void);
struct uwsgi_stats_pusher * uwsgi_register_stats_pusher(char *, void (*)(struct uwsgi_stats_pusher_instance *, time_t, char *, size_t));
struct uwsgi_stats *uwsgi_stats_new(size_t);
int uwsgi_stats_symbol(struct uwsgi_stats *, char);
int uwsgi_stats_comma(struct uwsgi_stats *);
int uwsgi_stats_object_open(struct uwsgi_stats *);
int uwsgi_stats_object_close(struct uwsgi_stats *);
int uwsgi_stats_list_open(struct uwsgi_stats *);
int uwsgi_stats_list_close(struct uwsgi_stats *);
int uwsgi_stats_keyval(struct uwsgi_stats *, char *, char *);
int uwsgi_stats_keyval_comma(struct uwsgi_stats *, char *, char *);
int uwsgi_stats_keyvalnum(struct uwsgi_stats *, char *, char *, unsigned long long);
int uwsgi_stats_keyvalnum_comma(struct uwsgi_stats *, char *, char *, unsigned long long);
int uwsgi_stats_keyvaln(struct uwsgi_stats *, char *, char *, int);
int uwsgi_stats_keyvaln_comma(struct uwsgi_stats *, char *, char *, int);
int uwsgi_stats_key(struct uwsgi_stats *, char *);
int uwsgi_stats_keylong(struct uwsgi_stats *, char *, unsigned long long);
int uwsgi_stats_keylong_comma(struct uwsgi_stats *, char *, unsigned long long);
int uwsgi_stats_keyslong(struct uwsgi_stats *, char *, long long);
int uwsgi_stats_keyslong_comma(struct uwsgi_stats *, char *, long long);
int uwsgi_stats_str(struct uwsgi_stats *, char *);
char *uwsgi_substitute(char *, char *, char *);
void uwsgi_opt_add_custom_option(char *, char *, void *);
void uwsgi_opt_cflags(char *, char *, void *);
void uwsgi_opt_build_plugin(char *, char *, void *);
void uwsgi_opt_dot_h(char *, char *, void *);
void uwsgi_opt_config_py(char *, char *, void *);
void uwsgi_opt_connect_and_read(char *, char *, void *);
void uwsgi_opt_extract(char *, char *, void *);
char *uwsgi_get_dot_h();
char *uwsgi_get_config_py();
char *uwsgi_get_cflags();
struct uwsgi_string_list *uwsgi_string_list_has_item(struct uwsgi_string_list *, char *, size_t);
void trigger_harakiri(int);
void uwsgi_setup_systemd();
void uwsgi_setup_upstart();
void uwsgi_setup_zerg();
void uwsgi_setup_inherited_sockets();
void uwsgi_setup_emperor();
#ifdef UWSGI_SSL
void uwsgi_ssl_init(void);
SSL_CTX *uwsgi_ssl_new_server_context(char *, char *, char *, char *, char *);
char *uwsgi_rsa_sign(char *, char *, size_t, unsigned int *);
char *uwsgi_sanitize_cert_filename(char *, char *, uint16_t);
void uwsgi_opt_scd(char *, char *, void *);
int uwsgi_subscription_sign_check(struct uwsgi_subscribe_slot *, struct uwsgi_subscribe_req *);
char *uwsgi_sha1(char *, size_t, char *);
char *uwsgi_sha1_2n(char *, size_t, char *, size_t, char *);
char *uwsgi_md5(char *, size_t, char *);
#endif
void uwsgi_opt_ssa(char *, char *, void *);
int uwsgi_no_subscriptions(struct uwsgi_subscribe_slot **);
void uwsgi_deadlock_check(pid_t);
struct uwsgi_logchunk {
char *name;
char *ptr;
size_t len;
int vec;
long pos;
long pos_len;
int type;
int free;
ssize_t(*func) (struct wsgi_request *, char **);
struct uwsgi_logchunk *next;
};
void uwsgi_build_log_format(char *);
void uwsgi_add_logchunk(int, int, char *, size_t);
struct uwsgi_logchunk *uwsgi_register_logchunk(char *, ssize_t (*)(struct wsgi_request *, char **), int);
void uwsgi_logit_simple(struct wsgi_request *);
void uwsgi_logit_lf(struct wsgi_request *);
void uwsgi_logit_lf_strftime(struct wsgi_request *);
struct uwsgi_logvar *uwsgi_logvar_get(struct wsgi_request *, char *, uint8_t);
void uwsgi_logvar_add(struct wsgi_request *, char *, uint8_t, char *, uint8_t);
// scanners are instances of 'imperial_monitor'
struct uwsgi_emperor_scanner {
char *arg;
int fd;
void *data;
void (*event_func) (struct uwsgi_emperor_scanner *);
struct uwsgi_imperial_monitor *monitor;
struct uwsgi_emperor_scanner *next;
};
void uwsgi_register_imperial_monitor(char *, void (*)(struct uwsgi_emperor_scanner *), void (*)(struct uwsgi_emperor_scanner *));
int uwsgi_emperor_is_valid(char *);
// an instance (called vassal) is a uWSGI stack running
// it is identified by the name of its config file
// a vassal is 'loyal' as soon as it manages a request
struct uwsgi_instance {
struct uwsgi_instance *ui_prev;
struct uwsgi_instance *ui_next;
char name[0xff];
pid_t pid;
int status;
time_t born;
time_t last_mod;
time_t last_loyal;
time_t last_accepting;
time_t last_ready;
time_t last_run;
time_t first_run;
time_t last_heartbeat;
uint64_t respawns;
int use_config;
int pipe[2];
int pipe_config[2];
char *config;
uint32_t config_len;
int loyal;
int zerg;
int ready;
int accepting;
struct uwsgi_emperor_scanner *scanner;
uid_t uid;
gid_t gid;
int on_demand_fd;
char *socket_name;
time_t cursed_at;
};
struct uwsgi_instance *emperor_get_by_fd(int);
struct uwsgi_instance *emperor_get(char *);
void emperor_stop(struct uwsgi_instance *);
void emperor_curse(struct uwsgi_instance *);
void emperor_respawn(struct uwsgi_instance *, time_t);
void emperor_add(struct uwsgi_emperor_scanner *, char *, time_t, char *, uint32_t, uid_t, gid_t, char *);
void emperor_back_to_ondemand(struct uwsgi_instance *);
void uwsgi_exec_command_with_args(char *);
void uwsgi_imperial_monitor_glob_init(struct uwsgi_emperor_scanner *);
void uwsgi_imperial_monitor_directory_init(struct uwsgi_emperor_scanner *);
void uwsgi_imperial_monitor_directory(struct uwsgi_emperor_scanner *);
void uwsgi_imperial_monitor_glob(struct uwsgi_emperor_scanner *);
void uwsgi_register_clock(struct uwsgi_clock *);
void uwsgi_set_clock(char *name);
void uwsgi_init_default(void);
void uwsgi_setup_reload(void);
void uwsgi_autoload_plugins_by_name(char *);
void uwsgi_commandline_config(void);
void uwsgi_setup_log(void);
void uwsgi_setup_log_master(void);
void uwsgi_setup_shared_sockets(void);
void uwsgi_setup_mules_and_farms(void);
void uwsgi_setup_workers(void);
void uwsgi_map_sockets(void);
void uwsgi_set_cpu_affinity(void);
void uwsgi_emperor_start(void);
void uwsgi_bind_sockets(void);
void uwsgi_set_sockets_protocols(void);
struct uwsgi_buffer *uwsgi_buffer_new(size_t);
int uwsgi_buffer_append(struct uwsgi_buffer *, char *, size_t);
int uwsgi_buffer_fix(struct uwsgi_buffer *, size_t);
int uwsgi_buffer_ensure(struct uwsgi_buffer *, size_t);
void uwsgi_buffer_destroy(struct uwsgi_buffer *);
int uwsgi_buffer_u8(struct uwsgi_buffer *, uint8_t);
int uwsgi_buffer_byte(struct uwsgi_buffer *, char);
int uwsgi_buffer_u16le(struct uwsgi_buffer *, uint16_t);
int uwsgi_buffer_u16be(struct uwsgi_buffer *, uint16_t);
int uwsgi_buffer_u32be(struct uwsgi_buffer *, uint32_t);
int uwsgi_buffer_u32le(struct uwsgi_buffer *, uint32_t);
int uwsgi_buffer_u64le(struct uwsgi_buffer *, uint64_t);
int uwsgi_buffer_f32be(struct uwsgi_buffer *, float);
int uwsgi_buffer_u24be(struct uwsgi_buffer *, uint32_t);
int uwsgi_buffer_u64be(struct uwsgi_buffer *, uint64_t);
int uwsgi_buffer_f64be(struct uwsgi_buffer *, double);
int uwsgi_buffer_num64(struct uwsgi_buffer *, int64_t);
int uwsgi_buffer_append_keyval(struct uwsgi_buffer *, char *, uint16_t, char *, uint16_t);
int uwsgi_buffer_append_keyval32(struct uwsgi_buffer *, char *, uint32_t, char *, uint32_t);
int uwsgi_buffer_append_keynum(struct uwsgi_buffer *, char *, uint16_t, int64_t);
int uwsgi_buffer_append_valnum(struct uwsgi_buffer *, int64_t);
int uwsgi_buffer_append_ipv4(struct uwsgi_buffer *, void *);
int uwsgi_buffer_append_keyipv4(struct uwsgi_buffer *, char *, uint16_t, void *);
int uwsgi_buffer_decapitate(struct uwsgi_buffer *, size_t);
int uwsgi_buffer_append_base64(struct uwsgi_buffer *, char *, size_t);
int uwsgi_buffer_insert(struct uwsgi_buffer *, size_t, char *, size_t);
int uwsgi_buffer_insert_chunked(struct uwsgi_buffer *, size_t, size_t);
int uwsgi_buffer_append_chunked(struct uwsgi_buffer *, size_t);
int uwsgi_buffer_append_json(struct uwsgi_buffer *, char *, size_t);
int uwsgi_buffer_set_uh(struct uwsgi_buffer *, uint8_t, uint8_t);
void uwsgi_buffer_map(struct uwsgi_buffer *, char *, size_t);
struct uwsgi_buffer *uwsgi_buffer_from_file(char *);
ssize_t uwsgi_buffer_write_simple(struct wsgi_request *, struct uwsgi_buffer *);
struct uwsgi_buffer *uwsgi_to_http(struct wsgi_request *, char *, uint16_t, char *, uint16_t);
struct uwsgi_buffer *uwsgi_to_http_dumb(struct wsgi_request *, char *, uint16_t, char *, uint16_t);
ssize_t uwsgi_pipe(int, int, int);
ssize_t uwsgi_pipe_sized(int, int, size_t, int);
int uwsgi_buffer_send(struct uwsgi_buffer *, int);
void uwsgi_master_cleanup_hooks(void);
pid_t uwsgi_daemonize2();
void uwsgi_emperor_simple_do(struct uwsgi_emperor_scanner *, char *, char *, time_t, uid_t, gid_t, char *);
#if defined(__linux__)
#define UWSGI_ELF
char *uwsgi_elf_section(char *, char *, size_t *);
#endif
void uwsgi_alarm_log_check(char *, size_t);
void uwsgi_alarm_run(struct uwsgi_alarm_instance *, char *, size_t);
void uwsgi_register_alarm(char *, void (*)(struct uwsgi_alarm_instance *), void (*)(struct uwsgi_alarm_instance *, char *, size_t));
void uwsgi_register_embedded_alarms();
void uwsgi_alarms_init();
void uwsgi_alarm_trigger(char *, char *, size_t);
struct uwsgi_thread {
pthread_t tid;
pthread_attr_t tattr;
int pipe[2];
int queue;
ssize_t rlen;
void *data;
char *buf;
off_t pos;
size_t len;
uint64_t custom0;
uint64_t custom1;
uint64_t custom2;
uint64_t custom3;
// linked list for offloaded requests
struct uwsgi_offload_request *offload_requests_head;
struct uwsgi_offload_request *offload_requests_tail;
void (*func) (struct uwsgi_thread *);
};
struct uwsgi_thread *uwsgi_thread_new(void (*)(struct uwsgi_thread *));
struct uwsgi_thread *uwsgi_thread_new_with_data(void (*)(struct uwsgi_thread *), void *data);
struct uwsgi_offload_request {
// the request socket
int s;
// the peer
int fd;
int fd2;
// if set the current request is expected to end leaving
// the offload thread do its job
uint8_t takeover;
// internal state
int status;
// a filename, a socket...
char *name;
off_t pos;
char *buf;
off_t buf_pos;
size_t to_write;
size_t len;
size_t written;
// a uwsgi_buffer (will be destroyed at the end of the task)
struct uwsgi_buffer *ubuf;
struct uwsgi_offload_engine *engine;
// this pipe is used for notifications
int pipe[2];
struct uwsgi_offload_request *prev;
struct uwsgi_offload_request *next;
// added in 2.1
struct uwsgi_buffer *ubuf1;
struct uwsgi_buffer *ubuf2;
struct uwsgi_buffer *ubuf3;
struct uwsgi_buffer *ubuf4;
struct uwsgi_buffer *ubuf5;
struct uwsgi_buffer *ubuf6;
struct uwsgi_buffer *ubuf7;
struct uwsgi_buffer *ubuf8;
int64_t custom1;
int64_t custom2;
int64_t custom3;
int64_t custom4;
int64_t custom5;
int64_t custom6;
int64_t custom7;
int64_t custom8;
void *data;
void (*free)(struct uwsgi_offload_request *);
};
struct uwsgi_offload_engine {
char *name;
int (*prepare_func)(struct wsgi_request *, struct uwsgi_offload_request *);
int (*event_func) (struct uwsgi_thread *, struct uwsgi_offload_request *, int);
struct uwsgi_offload_engine *next;
};
struct uwsgi_offload_engine *uwsgi_offload_engine_by_name(char *);
struct uwsgi_offload_engine *uwsgi_offload_register_engine(char *, int (*)(struct wsgi_request *, struct uwsgi_offload_request *), int (*) (struct uwsgi_thread *, struct uwsgi_offload_request *, int));
void uwsgi_offload_setup(struct uwsgi_offload_engine *, struct uwsgi_offload_request *, struct wsgi_request *, uint8_t);
int uwsgi_offload_run(struct wsgi_request *, struct uwsgi_offload_request *, int *);
void uwsgi_offload_engines_register_all(void);
struct uwsgi_thread *uwsgi_offload_thread_start(void);
int uwsgi_offload_request_sendfile_do(struct wsgi_request *, int, size_t, size_t);
int uwsgi_offload_request_net_do(struct wsgi_request *, char *, struct uwsgi_buffer *);
int uwsgi_offload_request_memory_do(struct wsgi_request *, char *, size_t);
int uwsgi_offload_request_pipe_do(struct wsgi_request *, int, size_t);
int uwsgi_simple_sendfile(struct wsgi_request *, int, size_t, size_t);
int uwsgi_simple_write(struct wsgi_request *, char *, size_t);
void uwsgi_subscription_set_algo(char *);
struct uwsgi_subscribe_slot **uwsgi_subscription_init_ht(void);
int uwsgi_check_pidfile(char *);
void uwsgi_daemons_spawn_all();
int uwsgi_daemon_check_pid_death(pid_t);
int uwsgi_daemon_check_pid_reload(pid_t);
void uwsgi_daemons_smart_check();
void uwsgi_setup_thread_req(long, struct wsgi_request *);
void uwsgi_loop_cores_run(void *(*)(void *));
int uwsgi_kvlist_parse(char *, size_t, char, int, ...);
int uwsgi_send_http_stats(int);
ssize_t uwsgi_simple_request_read(struct wsgi_request *, char *, size_t);
int uwsgi_plugin_modifier1(char *);
void *cache_udp_server_loop(void *);
int uwsgi_user_lock(int);
int uwsgi_user_unlock(int);
void simple_loop_run_int(int);
char *uwsgi_strip(char *);
#ifdef UWSGI_SSL
void uwsgi_opt_legion(char *, char *, void *);
void uwsgi_opt_legion_mcast(char *, char *, void *);
struct uwsgi_legion *uwsgi_legion_register(char *, char *, char *, char *, char *);
void uwsgi_opt_legion_node(char *, char *, void *);
void uwsgi_legion_register_node(struct uwsgi_legion *, char *);
void uwsgi_opt_legion_quorum(char *, char *, void *);
void uwsgi_opt_legion_hook(char *, char *, void *);
void uwsgi_legion_register_hook(struct uwsgi_legion *, char *, char *);
void uwsgi_opt_legion_scroll(char *, char *, void *);
void uwsgi_legion_add(struct uwsgi_legion *);
void uwsgi_legion_announce_death(void);
char *uwsgi_ssl_rand(size_t);
void uwsgi_start_legions(void);
int uwsgi_legion_announce(struct uwsgi_legion *);
struct uwsgi_legion *uwsgi_legion_get_by_name(char *);
struct uwsgi_legion_action *uwsgi_legion_action_get(char *);
struct uwsgi_legion_action *uwsgi_legion_action_register(char *, int (*)(struct uwsgi_legion *, char *));
int uwsgi_legion_action_call(char *, struct uwsgi_legion *, struct uwsgi_string_list *);
void uwsgi_legion_atexit(void);
#endif
struct uwsgi_option *uwsgi_opt_get(char *);
int uwsgi_opt_exists(char *);
int uwsgi_valid_fd(int);
void uwsgi_close_all_fds(void);
int check_hex(char *, int);
void uwsgi_uuid(char *);
int uwsgi_uuid_cmp(char *, char *);
int uwsgi_legion_i_am_the_lord(char *);
char *uwsgi_legion_lord_scroll(char *, uint16_t *);
void uwsgi_additional_header_add(struct wsgi_request *, char *, uint16_t);
void uwsgi_remove_header(struct wsgi_request *, char *, uint16_t);
void uwsgi_proto_hooks_setup(void);
char *uwsgi_base64_decode(char *, size_t, size_t *);
char *uwsgi_base64_encode(char *, size_t, size_t *);
void uwsgi_subscribe_all(uint8_t, int);
#define uwsgi_unsubscribe_all() uwsgi_subscribe_all(1, 1)
void uwsgi_websockets_init(void);
int uwsgi_websocket_send(struct wsgi_request *, char *, size_t);
int uwsgi_websocket_send_binary(struct wsgi_request *, char *, size_t);
struct uwsgi_buffer *uwsgi_websocket_recv(struct wsgi_request *);
struct uwsgi_buffer *uwsgi_websocket_recv_nb(struct wsgi_request *);
char *uwsgi_chunked_read(struct wsgi_request *, size_t *, int, int);
uint16_t uwsgi_be16(char *);
uint32_t uwsgi_be32(char *);
uint64_t uwsgi_be64(char *);
int uwsgi_websocket_handshake(struct wsgi_request *, char *, uint16_t, char *, uint16_t, char *, uint16_t);
int uwsgi_response_prepare_headers(struct wsgi_request *, char *, uint16_t);
int uwsgi_response_prepare_headers_int(struct wsgi_request *, int);
int uwsgi_response_add_header(struct wsgi_request *, char *, uint16_t, char *, uint16_t);
int uwsgi_response_add_header_force(struct wsgi_request *, char *, uint16_t, char *, uint16_t);
int uwsgi_response_commit_headers(struct wsgi_request *);
int uwsgi_response_sendfile_do(struct wsgi_request *, int, size_t, size_t);
int uwsgi_response_sendfile_do_can_close(struct wsgi_request *, int, size_t, size_t, int);
struct uwsgi_buffer *uwsgi_proto_base_add_header(struct wsgi_request *, char *, uint16_t, char *, uint16_t);
int uwsgi_simple_wait_write_hook(int, int);
int uwsgi_simple_wait_read_hook(int, int);
int uwsgi_simple_wait_read2_hook(int, int, int, int *);
int uwsgi_simple_wait_milliseconds_hook(int);
int uwsgi_response_write_headers_do(struct wsgi_request *);
char *uwsgi_request_body_read(struct wsgi_request *, ssize_t , ssize_t *);
char *uwsgi_request_body_readline(struct wsgi_request *, ssize_t, ssize_t *);
void uwsgi_request_body_seek(struct wsgi_request *, off_t);
struct uwsgi_buffer *uwsgi_proto_base_prepare_headers(struct wsgi_request *, char *, uint16_t);
struct uwsgi_buffer *uwsgi_proto_base_cgi_prepare_headers(struct wsgi_request *, char *, uint16_t);
int uwsgi_response_write_body_do(struct wsgi_request *, char *, size_t);
int uwsgi_response_writev_body_do(struct wsgi_request *, struct iovec *, size_t);
int uwsgi_proto_base_sendfile(struct wsgi_request *, int, size_t, size_t);
#ifdef UWSGI_SSL
int uwsgi_proto_ssl_sendfile(struct wsgi_request *, int, size_t, size_t);
#endif
ssize_t uwsgi_sendfile_do(int, int, size_t, size_t);
int uwsgi_proto_base_fix_headers(struct wsgi_request *);
int uwsgi_response_add_content_length(struct wsgi_request *, uint64_t);
void uwsgi_fix_range_for_size(enum uwsgi_range*, int64_t*, int64_t*, int64_t);
void uwsgi_request_fix_range_for_size(struct wsgi_request *, int64_t);
int uwsgi_response_add_content_range(struct wsgi_request *, int64_t, int64_t, int64_t);
int uwsgi_response_add_expires(struct wsgi_request *, uint64_t);
int uwsgi_response_add_last_modified(struct wsgi_request *, uint64_t);
int uwsgi_response_add_date(struct wsgi_request *, char *, uint16_t, uint64_t);
const char *uwsgi_http_status_msg(char *, uint16_t *);
int uwsgi_stats_dump_vars(struct uwsgi_stats *, struct uwsgi_core *);
int uwsgi_stats_dump_request(struct uwsgi_stats *, struct uwsgi_core *);
int uwsgi_contains_n(char *, size_t, char *, size_t);
char *uwsgi_upload_progress_create(struct wsgi_request *, int *);
int uwsgi_upload_progress_update(struct wsgi_request *, int, size_t);
void uwsgi_upload_progress_destroy(char *, int);
void uwsgi_time_bomb(int, int);
void uwsgi_master_manage_emperor(void);
void uwsgi_master_manage_udp(int);
void uwsgi_threaded_logger_spawn(void);
void uwsgi_master_check_idle(void);
int uwsgi_master_check_workers_deadline(void);
int uwsgi_master_check_gateways_deadline(void);
int uwsgi_master_check_mules_deadline(void);
int uwsgi_master_check_spoolers_deadline(void);
int uwsgi_master_check_crons_deadline(void);
int uwsgi_master_check_spoolers_death(int);
int uwsgi_master_check_emperor_death(int);
int uwsgi_master_check_mules_death(int);
int uwsgi_master_check_gateways_death(int);
int uwsgi_master_check_daemons_death(int);
void uwsgi_master_check_death(void);
int uwsgi_master_check_reload(char **);
void uwsgi_master_commit_status(void);
void uwsgi_master_check_chain(void);
void uwsgi_master_fix_request_counters(void);
int uwsgi_master_manage_events(int);
void uwsgi_block_signal(int);
void uwsgi_unblock_signal(int);
int uwsgi_worker_is_busy(int);
void uwsgi_post_accept(struct wsgi_request *);
void uwsgi_tcp_nodelay(int);
struct uwsgi_exception_handler_instance;
struct uwsgi_exception_handler {
char *name;
int (*func)(struct uwsgi_exception_handler_instance *, char *, size_t);
struct uwsgi_exception_handler *next;
};
struct uwsgi_exception_handler_instance {
struct uwsgi_exception_handler *handler;
int configured;
char *arg;
uint32_t custom32;
uint64_t custom64;
void *custom_ptr;
};
void uwsgi_exception_setup_handlers(void);
struct uwsgi_exception_handler *uwsgi_exception_handler_by_name(char *);
void uwsgi_manage_exception(struct wsgi_request *, int);
int uwsgi_exceptions_catch(struct wsgi_request *);
uint64_t uwsgi_worker_exceptions(int);
struct uwsgi_exception_handler *uwsgi_register_exception_handler(char *, int (*)(struct uwsgi_exception_handler_instance *, char *, size_t));
char *proxy1_parse(char *ptr, char *watermark, char **src, uint16_t *src_len, char **dst, uint16_t *dst_len, char **src_port, uint16_t *src_port_len, char **dst_port, uint16_t *dst_port_len);
void uwsgi_async_queue_is_full(time_t);
char *uwsgi_get_header(struct wsgi_request *, char *, uint16_t, uint16_t *);
void uwsgi_alarm_thread_start(void);
void uwsgi_exceptions_handler_thread_start(void);
#define uwsgi_response_add_connection_close(x) uwsgi_response_add_header(x, (char *)"Connection", 10, (char *)"close", 5)
#define uwsgi_response_add_content_type(x, y, z) uwsgi_response_add_header(x, (char *)"Content-Type", 12, y, z)
struct uwsgi_stats_pusher_instance *uwsgi_stats_pusher_add(struct uwsgi_stats_pusher *, char *);
int plugin_already_loaded(const char *);
struct uwsgi_plugin *uwsgi_plugin_get(const char *);
struct uwsgi_cache_magic_context {
char *cmd;
uint16_t cmd_len;
char *key;
uint16_t key_len;
uint64_t size;
uint64_t expires;
char *status;
uint16_t status_len;
char *cache;
uint16_t cache_len;
};
char *uwsgi_cache_magic_get(char *, uint16_t, uint64_t *, uint64_t *, char *);
int uwsgi_cache_magic_set(char *, uint16_t, char *, uint64_t, uint64_t, uint64_t, char *);
int uwsgi_cache_magic_del(char *, uint16_t, char *);
int uwsgi_cache_magic_exists(char *, uint16_t, char *);
int uwsgi_cache_magic_clear(char *);
void uwsgi_cache_magic_context_hook(char *, uint16_t, char *, uint16_t, void *);
char *uwsgi_legion_scrolls(char *, uint64_t *);
int uwsgi_emperor_vassal_start(struct uwsgi_instance *);
#ifdef UWSGI_ZLIB
#include <zlib.h>
int uwsgi_deflate_init(z_stream *, char *, size_t);
int uwsgi_inflate_init(z_stream *, char *, size_t);
char *uwsgi_deflate(z_stream *, char *, size_t, size_t *);
void uwsgi_crc32(uint32_t *, char *, size_t);
struct uwsgi_buffer *uwsgi_gzip(char *, size_t);
struct uwsgi_buffer *uwsgi_zlib_decompress(char *, size_t);
int uwsgi_gzip_fix(z_stream *, uint32_t, struct uwsgi_buffer *, size_t);
char *uwsgi_gzip_chunk(z_stream *, uint32_t *, char *, size_t, size_t *);
int uwsgi_gzip_prepare(z_stream *, char *, size_t, uint32_t *);
#endif
char *uwsgi_get_cookie(struct wsgi_request *, char *, uint16_t, uint16_t *);
char *uwsgi_get_qs(struct wsgi_request *, char *, uint16_t, uint16_t *);
struct uwsgi_route_var *uwsgi_get_route_var(char *, uint16_t);
struct uwsgi_route_var *uwsgi_register_route_var(char *, char *(*)(struct wsgi_request *, char *, uint16_t, uint16_t *));
char *uwsgi_get_mime_type(char *, int, size_t *);
void config_magic_table_fill(char *, char *[]);
int uwsgi_blob_to_response(struct wsgi_request *, char *, size_t);
struct uwsgi_cron *uwsgi_cron_add(char *);
int uwsgi_is_full_http(struct uwsgi_buffer *);
int uwsgi_http_date(time_t t, char *);
int uwsgi_apply_transformations(struct wsgi_request *wsgi_req, char *, size_t);
int uwsgi_apply_final_transformations(struct wsgi_request *);
void uwsgi_free_transformations(struct wsgi_request *);
struct uwsgi_transformation *uwsgi_add_transformation(struct wsgi_request *wsgi_req, int (*func)(struct wsgi_request *, struct uwsgi_transformation *), void *);
void uwsgi_file_write_do(struct uwsgi_string_list *);
int uwsgi_fd_is_safe(int);
void uwsgi_add_safe_fd(int);
void uwsgi_ipcsem_clear(void);
char *uwsgi_str_to_hex(char *, size_t);
// this 3 functions have been added 1.9.10 to allow plugins take the control over processes
void uwsgi_worker_run(void);
void uwsgi_mule_run(void);
void uwsgi_spooler_run(void);
void uwsgi_takeover(void);
char *uwsgi_binary_path(void);
int uwsgi_is_again();
void uwsgi_disconnect(struct wsgi_request *);
int uwsgi_ready_fd(struct wsgi_request *);
void uwsgi_envdir(char *);
void uwsgi_envdirs(struct uwsgi_string_list *);
void uwsgi_opt_envdir(char *, char *, void *);
void uwsgi_add_reload_fds();
void uwsgi_check_emperor(void);
#ifdef UWSGI_AS_SHARED_LIBRARY
int uwsgi_init(int, char **, char **);
#endif
int uwsgi_master_check_cron_death(int);
struct uwsgi_fsmon *uwsgi_register_fsmon(char *, void (*)(struct uwsgi_fsmon *), void *data);
int uwsgi_fsmon_event(int);
void uwsgi_fsmon_setup();
void uwsgi_exit(int) __attribute__ ((__noreturn__));
void uwsgi_fallback_config();
struct uwsgi_cache_item *uwsgi_cache_keys(struct uwsgi_cache *, uint64_t *, struct uwsgi_cache_item **);
void uwsgi_cache_rlock(struct uwsgi_cache *);
void uwsgi_cache_rwunlock(struct uwsgi_cache *);
char *uwsgi_cache_item_key(struct uwsgi_cache_item *);
char *uwsgi_binsh(void);
int uwsgi_file_executable(char *);
int uwsgi_mount(char *, char *, char *, char *, char *);
int uwsgi_umount(char *, char *);
int uwsgi_mount_hook(char *);
int uwsgi_umount_hook(char *);
void uwsgi_hooks_run(struct uwsgi_string_list *, char *, int);
void uwsgi_register_hook(char *, int (*)(char *));
struct uwsgi_hook *uwsgi_hook_by_name(char *);
void uwsgi_register_base_hooks(void);
void uwsgi_setup_log_encoders(void);
void uwsgi_log_encoders_register_embedded(void);
void uwsgi_register_log_encoder(char *, char *(*)(struct uwsgi_log_encoder *, char *, size_t, size_t *));
int uwsgi_accept(int);
void suspend_resume_them_all(int);
void uwsgi_master_fifo_prepare();
int uwsgi_master_fifo();
int uwsgi_master_fifo_manage(int);
void uwsgi_log_do_rotate(char *, char *, off_t, int);
void uwsgi_log_rotate();
void uwsgi_log_reopen();
void uwsgi_reload_workers();
void uwsgi_reload_mules();
void uwsgi_reload_spoolers();
void uwsgi_chain_reload();
void uwsgi_refork_master();
void uwsgi_update_pidfiles();
void gracefully_kill_them_all(int);
void uwsgi_brutally_reload_workers();
void uwsgi_cheaper_increase();
void uwsgi_cheaper_decrease();
void uwsgi_go_cheap();
char **uwsgi_split_quoted(char *, size_t, char *, size_t *);
void uwsgi_master_manage_emperor_proxy();
struct uwsgi_string_list *uwsgi_register_scheme(char *, char * (*)(char *, size_t *, int));
void uwsgi_setup_schemes(void);
struct uwsgi_string_list *uwsgi_check_scheme(char *);
void uwsgi_remap_fd(int, char *);
void uwsgi_opt_exit(char *, char *, void *);
int uwsgi_check_mountpoint(char *);
void uwsgi_master_check_mountpoints(void);
enum {
UWSGI_METRIC_COUNTER,
UWSGI_METRIC_GAUGE,
UWSGI_METRIC_ABSOLUTE,
UWSGI_METRIC_ALIAS,
};
struct uwsgi_metric_child;
struct uwsgi_metric_collector {
char *name;
int64_t (*func)(struct uwsgi_metric *);
struct uwsgi_metric_collector *next;
};
struct uwsgi_metric_threshold {
int64_t value;
uint8_t reset;
int64_t reset_value;
int32_t rate;
char *alarm;
char *msg;
size_t msg_len;
time_t last_alarm;
struct uwsgi_metric_threshold *next;
};
struct uwsgi_metric {
char *name;
char *oid;
size_t name_len;
size_t oid_len;
// pre-computed snmp representation
char *asn;
size_t asn_len;
// ABSOLUTE/COUNTER/GAUGE
uint8_t type;
// this could be taken from a file storage and must be always added to value by the collector (default 0)
int64_t initial_value;
// the value of the metric (point to a shared memory area)
int64_t *value;
// a custom blob you can attach to a metric
void *custom;
// the collection frequency
uint32_t freq;
time_t last_update;
// run this function to collect the value
struct uwsgi_metric_collector *collector;
// take the value from this pointer to a 64bit value
int64_t *ptr;
// get the initial value from this file, and store each update in it
char *filename;
// pointer to memory mapped storage
char *map;
// arguments for collectors
char *arg1;
char *arg2;
char *arg3;
int64_t arg1n;
int64_t arg2n;
int64_t arg3n;
struct uwsgi_metric_child *children;
struct uwsgi_metric_threshold *thresholds;
struct uwsgi_metric *next;
// allow to reset metrics after each push
uint8_t reset_after_push;
};
struct uwsgi_metric_child {
struct uwsgi_metric *um;
struct uwsgi_metric_child *next;
};
void uwsgi_setup_metrics(void);
void uwsgi_metrics_start_collector(void);
int uwsgi_metric_set(char *, char *, int64_t);
int uwsgi_metric_inc(char *, char *, int64_t);
int uwsgi_metric_dec(char *, char *, int64_t);
int uwsgi_metric_mul(char *, char *, int64_t);
int uwsgi_metric_div(char *, char *, int64_t);
int64_t uwsgi_metric_get(char *, char *);
int64_t uwsgi_metric_getn(char *, size_t, char *, size_t);
int uwsgi_metric_set_max(char *, char *, int64_t);
int uwsgi_metric_set_min(char *, char *, int64_t);
struct uwsgi_metric_collector *uwsgi_register_metric_collector(char *, int64_t (*)(struct uwsgi_metric *));
struct uwsgi_metric *uwsgi_register_metric(char *, char *, uint8_t, char *, void *, uint32_t, void *);
void uwsgi_metrics_collectors_setup(void);
struct uwsgi_metric *uwsgi_metric_find_by_name(char *);
struct uwsgi_metric *uwsgi_metric_find_by_namen(char *, size_t);
struct uwsgi_metric_child *uwsgi_metric_add_child(struct uwsgi_metric *, struct uwsgi_metric *);
struct uwsgi_metric *uwsgi_metric_find_by_oid(char *);
struct uwsgi_metric *uwsgi_metric_find_by_oidn(char *, size_t);
struct uwsgi_metric *uwsgi_metric_find_by_asn(char *, size_t);
int uwsgi_base128(struct uwsgi_buffer *, uint64_t, int);
struct wsgi_request *find_wsgi_req_proto_by_fd(int);
struct uwsgi_protocol *uwsgi_register_protocol(char *, void (*)(struct uwsgi_socket *));
void uwsgi_protocols_register(void);
void uwsgi_build_plugin(char *dir);
void uwsgi_sharedareas_init();
struct uwsgi_sharedarea *uwsgi_sharedarea_init(int);
struct uwsgi_sharedarea *uwsgi_sharedarea_init_ptr(char *, uint64_t);
struct uwsgi_sharedarea *uwsgi_sharedarea_init_fd(int, uint64_t, off_t);
int64_t uwsgi_sharedarea_read(int, uint64_t, char *, uint64_t);
int uwsgi_sharedarea_write(int, uint64_t, char *, uint64_t);
int uwsgi_sharedarea_read64(int, uint64_t, int64_t *);
int uwsgi_sharedarea_write64(int, uint64_t, int64_t *);
int uwsgi_sharedarea_read8(int, uint64_t, int8_t *);
int uwsgi_sharedarea_write8(int, uint64_t, int8_t *);
int uwsgi_sharedarea_read16(int, uint64_t, int16_t *);
int uwsgi_sharedarea_write16(int, uint64_t, int16_t *);
int uwsgi_sharedarea_read32(int, uint64_t, int32_t *);
int uwsgi_sharedarea_write32(int, uint64_t, int32_t *);
int uwsgi_sharedarea_inc8(int, uint64_t, int8_t);
int uwsgi_sharedarea_inc16(int, uint64_t, int16_t);
int uwsgi_sharedarea_inc32(int, uint64_t, int32_t);
int uwsgi_sharedarea_inc64(int, uint64_t, int64_t);
int uwsgi_sharedarea_dec8(int, uint64_t, int8_t);
int uwsgi_sharedarea_dec16(int, uint64_t, int16_t);
int uwsgi_sharedarea_dec32(int, uint64_t, int32_t);
int uwsgi_sharedarea_dec64(int, uint64_t, int64_t);
int uwsgi_sharedarea_wait(int, int, int);
int uwsgi_sharedarea_unlock(int);
int uwsgi_sharedarea_rlock(int);
int uwsgi_sharedarea_wlock(int);
int uwsgi_sharedarea_update(int);
struct uwsgi_sharedarea *uwsgi_sharedarea_get_by_id(int, uint64_t);
int uwsgi_websocket_send_from_sharedarea(struct wsgi_request *, int, uint64_t, uint64_t);
int uwsgi_websocket_send_binary_from_sharedarea(struct wsgi_request *, int, uint64_t, uint64_t);
void uwsgi_register_logchunks(void);
void uwsgi_setup(int, char **, char **);
int uwsgi_run(void);
int uwsgi_is_connected(int);
int uwsgi_pass_cred(int, char *, size_t);
int uwsgi_pass_cred2(int, char *, size_t, struct sockaddr *, size_t);
int uwsgi_recv_cred(int, char *, size_t, pid_t *, uid_t *, gid_t *);
ssize_t uwsgi_recv_cred2(int, char *, size_t, pid_t *, uid_t *, gid_t *);
int uwsgi_socket_passcred(int);
void uwsgi_dump_worker(int, char *);
mode_t uwsgi_mode_t(char *, int *);
int uwsgi_notify_socket_manage(int);
int uwsgi_notify_msg(char *, char *, size_t);
void vassal_sos();
int uwsgi_wait_for_fs(char *, int);
int uwsgi_wait_for_mountpoint(char *);
int uwsgi_wait_for_socket(char *);
#ifdef __cplusplus
}
#endif
|