connlist.h 795 B

123456789101112131415161718192021222324252627282930
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #ifndef HTTPD_CONNLIST_H
  3. #define HTTPD_CONNLIST_H
  4. #include "streaming.h"
  5. // (-1) in following macro is to keep conn list + next pointer
  6. // be power of 2
  7. #define CONN_LIST_MEMPOOL_SIZE ((2^5)-1)
  8. struct conn_list_leaf {
  9. h2o_stream_conn_t *conn[CONN_LIST_MEMPOOL_SIZE];
  10. struct conn_list_leaf *next;
  11. };
  12. typedef struct {
  13. struct conn_list_leaf *head;
  14. struct conn_list_leaf *tail;
  15. int size;
  16. int capacity;
  17. pthread_mutex_t lock;
  18. } conn_list_t;
  19. extern conn_list_t conn_list;
  20. void conn_list_insert(conn_list_t *list, h2o_stream_conn_t *conn);
  21. void conn_list_iter_all(conn_list_t *list, void (*cb)(h2o_stream_conn_t *conn));
  22. int conn_list_remove_conn(conn_list_t *list, h2o_stream_conn_t *conn);
  23. #endif /* HTTPD_CONNLIST_H */