implemented the option added in the previous commit

This commit is contained in:
hyung-hwan 2023-11-17 16:57:12 +09:00
parent aef6a81380
commit d2725688e0
17 changed files with 135 additions and 58 deletions

View File

@ -1245,7 +1245,7 @@ for (i = 0; i < 5; i++)
HIO_INFO1 (hio, "UNABLE TO START DNC - %js\n", hio_geterrmsg(hio)); HIO_INFO1 (hio, "UNABLE TO START DNC - %js\n", hio_geterrmsg(hio));
} }
htts = hio_svc_htts_start(hio, 0, &htts_bind_info, 1, process_http_request, HIO_NULL); htts = hio_svc_htts_start(hio, 0, &htts_bind_info, 1, process_http_request);
if (htts) hio_svc_htts_setservernamewithbcstr (htts, "HIO-HTTP"); if (htts) hio_svc_htts_setservernamewithbcstr (htts, "HIO-HTTP");
else HIO_INFO1 (hio, "UNABLE TO START HTTS - %js\n", hio_geterrmsg(hio)); else HIO_INFO1 (hio, "UNABLE TO START HTTS - %js\n", hio_geterrmsg(hio));

View File

@ -263,7 +263,7 @@ void* thr_func (void* arg)
htts_bind_info[1].ssl_keyfile = "localhost.key"; htts_bind_info[1].ssl_keyfile = "localhost.key";
#endif #endif
htts = hio_svc_htts_start(hio, 0, htts_bind_info, HIO_COUNTOF(htts_bind_info), process_http_request, HIO_NULL); htts = hio_svc_htts_start(hio, 0, htts_bind_info, HIO_COUNTOF(htts_bind_info), process_http_request);
if (!htts) if (!htts)
{ {
printf ("Unable to start htts\n"); printf ("Unable to start htts\n");

View File

@ -417,12 +417,26 @@ int webs_start (hio_t* hio, const arg_info_t* ai)
} }
HIO_MEMSET (&fcgic_tmout, 0, HIO_SIZEOF(fcgic_tmout)); HIO_MEMSET (&fcgic_tmout, 0, HIO_SIZEOF(fcgic_tmout));
fcgic_tmout.c.sec = 5; HIO_INIT_NTIME(&fcgic_tmout.c, 5, 0);
fcgic_tmout.r.sec = 60; HIO_INIT_NTIME(&fcgic_tmout.r, 60, 0);
HIO_INIT_NTIME(&fcgic_tmout.w, -1, 0);
webs = hio_svc_htts_start(hio, HIO_SIZEOF(htts_ext_t), bi, bic, process_http_request, &fcgic_tmout); webs = hio_svc_htts_start(hio, HIO_SIZEOF(htts_ext_t), bi, bic, process_http_request);
if (!webs) return -1; /* TODO: logging */ if (!webs) return -1; /* TODO: logging */
{
hio_oow_t ov;
ov = 1000;
hio_svc_htts_setoption (webs, HIO_SVC_HTTS_TASK_CGI_MAX, &ov);
}
if (hio_svc_htts_enablefcgic(webs, &fcgic_tmout) <= -1)
{
/* TODO: logging */
hio_svc_htts_stop (webs);
return -1;
}
ext = hio_svc_htts_getxtn(webs); ext = hio_svc_htts_getxtn(webs);
ext->ai = ai; ext->ai = ai;

View File

@ -619,7 +619,7 @@ HIO_DEBUG1 (hio, "DNC - unable to receive dns response in time over udp - msgid:
{ {
hio_ntime_t* tmout; hio_ntime_t* tmout;
tmout = HIO_IS_POS_NTIME(&msgxtn->wtmout)? &msgxtn->wtmout: HIO_NULL; tmout = HIO_IS_NEG_NTIME(&msgxtn->wtmout)? HIO_NULL: &msgxtn->wtmout;
HIO_DEBUG1 (hio, "DNC - sending dns question again over udp - msgid:%d\n", (int)hio_ntoh16(hio_dns_msg_to_pkt(reqmsg)->id)); HIO_DEBUG1 (hio, "DNC - sending dns question again over udp - msgid:%d\n", (int)hio_ntoh16(hio_dns_msg_to_pkt(reqmsg)->id));
if (hio_dev_sck_timedwrite(dev, hio_dns_msg_to_pkt(reqmsg), reqmsg->pktlen, tmout, reqmsg, &msgxtn->servaddr) >= 0) return; /* resent */ if (hio_dev_sck_timedwrite(dev, hio_dns_msg_to_pkt(reqmsg), reqmsg->pktlen, tmout, reqmsg, &msgxtn->servaddr) >= 0) return; /* resent */
@ -810,7 +810,7 @@ static HIO_INLINE int send_dns_msg (hio_svc_dnc_t* dnc, hio_dns_msg_t* msg, int
HIO_DEBUG1 (dnc->hio, "DNC - sending dns message over udp - msgid:%d\n", (int)hio_ntoh16(hio_dns_msg_to_pkt(msg)->id)); HIO_DEBUG1 (dnc->hio, "DNC - sending dns message over udp - msgid:%d\n", (int)hio_ntoh16(hio_dns_msg_to_pkt(msg)->id));
tmout = HIO_IS_POS_NTIME(&msgxtn->wtmout)? &msgxtn->wtmout: HIO_NULL; tmout = HIO_IS_NEG_NTIME(&msgxtn->wtmout)? HIO_NULL: &msgxtn->wtmout;
/* TODO: optionally, override dnc->serv_addr and use the target address passed as a parameter */ /* TODO: optionally, override dnc->serv_addr and use the target address passed as a parameter */
return hio_dev_sck_timedwrite(dnc->udp_sck, hio_dns_msg_to_pkt(msg), msg->pktlen, tmout, msg, &msgxtn->servaddr); return hio_dev_sck_timedwrite(dnc->udp_sck, hio_dns_msg_to_pkt(msg), msg->pktlen, tmout, msg, &msgxtn->servaddr);
} }

View File

@ -31,7 +31,6 @@ struct hio_svc_fcgic_t
HIO_SVC_HEADER; HIO_SVC_HEADER;
int stopping; int stopping;
int tmout_set;
hio_svc_fcgic_tmout_t tmout; hio_svc_fcgic_tmout_t tmout;
hio_svc_fcgic_conn_t* conns; hio_svc_fcgic_conn_t* conns;
@ -125,7 +124,7 @@ static void sck_on_connect (hio_dev_sck_t* sck)
HIO_MEMSET (&conn->r, 0, HIO_SIZEOF(conn->r)); HIO_MEMSET (&conn->r, 0, HIO_SIZEOF(conn->r));
conn->r.state = R_AWAITING_HEADER; conn->r.state = R_AWAITING_HEADER;
if (conn->fcgic->tmout_set) if (!HIO_IS_NEG_NTIME(&conn->fcgic->tmout.r))
hio_dev_sck_timedread (sck, 1, &conn->fcgic->tmout.r); hio_dev_sck_timedread (sck, 1, &conn->fcgic->tmout.r);
} }
@ -318,7 +317,7 @@ static int make_connection_socket (hio_svc_fcgic_t* fcgic, hio_svc_fcgic_conn_t*
HIO_MEMSET (&ci, 0, HIO_SIZEOF(ci)); HIO_MEMSET (&ci, 0, HIO_SIZEOF(ci));
ci.remoteaddr = conn->addr; ci.remoteaddr = conn->addr;
if (fcgic->tmout_set) ci.connect_tmout = fcgic->tmout.c; ci.connect_tmout = fcgic->tmout.c;
if (hio_dev_sck_connect(sck, &ci) <= -1) if (hio_dev_sck_connect(sck, &ci) <= -1)
{ {
@ -489,12 +488,11 @@ hio_svc_fcgic_t* hio_svc_fcgic_start (hio_t* hio, const hio_svc_fcgic_tmout_t* t
fcgic->hio = hio; fcgic->hio = hio;
fcgic->svc_stop = (hio_svc_stop_t)hio_svc_fcgic_stop; fcgic->svc_stop = (hio_svc_stop_t)hio_svc_fcgic_stop;
HIO_INIT_NTIME(&fcgic->tmout.c, -1, 0);
HIO_INIT_NTIME(&fcgic->tmout.r, -1, 0);
HIO_INIT_NTIME(&fcgic->tmout.w, -1, 0);
if (tmout) if (tmout) fcgic->tmout = *tmout;
{
fcgic->tmout = *tmout;
fcgic->tmout_set = 1;
}
HIO_SVCL_APPEND_SVC (&hio->actsvc, (hio_svc_t*)fcgic); HIO_SVCL_APPEND_SVC (&hio->actsvc, (hio_svc_t*)fcgic);
HIO_DEBUG1 (hio, "FCGIC - STARTED SERVICE %p\n", fcgic); HIO_DEBUG1 (hio, "FCGIC - STARTED SERVICE %p\n", fcgic);

View File

@ -1094,7 +1094,7 @@ static int fmt_outv (hio_fmtout_t* fmtout, va_list ap)
sign = 0; sign = 0;
if (lm_flag & LF_J) if (lm_flag & LF_J)
{ {
#if 0 && defined(__GNUC__) && \ #if 1 && !defined(__clang__) && defined(__GNUC__) && \
(HIO_SIZEOF_UINTMAX_T > HIO_SIZEOF_OOW_T) && \ (HIO_SIZEOF_UINTMAX_T > HIO_SIZEOF_OOW_T) && \
(HIO_SIZEOF_UINTMAX_T != HIO_SIZEOF_LONG_LONG) && \ (HIO_SIZEOF_UINTMAX_T != HIO_SIZEOF_LONG_LONG) && \
(HIO_SIZEOF_UINTMAX_T != HIO_SIZEOF_LONG) (HIO_SIZEOF_UINTMAX_T != HIO_SIZEOF_LONG)
@ -1106,7 +1106,7 @@ static int fmt_outv (hio_fmtout_t* fmtout, va_list ap)
#if defined(HIO_ENDIAN_BIG) #if defined(HIO_ENDIAN_BIG)
num = num << (8 * HIO_SIZEOF(hio_oow_t)) | (va_arg(ap, hio_oow_t)); num = num << (8 * HIO_SIZEOF(hio_oow_t)) | (va_arg(ap, hio_oow_t));
#else #else
register int shift = i * HIO_SIZEOF(hio_oow_t); int shift = i * HIO_SIZEOF(hio_oow_t);
hio_oow_t x = va_arg(ap, hio_oow_t); hio_oow_t x = va_arg(ap, hio_oow_t);
num |= (hio_uintmax_t)x << (shift * HIO_BITS_PER_BYTE); num |= (hio_uintmax_t)x << (shift * HIO_BITS_PER_BYTE);
#endif #endif
@ -1136,7 +1136,7 @@ static int fmt_outv (hio_fmtout_t* fmtout, va_list ap)
handle_sign: handle_sign:
if (lm_flag & LF_J) if (lm_flag & LF_J)
{ {
#if 0 && defined(__GNUC__) && \ #if 1 && !defined(__clang__) && defined(__GNUC__) && \
(HIO_SIZEOF_INTMAX_T > HIO_SIZEOF_OOI_T) && \ (HIO_SIZEOF_INTMAX_T > HIO_SIZEOF_OOI_T) && \
(HIO_SIZEOF_UINTMAX_T != HIO_SIZEOF_LONG_LONG) && \ (HIO_SIZEOF_UINTMAX_T != HIO_SIZEOF_LONG_LONG) && \
(HIO_SIZEOF_UINTMAX_T != HIO_SIZEOF_LONG) (HIO_SIZEOF_UINTMAX_T != HIO_SIZEOF_LONG)
@ -1148,7 +1148,7 @@ static int fmt_outv (hio_fmtout_t* fmtout, va_list ap)
#if defined(HIO_ENDIAN_BIG) #if defined(HIO_ENDIAN_BIG)
num = num << (8 * HIO_SIZEOF(hio_oow_t)) | (va_arg(ap, hio_oow_t)); num = num << (8 * HIO_SIZEOF(hio_oow_t)) | (va_arg(ap, hio_oow_t));
#else #else
register int shift = i * HIO_SIZEOF(hio_oow_t); int shift = i * HIO_SIZEOF(hio_oow_t);
hio_oow_t x = va_arg(ap, hio_oow_t); hio_oow_t x = va_arg(ap, hio_oow_t);
num |= (hio_uintmax_t)x << (shift * HIO_BITS_PER_BYTE); num |= (hio_uintmax_t)x << (shift * HIO_BITS_PER_BYTE);
#endif #endif

View File

@ -135,7 +135,7 @@ typedef int (*hio_svc_fcgic_on_write_t) (
typedef void (*hio_svc_fcgic_on_untie_t) ( typedef void (*hio_svc_fcgic_on_untie_t) (
hio_svc_fcgic_sess_t* sess, hio_svc_fcgic_sess_t* sess,
void* ctx; void* ctx
); );
struct hio_svc_fcgic_sess_t struct hio_svc_fcgic_sess_t

View File

@ -79,8 +79,7 @@ typedef enum hio_perenc_http_option_t hio_perenc_bcstr_option_t;
enum hio_svc_htts_option_t enum hio_svc_htts_option_t
{ {
HIO_SVC_HTTS_TASK_MAX, HIO_SVC_HTTS_TASK_MAX,
HIO_SVC_HTTS_TASK_CGI_MAX, HIO_SVC_HTTS_TASK_CGI_MAX
HIO_SVC_HTTS_FCGI_TMOUT,
}; };
typedef enum hio_svc_htts_option_t hio_svc_htts_option_t; typedef enum hio_svc_htts_option_t hio_svc_htts_option_t;
@ -397,14 +396,23 @@ HIO_EXPORT hio_svc_htts_t* hio_svc_htts_start (
hio_oow_t xtnsize, hio_oow_t xtnsize,
hio_dev_sck_bind_t* binds, hio_dev_sck_bind_t* binds,
hio_oow_t nbinds, hio_oow_t nbinds,
hio_svc_htts_proc_req_t proc_req, hio_svc_htts_proc_req_t proc_req
const hio_svc_fcgic_tmout_t* fcgic_tmout
); );
HIO_EXPORT void hio_svc_htts_stop ( HIO_EXPORT void hio_svc_htts_stop (
hio_svc_htts_t* htts hio_svc_htts_t* htts
); );
HIO_EXPORT void* hio_svc_htts_getxtn (
hio_svc_htts_t* htts
);
#if defined(HIO_HAVE_INLINE)
static HIO_INLINE hio_t* hio_svc_htts_gethio(hio_svc_htts_t* svc) { return hio_svc_gethio((hio_svc_t*)svc); }
#else
# define hio_svc_htts_gethio(svc) hio_svc_gethio(svc)
#endif
HIO_EXPORT int hio_svc_htts_getoption ( HIO_EXPORT int hio_svc_htts_getoption (
hio_svc_htts_t* htts, hio_svc_htts_t* htts,
hio_svc_htts_option_t id, hio_svc_htts_option_t id,
@ -417,16 +425,11 @@ HIO_EXPORT int hio_svc_htts_setoption (
const void* value const void* value
); );
HIO_EXPORT void* hio_svc_htts_getxtn ( HIO_EXPORT int hio_svc_htts_enablefcgic (
hio_svc_htts_t* htts hio_svc_htts_t* htts,
hio_svc_fcgic_tmout_t* tmout
); );
#if defined(HIO_HAVE_INLINE)
static HIO_INLINE hio_t* hio_svc_htts_gethio(hio_svc_htts_t* svc) { return hio_svc_gethio((hio_svc_t*)svc); }
#else
# define hio_svc_htts_gethio(svc) hio_svc_gethio(svc)
#endif
HIO_EXPORT int hio_svc_htts_writetosidechan ( HIO_EXPORT int hio_svc_htts_writetosidechan (
hio_svc_htts_t* htts, hio_svc_htts_t* htts,
hio_oow_t idx, /* listener index */ hio_oow_t idx, /* listener index */

View File

@ -1444,7 +1444,7 @@ update_timer:
dev->rtmridx = HIO_TMRIDX_INVALID; dev->rtmridx = HIO_TMRIDX_INVALID;
} }
if (tmout && HIO_IS_POS_NTIME(tmout)) if (tmout && !HIO_IS_NEG_NTIME(tmout))
{ {
hio_tmrjob_t tmrjob; hio_tmrjob_t tmrjob;
@ -1584,7 +1584,7 @@ static HIO_INLINE int __enqueue_pending_write (hio_dev_t* dev, hio_iolen_t olen,
j += iov[i].iov_len; j += iov[i].iov_len;
} }
if (tmout && HIO_IS_POS_NTIME(tmout)) if (tmout && !HIO_IS_NEG_NTIME(tmout))
{ {
hio_tmrjob_t tmrjob; hio_tmrjob_t tmrjob;
@ -1657,7 +1657,7 @@ static HIO_INLINE int __enqueue_pending_sendfile (hio_dev_t* dev, hio_iolen_t ol
((wq_sendfile_data_t*)q->ptr)->in_fd = in_fd; ((wq_sendfile_data_t*)q->ptr)->in_fd = in_fd;
((wq_sendfile_data_t*)q->ptr)->foff = foff; ((wq_sendfile_data_t*)q->ptr)->foff = foff;
if (tmout && HIO_IS_POS_NTIME(tmout)) if (tmout && !HIO_IS_NEG_NTIME(tmout))
{ {
hio_tmrjob_t tmrjob; hio_tmrjob_t tmrjob;

View File

@ -192,6 +192,7 @@ static void cgi_on_kill (hio_svc_htts_task_t* task)
} }
if (cgi->task_next) HIO_SVC_HTTS_TASKL_UNLINK_TASK (cgi); /* detach from the htts service only if it's attached */ if (cgi->task_next) HIO_SVC_HTTS_TASKL_UNLINK_TASK (cgi); /* detach from the htts service only if it's attached */
cgi->htts->stat.ntask_cgis--;
HIO_DEBUG5 (hio, "HTTS(%p) - cgi(t=%p,c=%p[%d],p=%p) - killed the task\n", cgi->htts, cgi, cgi->task_client, (cgi->task_csck? cgi->task_csck->hnd: -1), cgi->peer); HIO_DEBUG5 (hio, "HTTS(%p) - cgi(t=%p,c=%p[%d],p=%p) - killed the task\n", cgi->htts, cgi, cgi->task_client, (cgi->task_csck? cgi->task_csck->hnd: -1), cgi->peer);
} }
@ -938,9 +939,16 @@ int hio_svc_htts_docgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t* r
HIO_ASSERT (hio, hio_htre_getcontentlen(req) == 0); HIO_ASSERT (hio, hio_htre_getcontentlen(req) == 0);
HIO_ASSERT (hio, cli->sck == csck); HIO_ASSERT (hio, cli->sck == csck);
if (htts->stat.ntask_cgis >= htts->option.task_cgi_max)
{
hio_seterrbfmt (hio, HIO_ENOCAPA, "too many cgi tasks");
return -1;
}
cgi = (cgi_t*)hio_svc_htts_task_make(htts, HIO_SIZEOF(*cgi), cgi_on_kill, req, csck); cgi = (cgi_t*)hio_svc_htts_task_make(htts, HIO_SIZEOF(*cgi), cgi_on_kill, req, csck);
if (HIO_UNLIKELY(!cgi)) goto oops; if (HIO_UNLIKELY(!cgi)) goto oops;
HIO_SVC_HTTS_TASK_RCUP((hio_svc_htts_task_t*)cgi); HIO_SVC_HTTS_TASK_RCUP((hio_svc_htts_task_t*)cgi);
htts->stat.ntask_cgis++;
cgi->on_kill = on_kill; cgi->on_kill = on_kill;
cgi->options = options; cgi->options = options;

View File

@ -825,7 +825,6 @@ static void unbind_task_from_peer (file_t* file, int rcdown)
{ {
while (n > 0) while (n > 0)
{ {
HIO_DEBUG1(hio, "RCDOWN.... %d\n", n);
n--; n--;
HIO_SVC_HTTS_TASK_RCDOWN((hio_svc_htts_task_t*)file); HIO_SVC_HTTS_TASK_RCDOWN((hio_svc_htts_task_t*)file);
} }

View File

@ -79,8 +79,17 @@ struct hio_svc_htts_t
hio_becs_t* becbuf; /* temporary buffer for any work */ hio_becs_t* becbuf; /* temporary buffer for any work */
int fcgic_tmout_set; struct
hio_svc_fcgic_tmout_t fcgic_tmout; {
hio_oow_t task_max;
hio_oow_t task_cgi_max;
} option;
struct
{
hio_ooi_t ntasks;
hio_ooi_t ntask_cgis;
} stat;
}; };
struct hio_svc_httc_t struct hio_svc_httc_t

View File

@ -427,7 +427,7 @@ static void halt_idle_clients (hio_t* hio, const hio_ntime_t* now, hio_tmrjob_t*
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
hio_svc_htts_t* hio_svc_htts_start (hio_t* hio, hio_oow_t xtnsize, hio_dev_sck_bind_t* binds, hio_oow_t nbinds, hio_svc_htts_proc_req_t proc_req, const hio_svc_fcgic_tmout_t* fcgic_tmout) hio_svc_htts_t* hio_svc_htts_start (hio_t* hio, hio_oow_t xtnsize, hio_dev_sck_bind_t* binds, hio_oow_t nbinds, hio_svc_htts_proc_req_t proc_req)
{ {
hio_svc_htts_t* htts = HIO_NULL; hio_svc_htts_t* htts = HIO_NULL;
union union
@ -454,11 +454,8 @@ hio_svc_htts_t* hio_svc_htts_start (hio_t* hio, hio_oow_t xtnsize, hio_dev_sck_b
htts->proc_req = proc_req; htts->proc_req = proc_req;
htts->idle_tmridx = HIO_TMRIDX_INVALID; htts->idle_tmridx = HIO_TMRIDX_INVALID;
if (fcgic_tmout) htts->option.task_max = HIO_TYPE_MAX(hio_oow_t);
{ htts->option.task_cgi_max = HIO_TYPE_MAX(hio_oow_t);
htts->fcgic_tmout_set = 1;
htts->fcgic_tmout = *fcgic_tmout;
}
htts->becbuf = hio_becs_open(hio, 0, 256); htts->becbuf = hio_becs_open(hio, 0, 256);
if (HIO_UNLIKELY(!htts->becbuf)) goto oops; if (HIO_UNLIKELY(!htts->becbuf)) goto oops;
@ -574,13 +571,6 @@ hio_svc_htts_t* hio_svc_htts_start (hio_t* hio, hio_oow_t xtnsize, hio_dev_sck_b
HIO_SVC_HTTS_CLIL_INIT (&htts->cli); HIO_SVC_HTTS_CLIL_INIT (&htts->cli);
HIO_SVC_HTTS_TASKL_INIT (&htts->task); HIO_SVC_HTTS_TASKL_INIT (&htts->task);
htts->fcgic = hio_svc_fcgic_start(htts->hio, (htts->fcgic_tmout_set? &htts->fcgic_tmout: HIO_NULL));
if (HIO_UNLIKELY(!htts->fcgic))
{
/* TODO: only warning ... */
}
HIO_DEBUG1 (hio, "HTTS - STARTED SERVICE %p\n", htts); HIO_DEBUG1 (hio, "HTTS - STARTED SERVICE %p\n", htts);
{ {
@ -674,6 +664,58 @@ void* hio_svc_htts_getxtn (hio_svc_htts_t* htts)
return (void*)(htts + 1); return (void*)(htts + 1);
} }
int hio_svc_htts_getoption (hio_svc_htts_t* htts, hio_svc_htts_option_t id, void* value)
{
switch (id)
{
case HIO_SVC_HTTS_TASK_MAX:
*(hio_oow_t*)value = htts->option.task_max;
break;
case HIO_SVC_HTTS_TASK_CGI_MAX:
*(hio_oow_t*)value = htts->option.task_cgi_max;
break;
default:
goto einval;
}
return 0;
einval:
hio_seterrnum (htts->hio, HIO_EINVAL);
}
int hio_svc_htts_setoption (hio_svc_htts_t* htts, hio_svc_htts_option_t id, const void* value)
{
switch (id)
{
case HIO_SVC_HTTS_TASK_MAX:
htts->option.task_max = *(const hio_oow_t*)value;
break;
case HIO_SVC_HTTS_TASK_CGI_MAX:
htts->option.task_cgi_max = *(const hio_oow_t*)value;
break;
default:
goto einval;
}
return 0;
einval:
hio_seterrnum (htts->hio, HIO_EINVAL);
return -1;
}
int hio_svc_htts_enablefcgic (hio_svc_htts_t* htts, hio_svc_fcgic_tmout_t* tmout)
{
if (htts->fcgic) return 0;
htts->fcgic = hio_svc_fcgic_start(htts->hio, tmout);
return htts->fcgic? 0: -1;
}
int hio_svc_htts_setservernamewithbcstr (hio_svc_htts_t* htts, const hio_bch_t* name) int hio_svc_htts_setservernamewithbcstr (hio_svc_htts_t* htts, const hio_bch_t* name)
{ {
hio_t* hio = htts->hio; hio_t* hio = htts->hio;
@ -795,6 +837,7 @@ hio_svc_htts_task_t* hio_svc_htts_task_make (hio_svc_htts_t* htts, hio_oow_t tas
HIO_ASSERT (hio, csck->on_write == client_on_write); HIO_ASSERT (hio, csck->on_write == client_on_write);
HIO_ASSERT (hio, csck->on_disconnect == client_on_disconnect); HIO_ASSERT (hio, csck->on_disconnect == client_on_disconnect);
htts->stat.ntasks++;
HIO_DEBUG2 (hio, "HTTS(%p) - allocated task %p\n", htts, task); HIO_DEBUG2 (hio, "HTTS(%p) - allocated task %p\n", htts, task);
return task; return task;
} }
@ -809,6 +852,7 @@ void hio_svc_htts_task_kill (hio_svc_htts_task_t* task)
if (task->task_on_kill) task->task_on_kill (task); if (task->task_on_kill) task->task_on_kill (task);
hio_freemem (hio, task); hio_freemem (hio, task);
htts->stat.ntasks--;
HIO_DEBUG2 (hio, "HTTS(%p) - destroyed task %p\n", htts, task); HIO_DEBUG2 (hio, "HTTS(%p) - destroyed task %p\n", htts, task);
} }

View File

@ -184,7 +184,7 @@ static void thr_on_kill (hio_svc_htts_task_t* task)
* it is the task destruction callback. (passing 0 to unbind_task_from_peer/client) * it is the task destruction callback. (passing 0 to unbind_task_from_peer/client)
*/ */
unbind_task_from_peer (task, 0); unbind_task_from_peer (thr, 0);
if (thr->task_csck) if (thr->task_csck)
{ {
@ -301,7 +301,8 @@ oops:
static int peer_capture_response_header (hio_htre_t* req, const hio_bch_t* key, const hio_htre_hdrval_t* val, void* ctx) static int peer_capture_response_header (hio_htre_t* req, const hio_bch_t* key, const hio_htre_hdrval_t* val, void* ctx)
{ {
return hio_svc_htts_task_addreshdrs((thr_t*)ctx, key, val); thr_t* thr = (thr_t*)ctx;
return hio_svc_htts_task_addreshdrs(thr, key, val);
} }
static int thr_peer_htrd_peek (hio_htrd_t* htrd, hio_htre_t* req) static int thr_peer_htrd_peek (hio_htrd_t* htrd, hio_htre_t* req)

View File

@ -1477,9 +1477,9 @@ fcntl (rdev->hnd, F_SETFL, flags | O_NONBLOCK);
} }
else else
{ {
HIO_INIT_NTIME (&rdev->tmout, 0, 0); /* just in case */ HIO_INIT_NTIME (&rdev->tmout, -1, 0); /* just in case */
if (HIO_IS_POS_NTIME(&conn->connect_tmout)) if (!HIO_IS_NEG_NTIME(&conn->connect_tmout))
{ {
if (schedule_timer_job_after(rdev, &conn->connect_tmout, connect_timedout) <= -1) if (schedule_timer_job_after(rdev, &conn->connect_tmout, connect_timedout) <= -1)
{ {
@ -1761,7 +1761,7 @@ static int harvest_outgoing_connection (hio_dev_sck_t* rdev)
/* rdev->tmout has been set to the deadline of the connect task /* rdev->tmout has been set to the deadline of the connect task
* when the CONNECT IOCTL command has been executed. use the * when the CONNECT IOCTL command has been executed. use the
* same deadline here */ * same deadline here */
if (HIO_IS_POS_NTIME(&rdev->tmout) && if (!HIO_IS_NEG_NTIME(&rdev->tmout) &&
schedule_timer_job_at(rdev, &rdev->tmout, ssl_connect_timedout) <= -1) schedule_timer_job_at(rdev, &rdev->tmout, ssl_connect_timedout) <= -1)
{ {
HIO_DEBUG1 (hio, "SCK(%p) - ssl-connect timeout scheduling failed. halting\n", rdev); HIO_DEBUG1 (hio, "SCK(%p) - ssl-connect timeout scheduling failed. halting\n", rdev);
@ -1907,7 +1907,7 @@ static int make_accepted_client_connection (hio_dev_sck_t* rdev, hio_syshnd_t cl
/* let the client device know the SSL context to use */ /* let the client device know the SSL context to use */
clidev->ssl_ctx = rdev->ssl_ctx; clidev->ssl_ctx = rdev->ssl_ctx;
if (HIO_IS_POS_NTIME(&rdev->tmout) && if (!HIO_IS_NEG_NTIME(&rdev->tmout) &&
schedule_timer_job_after(clidev, &rdev->tmout, ssl_accept_timedout) <= -1) schedule_timer_job_after(clidev, &rdev->tmout, ssl_accept_timedout) <= -1)
{ {
/* timer job scheduling failed. halt the device */ /* timer job scheduling failed. halt the device */

View File

@ -240,7 +240,7 @@ int hio_schedtmrjobafter (hio_t* hio, const hio_ntime_t* fire_after, hio_tmrjob_
{ {
hio_ntime_t fire_at; hio_ntime_t fire_at;
HIO_ASSERT (hio, HIO_IS_POS_NTIME(fire_after)); HIO_ASSERT (hio, !HIO_IS_NEG_NTIME(fire_after));
hio_gettime (hio, &fire_at); hio_gettime (hio, &fire_at);
HIO_ADD_NTIME (&fire_at, &fire_at, fire_after); HIO_ADD_NTIME (&fire_at, &fire_at, fire_after);

View File

@ -12,6 +12,7 @@ test_default_index()
mkdir -p "${tmpdir}" mkdir -p "${tmpdir}"
## check if index.html is retrieved ## check if index.html is retrieved
echo ../bin/hio-webs --file-no-list-dir "${srvaddr}" "${tmpdir}" 2>/dev/null &
../bin/hio-webs --file-no-list-dir "${srvaddr}" "${tmpdir}" 2>/dev/null & ../bin/hio-webs --file-no-list-dir "${srvaddr}" "${tmpdir}" 2>/dev/null &
local jid=$! local jid=$!