2020-05-25 08:04:30 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2016-2020 Chung, Hyung-Hwan. All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
2022-06-11 05:32:01 +00:00
|
|
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
2020-05-25 08:04:30 +00:00
|
|
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
#ifndef _HIO_HTTP_PRV_H_
|
|
|
|
#define _HIO_HTTP_PRV_H_
|
2020-05-25 08:04:30 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
#include <hio-http.h>
|
|
|
|
#include <hio-htrd.h>
|
|
|
|
#include <hio-sck.h>
|
|
|
|
#include "hio-prv.h"
|
2020-05-25 08:04:30 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
struct hio_svc_htts_cli_t
|
2020-05-25 08:04:30 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_svc_htts_cli_t* cli_prev;
|
|
|
|
hio_svc_htts_cli_t* cli_next;
|
2020-05-25 08:04:30 +00:00
|
|
|
|
2021-08-06 03:23:48 +00:00
|
|
|
/* a listener socket sets htts, sck, and l_idx fields only */
|
2020-05-25 08:04:30 +00:00
|
|
|
/* a client sockets uses all the fields in this struct */
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_svc_htts_t* htts;
|
|
|
|
hio_dev_sck_t* sck;
|
2022-10-08 07:47:55 +00:00
|
|
|
hio_skad_t cli_addr;
|
|
|
|
hio_bch_t cli_addr_bcstr[HIO_SKAD_IP_STRLEN + 1];
|
2021-08-06 03:23:48 +00:00
|
|
|
hio_oow_t l_idx; /* listening socket: < htts->l.count, client socket: >= htts->l.count */
|
2020-05-25 08:04:30 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_htrd_t* htrd;
|
|
|
|
hio_becs_t* sbuf; /* temporary buffer for status line formatting */
|
2020-05-25 08:04:30 +00:00
|
|
|
|
2023-01-11 15:41:01 +00:00
|
|
|
hio_svc_htts_task_t* task;
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_ntime_t last_active;
|
2020-05-25 08:04:30 +00:00
|
|
|
};
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
struct hio_svc_htts_cli_htrd_xtn_t
|
2020-05-25 08:04:30 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_dev_sck_t* sck;
|
2020-05-25 08:04:30 +00:00
|
|
|
};
|
2021-07-22 07:30:20 +00:00
|
|
|
typedef struct hio_svc_htts_cli_htrd_xtn_t hio_svc_htts_cli_htrd_xtn_t;
|
2020-05-25 08:04:30 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
struct hio_svc_htts_t
|
2020-05-25 08:04:30 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
HIO_SVC_HEADER;
|
2020-05-25 08:04:30 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_svc_htts_proc_req_t proc_req;
|
2020-05-25 08:04:30 +00:00
|
|
|
|
2021-08-06 03:23:48 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
hio_dev_sck_t** sck;
|
|
|
|
hio_oow_t count;
|
|
|
|
} l;
|
|
|
|
/*hio_dev_sck_t* lsck;*/
|
2022-09-12 14:43:29 +00:00
|
|
|
hio_svc_fcgic_t* fcgic;
|
2021-08-06 03:23:48 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_svc_htts_cli_t cli; /* list head for client list */
|
2023-01-11 15:41:01 +00:00
|
|
|
hio_svc_htts_task_t task; /* list head for task list */
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_tmridx_t idle_tmridx;
|
2020-05-25 08:04:30 +00:00
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
hio_bch_t* server_name;
|
|
|
|
hio_bch_t server_name_buf[64];
|
2023-02-20 08:08:41 +00:00
|
|
|
|
2023-02-20 16:08:28 +00:00
|
|
|
hio_becs_t* becbuf; /* temporary buffer for any work */
|
|
|
|
|
2023-11-17 07:57:12 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
hio_oow_t task_max;
|
|
|
|
hio_oow_t task_cgi_max;
|
|
|
|
} option;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
hio_ooi_t ntasks;
|
|
|
|
hio_ooi_t ntask_cgis;
|
|
|
|
} stat;
|
2020-05-25 08:04:30 +00:00
|
|
|
};
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
struct hio_svc_httc_t
|
2020-05-25 08:04:30 +00:00
|
|
|
{
|
2021-07-22 07:30:20 +00:00
|
|
|
HIO_SVC_HEADER;
|
2020-05-25 08:04:30 +00:00
|
|
|
};
|
|
|
|
|
2023-01-11 14:59:41 +00:00
|
|
|
/* client list */
|
2021-07-22 07:30:20 +00:00
|
|
|
#define HIO_SVC_HTTS_CLIL_APPEND_CLI(lh,cli) do { \
|
2020-05-25 08:04:30 +00:00
|
|
|
(cli)->cli_next = (lh); \
|
|
|
|
(cli)->cli_prev = (lh)->cli_prev; \
|
|
|
|
(cli)->cli_prev->cli_next = (cli); \
|
|
|
|
(lh)->cli_prev = (cli); \
|
|
|
|
} while(0)
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
#define HIO_SVC_HTTS_CLIL_UNLINK_CLI(cli) do { \
|
2020-05-25 08:04:30 +00:00
|
|
|
(cli)->cli_prev->cli_next = (cli)->cli_next; \
|
|
|
|
(cli)->cli_next->cli_prev = (cli)->cli_prev; \
|
|
|
|
} while (0)
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
#define HIO_SVC_HTTS_CLIL_UNLINK_CLI_CLEAN(cli) do { \
|
2020-05-25 08:04:30 +00:00
|
|
|
(cli)->cli_prev->cli_next = (cli)->cli_next; \
|
|
|
|
(cli)->cli_next->cli_prev = (cli)->cli_prev; \
|
|
|
|
(cli)->cli_prev = (cli); \
|
|
|
|
(cli)->cli_next = (cli); \
|
|
|
|
} while (0)
|
|
|
|
|
2021-07-22 07:30:20 +00:00
|
|
|
#define HIO_SVC_HTTS_CLIL_INIT(lh) ((lh)->cli_next = (lh)->cli_prev = lh)
|
|
|
|
#define HIO_SVC_HTTS_CLIL_FIRST_CLI(lh) ((lh)->cli_next)
|
|
|
|
#define HIO_SVC_HTTS_CLIL_LAST_CLI(lh) ((lh)->cli_prev)
|
|
|
|
#define HIO_SVC_HTTS_CLIL_IS_EMPTY(lh) (HIO_SVC_HTTS_CLIL_FIRST_CLI(lh) == (lh))
|
|
|
|
#define HIO_SVC_HTTS_CLIL_IS_NIL_CLI(lh,cli) ((cli) == (lh))
|
2020-05-25 08:04:30 +00:00
|
|
|
|
2023-01-11 15:33:52 +00:00
|
|
|
|
|
|
|
/* task list */
|
|
|
|
#define HIO_SVC_HTTS_TASKL_APPEND_TASK(lh,task) do { \
|
|
|
|
(task)->task_next = (lh); \
|
|
|
|
(task)->task_prev = (lh)->task_prev; \
|
|
|
|
(task)->task_prev->task_next = (task); \
|
|
|
|
(lh)->task_prev = (task); \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
#define HIO_SVC_HTTS_TASKL_UNLINK_TASK(task) do { \
|
|
|
|
(task)->task_prev->task_next = (task)->task_next; \
|
|
|
|
(task)->task_next->task_prev = (task)->task_prev; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define HIO_SVC_HTTS_TASKL_UNLINK_TASK_CLEAN(task) do { \
|
|
|
|
(task)->task_prev->task_next = (task)->task_next; \
|
|
|
|
(task)->task_next->task_prev = (task)->task_prev; \
|
|
|
|
(task)->task_prev = (task); \
|
|
|
|
(task)->task_next = (task); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define HIO_SVC_HTTS_TASKL_INIT(lh) ((lh)->task_next = (lh)->task_prev = lh)
|
|
|
|
#define HIO_SVC_HTTS_TASKL_FIRST_TASK(lh) ((lh)->task_next)
|
|
|
|
#define HIO_SVC_HTTS_TASKL_LAST_TASK(lh) ((lh)->task_prev)
|
|
|
|
#define HIO_SVC_HTTS_TASKL_IS_EMPTY(lh) (HIO_SVC_HTTS_TASKL_FIRST_TASK(lh) == (lh))
|
|
|
|
#define HIO_SVC_HTTS_TASKL_IS_NIL_TASK(lh,task) ((task) == (lh))
|
|
|
|
|
2020-05-25 08:04:30 +00:00
|
|
|
#endif
|