diff options
Diffstat (limited to 'src/lib/internal.h')
-rw-r--r-- | src/lib/internal.h | 233 |
1 files changed, 233 insertions, 0 deletions
diff --git a/src/lib/internal.h b/src/lib/internal.h index 5a08a0b2..7829efc4 100644 --- a/src/lib/internal.h +++ b/src/lib/internal.h | |||
@@ -907,12 +907,117 @@ struct MHD_Daemon | |||
907 | */ | 907 | */ |
908 | const void *digest_auth_random_buf; | 908 | const void *digest_auth_random_buf; |
909 | #endif | 909 | #endif |
910 | |||
911 | /** | ||
912 | * Head of the XDLL of ALL connections with a default ('normal') | ||
913 | * timeout, sorted by timeout (earliest at the tail, most recently | ||
914 | * used connection at the head). MHD can just look at the tail of | ||
915 | * this list to determine the timeout for all of its elements; | ||
916 | * whenever there is an event of a connection, the connection is | ||
917 | * moved back to the tail of the list. | ||
918 | * | ||
919 | * All connections by default start in this list; if a custom | ||
920 | * timeout that does not match @e connection_timeout is set, they | ||
921 | * are moved to the @e manual_timeout_head-XDLL. | ||
922 | * Not used in MHD_USE_THREAD_PER_CONNECTION mode as each thread | ||
923 | * needs only one connection-specific timeout. | ||
924 | */ | ||
925 | struct MHD_Connection *normal_timeout_head; | ||
926 | |||
927 | /** | ||
928 | * Tail of the XDLL of ALL connections with a default timeout, | ||
929 | * sorted by timeout (earliest timeout at the tail). | ||
930 | * Not used in MHD_USE_THREAD_PER_CONNECTION mode. | ||
931 | */ | ||
932 | struct MHD_Connection *normal_timeout_tail; | ||
933 | |||
934 | /** | ||
935 | * Head of the XDLL of ALL connections with a non-default/custom | ||
936 | * timeout, unsorted. MHD will do a O(n) scan over this list to | ||
937 | * determine the current timeout. | ||
938 | * Not used in MHD_USE_THREAD_PER_CONNECTION mode. | ||
939 | */ | ||
940 | struct MHD_Connection *manual_timeout_head; | ||
941 | |||
942 | /** | ||
943 | * Tail of the XDLL of ALL connections with a non-default/custom | ||
944 | * timeout, unsorted. | ||
945 | * Not used in MHD_USE_THREAD_PER_CONNECTION mode. | ||
946 | */ | ||
947 | struct MHD_Connection *manual_timeout_tail; | ||
910 | 948 | ||
949 | /** | ||
950 | * Head of doubly-linked list of our current, active connections. | ||
951 | */ | ||
952 | struct MHD_Connection *connections_head; | ||
953 | |||
954 | /** | ||
955 | * Tail of doubly-linked list of our current, active connections. | ||
956 | */ | ||
957 | struct MHD_Connection *connections_tail; | ||
958 | |||
959 | /** | ||
960 | * Head of doubly-linked list of our current but suspended | ||
961 | * connections. | ||
962 | */ | ||
963 | struct MHD_Connection *suspended_connections_head; | ||
964 | |||
965 | /** | ||
966 | * Tail of doubly-linked list of our current but suspended | ||
967 | * connections. | ||
968 | */ | ||
969 | struct MHD_Connection *suspended_connections_tail; | ||
970 | |||
971 | /** | ||
972 | * Head of doubly-linked list of connections to clean up. | ||
973 | */ | ||
974 | struct MHD_Connection *cleanup_head; | ||
975 | |||
976 | /** | ||
977 | * Tail of doubly-linked list of connections to clean up. | ||
978 | */ | ||
979 | struct MHD_Connection *cleanup_tail; | ||
980 | |||
981 | #ifdef EPOLL_SUPPORT | ||
982 | /** | ||
983 | * Head of EDLL of connections ready for processing (in epoll mode). | ||
984 | */ | ||
985 | struct MHD_Connection *eready_head; | ||
986 | |||
987 | /** | ||
988 | * Tail of EDLL of connections ready for processing (in epoll mode) | ||
989 | */ | ||
990 | struct MHD_Connection *eready_tail; | ||
991 | |||
992 | #ifdef UPGRADE_SUPPORT | ||
993 | /** | ||
994 | * Head of EDLL of upgraded connections ready for processing (in epoll mode). | ||
995 | */ | ||
996 | struct MHD_UpgradeResponseHandle *eready_urh_head; | ||
997 | |||
998 | /** | ||
999 | * Tail of EDLL of upgraded connections ready for processing (in epoll mode) | ||
1000 | */ | ||
1001 | struct MHD_UpgradeResponseHandle *eready_urh_tail; | ||
1002 | #endif /* UPGRADE_SUPPORT */ | ||
1003 | #endif /* EPOLL_SUPPORT */ | ||
1004 | |||
911 | /** | 1005 | /** |
912 | * Socket address to bind to for the listen socket. | 1006 | * Socket address to bind to for the listen socket. |
913 | */ | 1007 | */ |
914 | struct sockaddr_storage listen_sa; | 1008 | struct sockaddr_storage listen_sa; |
915 | 1009 | ||
1010 | /** | ||
1011 | * Mutex for per-IP connection counts. | ||
1012 | */ | ||
1013 | MHD_mutex_ per_ip_connection_mutex; | ||
1014 | |||
1015 | /** | ||
1016 | * Mutex for (modifying) access to the "cleanup", "normal_timeout" and | ||
1017 | * "manual_timeout" DLLs. | ||
1018 | */ | ||
1019 | MHD_mutex_ cleanup_connection_mutex; | ||
1020 | |||
916 | /** | 1021 | /** |
917 | * Number of (valid) bytes in @e listen_sa. Zero | 1022 | * Number of (valid) bytes in @e listen_sa. Zero |
918 | * if @e listen_sa is not initialized. | 1023 | * if @e listen_sa is not initialized. |
@@ -1301,4 +1406,132 @@ MHD_parse_arguments_ (struct MHD_Connection *connection, | |||
1301 | unsigned int *num_headers); | 1406 | unsigned int *num_headers); |
1302 | 1407 | ||
1303 | 1408 | ||
1409 | |||
1410 | /** | ||
1411 | * Insert an element at the head of a DLL. Assumes that head, tail and | ||
1412 | * element are structs with prev and next fields. | ||
1413 | * | ||
1414 | * @param head pointer to the head of the DLL | ||
1415 | * @param tail pointer to the tail of the DLL | ||
1416 | * @param element element to insert | ||
1417 | */ | ||
1418 | #define DLL_insert(head,tail,element) do { \ | ||
1419 | mhd_assert (NULL == (element)->next); \ | ||
1420 | mhd_assert (NULL == (element)->prev); \ | ||
1421 | (element)->next = (head); \ | ||
1422 | (element)->prev = NULL; \ | ||
1423 | if ((tail) == NULL) \ | ||
1424 | (tail) = element; \ | ||
1425 | else \ | ||
1426 | (head)->prev = element; \ | ||
1427 | (head) = (element); } while (0) | ||
1428 | |||
1429 | |||
1430 | /** | ||
1431 | * Remove an element from a DLL. Assumes that head, tail and element | ||
1432 | * are structs with prev and next fields. | ||
1433 | * | ||
1434 | * @param head pointer to the head of the DLL | ||
1435 | * @param tail pointer to the tail of the DLL | ||
1436 | * @param element element to remove | ||
1437 | */ | ||
1438 | #define DLL_remove(head,tail,element) do { \ | ||
1439 | mhd_assert ( (NULL != (element)->next) || ((element) == (tail))); \ | ||
1440 | mhd_assert ( (NULL != (element)->prev) || ((element) == (head))); \ | ||
1441 | if ((element)->prev == NULL) \ | ||
1442 | (head) = (element)->next; \ | ||
1443 | else \ | ||
1444 | (element)->prev->next = (element)->next; \ | ||
1445 | if ((element)->next == NULL) \ | ||
1446 | (tail) = (element)->prev; \ | ||
1447 | else \ | ||
1448 | (element)->next->prev = (element)->prev; \ | ||
1449 | (element)->next = NULL; \ | ||
1450 | (element)->prev = NULL; } while (0) | ||
1451 | |||
1452 | |||
1453 | |||
1454 | /** | ||
1455 | * Insert an element at the head of a XDLL. Assumes that head, tail and | ||
1456 | * element are structs with prevX and nextX fields. | ||
1457 | * | ||
1458 | * @param head pointer to the head of the XDLL | ||
1459 | * @param tail pointer to the tail of the XDLL | ||
1460 | * @param element element to insert | ||
1461 | */ | ||
1462 | #define XDLL_insert(head,tail,element) do { \ | ||
1463 | mhd_assert (NULL == (element)->nextX); \ | ||
1464 | mhd_assert (NULL == (element)->prevX); \ | ||
1465 | (element)->nextX = (head); \ | ||
1466 | (element)->prevX = NULL; \ | ||
1467 | if (NULL == (tail)) \ | ||
1468 | (tail) = element; \ | ||
1469 | else \ | ||
1470 | (head)->prevX = element; \ | ||
1471 | (head) = (element); } while (0) | ||
1472 | |||
1473 | |||
1474 | /** | ||
1475 | * Remove an element from a XDLL. Assumes that head, tail and element | ||
1476 | * are structs with prevX and nextX fields. | ||
1477 | * | ||
1478 | * @param head pointer to the head of the XDLL | ||
1479 | * @param tail pointer to the tail of the XDLL | ||
1480 | * @param element element to remove | ||
1481 | */ | ||
1482 | #define XDLL_remove(head,tail,element) do { \ | ||
1483 | mhd_assert ( (NULL != (element)->nextX) || ((element) == (tail))); \ | ||
1484 | mhd_assert ( (NULL != (element)->prevX) || ((element) == (head))); \ | ||
1485 | if (NULL == (element)->prevX) \ | ||
1486 | (head) = (element)->nextX; \ | ||
1487 | else \ | ||
1488 | (element)->prevX->nextX = (element)->nextX; \ | ||
1489 | if (NULL == (element)->nextX) \ | ||
1490 | (tail) = (element)->prevX; \ | ||
1491 | else \ | ||
1492 | (element)->nextX->prevX = (element)->prevX; \ | ||
1493 | (element)->nextX = NULL; \ | ||
1494 | (element)->prevX = NULL; } while (0) | ||
1495 | |||
1496 | |||
1497 | /** | ||
1498 | * Insert an element at the head of a EDLL. Assumes that head, tail and | ||
1499 | * element are structs with prevE and nextE fields. | ||
1500 | * | ||
1501 | * @param head pointer to the head of the EDLL | ||
1502 | * @param tail pointer to the tail of the EDLL | ||
1503 | * @param element element to insert | ||
1504 | */ | ||
1505 | #define EDLL_insert(head,tail,element) do { \ | ||
1506 | (element)->nextE = (head); \ | ||
1507 | (element)->prevE = NULL; \ | ||
1508 | if ((tail) == NULL) \ | ||
1509 | (tail) = element; \ | ||
1510 | else \ | ||
1511 | (head)->prevE = element; \ | ||
1512 | (head) = (element); } while (0) | ||
1513 | |||
1514 | |||
1515 | /** | ||
1516 | * Remove an element from a EDLL. Assumes that head, tail and element | ||
1517 | * are structs with prevE and nextE fields. | ||
1518 | * | ||
1519 | * @param head pointer to the head of the EDLL | ||
1520 | * @param tail pointer to the tail of the EDLL | ||
1521 | * @param element element to remove | ||
1522 | */ | ||
1523 | #define EDLL_remove(head,tail,element) do { \ | ||
1524 | if ((element)->prevE == NULL) \ | ||
1525 | (head) = (element)->nextE; \ | ||
1526 | else \ | ||
1527 | (element)->prevE->nextE = (element)->nextE; \ | ||
1528 | if ((element)->nextE == NULL) \ | ||
1529 | (tail) = (element)->prevE; \ | ||
1530 | else \ | ||
1531 | (element)->nextE->prevE = (element)->prevE; \ | ||
1532 | (element)->nextE = NULL; \ | ||
1533 | (element)->prevE = NULL; } while (0) | ||
1534 | |||
1535 | |||
1536 | |||
1304 | #endif | 1537 | #endif |