From c526c4c7801fed6c4d0bd9aecb57230cb2009906 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 1 Sep 2022 06:36:16 +0000 Subject: [PATCH] added a function to create a socket device with a given address in fcgi-cli.c --- hio/lib/fcgi-cli.c | 53 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/hio/lib/fcgi-cli.c b/hio/lib/fcgi-cli.c index ad18e5a..d0a137d 100644 --- a/hio/lib/fcgi-cli.c +++ b/hio/lib/fcgi-cli.c @@ -38,11 +38,6 @@ struct hio_svc_fcgic_t hio_svc_fcgic_tmout_t tmout; hio_svc_fcgic_conn_t* conns; - -#if 0 - hio_oow_t autoi; - hio_oow_t autoi2; -#endif }; #define INVALID_SID HIO_TYPE_MAX(hio_oow_t) @@ -113,6 +108,46 @@ typedef struct fcgic_fcgi_msg_xtn_t fcgic_fcgi_msg_xtn_t; #endif +static hio_dev_sck_t* make_sck_dev (hio_t* hio, hio_skad_t* addr) +{ + hio_dev_sck_make_t mi; + + HIO_MEMSET (&mi, 0, HIO_SIZEOF(mi)); + switch (hio_skad_get_family(addr)) + { + case HIO_AF_INET: + mi.type = HIO_DEV_SCK_TCP4; + break; + + case HIO_AF_INET6: + mi.type = HIO_DEV_SCK_TCP6; + break; + + #if defined(HIO_AF_UNIX) + case HIO_AF_UNIX: + mi.type = HIO_DEV_SCK_UNIX; + break; + #endif + + case HIO_AF_QX: + mi.type = HIO_DEV_SCK_QX; + break; + + default: + hio_seterrnum (hio, HIO_EINVAL); + return HIO_NULL; + } + + mi.options = HIO_DEV_SCK_MAKE_LENIENT; +#if 0 + mi.on_write = listener_on_write; + mi.on_read = listener_on_read; + mi.on_connect = listener_on_connect; + mi.on_disconnect = listener_on_disconnect; +#endif + + return hio_dev_sck_make(hio, 0, &mi); +} static hio_svc_fcgic_conn_t* get_connection (hio_svc_fcgic_t* fcgic, hio_skad_t* addr) { @@ -129,6 +164,14 @@ static hio_svc_fcgic_conn_t* get_connection (hio_svc_fcgic_t* fcgic, hio_skad_t* conn = hio_callocmem(hio, HIO_SIZEOF(*conn)); if (HIO_UNLIKELY(!conn)) return HIO_NULL; + conn->dev = make_sck_dev(hio, addr); + if (HIO_UNLIKELY(!conn->dev)) + { + hio_freemem (hio, conn); + return HIO_NULL; + } + conn->addr = *addr; + conn->sess.capa = 0; conn->sess.free = INVALID_SID;