aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/internal.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/internal.h')
-rw-r--r--src/daemon/internal.h85
1 files changed, 79 insertions, 6 deletions
diff --git a/src/daemon/internal.h b/src/daemon/internal.h
index 9a3eb8cb..fcacc523 100644
--- a/src/daemon/internal.h
+++ b/src/daemon/internal.h
@@ -379,11 +379,15 @@ enum MHD_CONNECTION_STATE
379 MHD_CONNECTION_FOOTERS_SENT = MHD_CONNECTION_FOOTERS_SENDING + 1, 379 MHD_CONNECTION_FOOTERS_SENT = MHD_CONNECTION_FOOTERS_SENDING + 1,
380 380
381 /** 381 /**
382 * 19: This connection is closed (no more activity 382 * 19: This connection is to be closed.
383 * allowed).
384 */ 383 */
385 MHD_CONNECTION_CLOSED = MHD_CONNECTION_FOOTERS_SENT + 1, 384 MHD_CONNECTION_CLOSED = MHD_CONNECTION_FOOTERS_SENT + 1,
386 385
386 /**
387 * 20: This connection is finished (only to be freed)
388 */
389 MHD_CONNECTION_IN_CLEANUP = MHD_CONNECTION_CLOSED + 1,
390
387 /* 391 /*
388 * SSL/TLS connection states 392 * SSL/TLS connection states
389 */ 393 */
@@ -440,11 +444,16 @@ struct MHD_Connection
440{ 444{
441 445
442 /** 446 /**
443 * This is a linked list. 447 * This is a doubly-linked list.
444 */ 448 */
445 struct MHD_Connection *next; 449 struct MHD_Connection *next;
446 450
447 /** 451 /**
452 * This is a doubly-linked list.
453 */
454 struct MHD_Connection *prev;
455
456 /**
448 * Reference to the MHD_Daemon struct. 457 * Reference to the MHD_Daemon struct.
449 */ 458 */
450 struct MHD_Daemon *daemon; 459 struct MHD_Daemon *daemon;
@@ -622,6 +631,11 @@ struct MHD_Connection
622 int read_closed; 631 int read_closed;
623 632
624 /** 633 /**
634 * Set to MHD_YES if the thread has been joined.
635 */
636 int thread_joined;
637
638 /**
625 * State in the FSM for this connection. 639 * State in the FSM for this connection.
626 */ 640 */
627 enum MHD_CONNECTION_STATE state; 641 enum MHD_CONNECTION_STATE state;
@@ -747,9 +761,24 @@ struct MHD_Daemon
747 void *default_handler_cls; 761 void *default_handler_cls;
748 762
749 /** 763 /**
750 * Linked list of our current connections. 764 * Tail of doubly-linked list of our current, active connections.
765 */
766 struct MHD_Connection *connections_head;
767
768 /**
769 * Tail of doubly-linked list of our current, active connections.
770 */
771 struct MHD_Connection *connections_tail;
772
773 /**
774 * Tail of doubly-linked list of connections to clean up.
751 */ 775 */
752 struct MHD_Connection *connections; 776 struct MHD_Connection *cleanup_head;
777
778 /**
779 * Tail of doubly-linked list of connections to clean up.
780 */
781 struct MHD_Connection *cleanup_tail;
753 782
754 /** 783 /**
755 * Function to call to check if we should 784 * Function to call to check if we should
@@ -847,11 +876,16 @@ struct MHD_Daemon
847 pthread_t pid; 876 pthread_t pid;
848 877
849 /** 878 /**
850 * Mutex for per-IP connection counts 879 * Mutex for per-IP connection counts.
851 */ 880 */
852 pthread_mutex_t per_ip_connection_mutex; 881 pthread_mutex_t per_ip_connection_mutex;
853 882
854 /** 883 /**
884 * Mutex for (modifying) access to the "cleanup" connection DLL.
885 */
886 pthread_mutex_t cleanup_connection_mutex;
887
888 /**
855 * Listen socket. 889 * Listen socket.
856 */ 890 */
857 int socket_fd; 891 int socket_fd;
@@ -966,5 +1000,44 @@ struct MHD_Daemon
966#endif 1000#endif
967 1001
968 1002
1003/**
1004 * Insert an element at the head of a DLL. Assumes that head, tail and
1005 * element are structs with prev and next fields.
1006 *
1007 * @param head pointer to the head of the DLL
1008 * @param tail pointer to the tail of the DLL
1009 * @param element element to insert
1010 */
1011#define DLL_insert(head,tail,element) do { \
1012 (element)->next = (head); \
1013 (element)->prev = NULL; \
1014 if ((tail) == NULL) \
1015 (tail) = element; \
1016 else \
1017 (head)->prev = element; \
1018 (head) = (element); } while (0)
1019
1020
1021/**
1022 * Remove an element from a DLL. Assumes
1023 * that head, tail and element are structs
1024 * with prev and next fields.
1025 *
1026 * @param head pointer to the head of the DLL
1027 * @param tail pointer to the tail of the DLL
1028 * @param element element to remove
1029 */
1030#define DLL_remove(head,tail,element) do { \
1031 if ((element)->prev == NULL) \
1032 (head) = (element)->next; \
1033 else \
1034 (element)->prev->next = (element)->next; \
1035 if ((element)->next == NULL) \
1036 (tail) = (element)->prev; \
1037 else \
1038 (element)->next->prev = (element)->prev; \
1039 (element)->next = NULL; \
1040 (element)->prev = NULL; } while (0)
1041
969 1042
970#endif 1043#endif