Compare commits

...
4 Commits
31 changed files with 848 additions and 474 deletions
-7
View File
@@ -90,10 +90,3 @@ hio_t05_CPPFLAGS = $(CPPFLAGS_COMMON)
hio_t05_CFLAGS = $(CFLAGS_COMMON) hio_t05_CFLAGS = $(CFLAGS_COMMON)
hio_t05_LDFLAGS = $(LDFLAGS_COMMON) hio_t05_LDFLAGS = $(LDFLAGS_COMMON)
hio_t05_LDADD = $(LIBADD_COMMON) hio_t05_LDADD = $(LIBADD_COMMON)
noinst_PROGRAMS += hio-t06
hio_t06_SOURCES = t06.c
hio_t06_CPPFLAGS = $(CPPFLAGS_COMMON)
hio_t06_CFLAGS = $(CFLAGS_COMMON)
hio_t06_LDFLAGS = $(LDFLAGS_COMMON)
hio_t06_LDADD = $(LIBADD_COMMON)
+6 -41
View File
@@ -94,7 +94,7 @@ bin_PROGRAMS = hio-execd$(EXEEXT) $(am__EXEEXT_1) hio-untar$(EXEEXT) \
hio-webs$(EXEEXT) hio-webs$(EXEEXT)
@HAVE_X11_LIB_TRUE@am__append_1 = hio-te @HAVE_X11_LIB_TRUE@am__append_1 = hio-te
noinst_PROGRAMS = hio-t01$(EXEEXT) hio-t02$(EXEEXT) hio-t03$(EXEEXT) \ noinst_PROGRAMS = hio-t01$(EXEEXT) hio-t02$(EXEEXT) hio-t03$(EXEEXT) \
hio-t04$(EXEEXT) hio-t05$(EXEEXT) hio-t06$(EXEEXT) hio-t04$(EXEEXT) hio-t05$(EXEEXT)
@ENABLE_MARIADB_TRUE@am__append_2 = $(MARIADB_CFLAGS) @ENABLE_MARIADB_TRUE@am__append_2 = $(MARIADB_CFLAGS)
@ENABLE_MARIADB_TRUE@am__append_3 = $(MARIADB_LDFLAGS) @ENABLE_MARIADB_TRUE@am__append_3 = $(MARIADB_LDFLAGS)
@ENABLE_MARIADB_TRUE@am__append_4 = $(MARIADB_LIBS) @ENABLE_MARIADB_TRUE@am__append_4 = $(MARIADB_LIBS)
@@ -158,12 +158,6 @@ hio_t05_DEPENDENCIES = $(LIBADD_COMMON)
hio_t05_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ hio_t05_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(hio_t05_CFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(hio_t05_CFLAGS) \
$(CFLAGS) $(hio_t05_LDFLAGS) $(LDFLAGS) -o $@ $(CFLAGS) $(hio_t05_LDFLAGS) $(LDFLAGS) -o $@
am_hio_t06_OBJECTS = hio_t06-t06.$(OBJEXT)
hio_t06_OBJECTS = $(am_hio_t06_OBJECTS)
hio_t06_DEPENDENCIES = $(LIBADD_COMMON)
hio_t06_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(hio_t06_CFLAGS) \
$(CFLAGS) $(hio_t06_LDFLAGS) $(LDFLAGS) -o $@
am__hio_te_SOURCES_DIST = te.c am__hio_te_SOURCES_DIST = te.c
@HAVE_X11_LIB_TRUE@am_hio_te_OBJECTS = hio_te-te.$(OBJEXT) @HAVE_X11_LIB_TRUE@am_hio_te_OBJECTS = hio_te-te.$(OBJEXT)
hio_te_OBJECTS = $(am_hio_te_OBJECTS) hio_te_OBJECTS = $(am_hio_te_OBJECTS)
@@ -201,9 +195,8 @@ am__maybe_remake_depfiles = depfiles
am__depfiles_remade = ./$(DEPDIR)/hio_execd-execd.Po \ am__depfiles_remade = ./$(DEPDIR)/hio_execd-execd.Po \
./$(DEPDIR)/hio_t01-t01.Po ./$(DEPDIR)/hio_t02-t02.Po \ ./$(DEPDIR)/hio_t01-t01.Po ./$(DEPDIR)/hio_t02-t02.Po \
./$(DEPDIR)/hio_t03-t03.Po ./$(DEPDIR)/hio_t04-t04.Po \ ./$(DEPDIR)/hio_t03-t03.Po ./$(DEPDIR)/hio_t04-t04.Po \
./$(DEPDIR)/hio_t05-t05.Po ./$(DEPDIR)/hio_t06-t06.Po \ ./$(DEPDIR)/hio_t05-t05.Po ./$(DEPDIR)/hio_te-te.Po \
./$(DEPDIR)/hio_te-te.Po ./$(DEPDIR)/hio_untar-untar.Po \ ./$(DEPDIR)/hio_untar-untar.Po ./$(DEPDIR)/hio_webs-webs.Po
./$(DEPDIR)/hio_webs-webs.Po
am__mv = mv -f am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -225,13 +218,11 @@ am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 = am__v_CCLD_1 =
SOURCES = $(hio_execd_SOURCES) $(hio_t01_SOURCES) $(hio_t02_SOURCES) \ SOURCES = $(hio_execd_SOURCES) $(hio_t01_SOURCES) $(hio_t02_SOURCES) \
$(hio_t03_SOURCES) $(hio_t04_SOURCES) $(hio_t05_SOURCES) \ $(hio_t03_SOURCES) $(hio_t04_SOURCES) $(hio_t05_SOURCES) \
$(hio_t06_SOURCES) $(hio_te_SOURCES) $(hio_untar_SOURCES) \ $(hio_te_SOURCES) $(hio_untar_SOURCES) $(hio_webs_SOURCES)
$(hio_webs_SOURCES)
DIST_SOURCES = $(hio_execd_SOURCES) $(hio_t01_SOURCES) \ DIST_SOURCES = $(hio_execd_SOURCES) $(hio_t01_SOURCES) \
$(hio_t02_SOURCES) $(hio_t03_SOURCES) $(hio_t04_SOURCES) \ $(hio_t02_SOURCES) $(hio_t03_SOURCES) $(hio_t04_SOURCES) \
$(hio_t05_SOURCES) $(hio_t06_SOURCES) \ $(hio_t05_SOURCES) $(am__hio_te_SOURCES_DIST) \
$(am__hio_te_SOURCES_DIST) $(hio_untar_SOURCES) \ $(hio_untar_SOURCES) $(hio_webs_SOURCES)
$(hio_webs_SOURCES)
am__can_run_installinfo = \ am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \ case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \ n|no|NO) false;; \
@@ -460,11 +451,6 @@ hio_t05_CPPFLAGS = $(CPPFLAGS_COMMON)
hio_t05_CFLAGS = $(CFLAGS_COMMON) hio_t05_CFLAGS = $(CFLAGS_COMMON)
hio_t05_LDFLAGS = $(LDFLAGS_COMMON) hio_t05_LDFLAGS = $(LDFLAGS_COMMON)
hio_t05_LDADD = $(LIBADD_COMMON) hio_t05_LDADD = $(LIBADD_COMMON)
hio_t06_SOURCES = t06.c
hio_t06_CPPFLAGS = $(CPPFLAGS_COMMON)
hio_t06_CFLAGS = $(CFLAGS_COMMON)
hio_t06_LDFLAGS = $(LDFLAGS_COMMON)
hio_t06_LDADD = $(LIBADD_COMMON)
all: all-am all: all-am
.SUFFIXES: .SUFFIXES:
@@ -571,10 +557,6 @@ hio-t05$(EXEEXT): $(hio_t05_OBJECTS) $(hio_t05_DEPENDENCIES) $(EXTRA_hio_t05_DEP
@rm -f hio-t05$(EXEEXT) @rm -f hio-t05$(EXEEXT)
$(AM_V_CCLD)$(hio_t05_LINK) $(hio_t05_OBJECTS) $(hio_t05_LDADD) $(LIBS) $(AM_V_CCLD)$(hio_t05_LINK) $(hio_t05_OBJECTS) $(hio_t05_LDADD) $(LIBS)
hio-t06$(EXEEXT): $(hio_t06_OBJECTS) $(hio_t06_DEPENDENCIES) $(EXTRA_hio_t06_DEPENDENCIES)
@rm -f hio-t06$(EXEEXT)
$(AM_V_CCLD)$(hio_t06_LINK) $(hio_t06_OBJECTS) $(hio_t06_LDADD) $(LIBS)
hio-te$(EXEEXT): $(hio_te_OBJECTS) $(hio_te_DEPENDENCIES) $(EXTRA_hio_te_DEPENDENCIES) hio-te$(EXEEXT): $(hio_te_OBJECTS) $(hio_te_DEPENDENCIES) $(EXTRA_hio_te_DEPENDENCIES)
@rm -f hio-te$(EXEEXT) @rm -f hio-te$(EXEEXT)
$(AM_V_CCLD)$(hio_te_LINK) $(hio_te_OBJECTS) $(hio_te_LDADD) $(LIBS) $(AM_V_CCLD)$(hio_te_LINK) $(hio_te_OBJECTS) $(hio_te_LDADD) $(LIBS)
@@ -599,7 +581,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hio_t03-t03.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hio_t03-t03.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hio_t04-t04.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hio_t04-t04.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hio_t05-t05.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hio_t05-t05.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hio_t06-t06.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hio_te-te.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hio_te-te.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hio_untar-untar.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hio_untar-untar.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hio_webs-webs.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hio_webs-webs.Po@am__quote@ # am--include-marker
@@ -718,20 +699,6 @@ hio_t05-t05.obj: t05.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t05_CPPFLAGS) $(CPPFLAGS) $(hio_t05_CFLAGS) $(CFLAGS) -c -o hio_t05-t05.obj `if test -f 't05.c'; then $(CYGPATH_W) 't05.c'; else $(CYGPATH_W) '$(srcdir)/t05.c'; fi` @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t05_CPPFLAGS) $(CPPFLAGS) $(hio_t05_CFLAGS) $(CFLAGS) -c -o hio_t05-t05.obj `if test -f 't05.c'; then $(CYGPATH_W) 't05.c'; else $(CYGPATH_W) '$(srcdir)/t05.c'; fi`
hio_t06-t06.o: t06.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t06_CPPFLAGS) $(CPPFLAGS) $(hio_t06_CFLAGS) $(CFLAGS) -MT hio_t06-t06.o -MD -MP -MF $(DEPDIR)/hio_t06-t06.Tpo -c -o hio_t06-t06.o `test -f 't06.c' || echo '$(srcdir)/'`t06.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hio_t06-t06.Tpo $(DEPDIR)/hio_t06-t06.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t06.c' object='hio_t06-t06.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t06_CPPFLAGS) $(CPPFLAGS) $(hio_t06_CFLAGS) $(CFLAGS) -c -o hio_t06-t06.o `test -f 't06.c' || echo '$(srcdir)/'`t06.c
hio_t06-t06.obj: t06.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t06_CPPFLAGS) $(CPPFLAGS) $(hio_t06_CFLAGS) $(CFLAGS) -MT hio_t06-t06.obj -MD -MP -MF $(DEPDIR)/hio_t06-t06.Tpo -c -o hio_t06-t06.obj `if test -f 't06.c'; then $(CYGPATH_W) 't06.c'; else $(CYGPATH_W) '$(srcdir)/t06.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hio_t06-t06.Tpo $(DEPDIR)/hio_t06-t06.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='t06.c' object='hio_t06-t06.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_t06_CPPFLAGS) $(CPPFLAGS) $(hio_t06_CFLAGS) $(CFLAGS) -c -o hio_t06-t06.obj `if test -f 't06.c'; then $(CYGPATH_W) 't06.c'; else $(CYGPATH_W) '$(srcdir)/t06.c'; fi`
hio_te-te.o: te.c hio_te-te.o: te.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_te_CPPFLAGS) $(CPPFLAGS) $(hio_te_CFLAGS) $(CFLAGS) -MT hio_te-te.o -MD -MP -MF $(DEPDIR)/hio_te-te.Tpo -c -o hio_te-te.o `test -f 'te.c' || echo '$(srcdir)/'`te.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hio_te_CPPFLAGS) $(CPPFLAGS) $(hio_te_CFLAGS) $(CFLAGS) -MT hio_te-te.o -MD -MP -MF $(DEPDIR)/hio_te-te.Tpo -c -o hio_te-te.o `test -f 'te.c' || echo '$(srcdir)/'`te.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hio_te-te.Tpo $(DEPDIR)/hio_te-te.Po @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hio_te-te.Tpo $(DEPDIR)/hio_te-te.Po
@@ -914,7 +881,6 @@ distclean: distclean-am
-rm -f ./$(DEPDIR)/hio_t03-t03.Po -rm -f ./$(DEPDIR)/hio_t03-t03.Po
-rm -f ./$(DEPDIR)/hio_t04-t04.Po -rm -f ./$(DEPDIR)/hio_t04-t04.Po
-rm -f ./$(DEPDIR)/hio_t05-t05.Po -rm -f ./$(DEPDIR)/hio_t05-t05.Po
-rm -f ./$(DEPDIR)/hio_t06-t06.Po
-rm -f ./$(DEPDIR)/hio_te-te.Po -rm -f ./$(DEPDIR)/hio_te-te.Po
-rm -f ./$(DEPDIR)/hio_untar-untar.Po -rm -f ./$(DEPDIR)/hio_untar-untar.Po
-rm -f ./$(DEPDIR)/hio_webs-webs.Po -rm -f ./$(DEPDIR)/hio_webs-webs.Po
@@ -969,7 +935,6 @@ maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/hio_t03-t03.Po -rm -f ./$(DEPDIR)/hio_t03-t03.Po
-rm -f ./$(DEPDIR)/hio_t04-t04.Po -rm -f ./$(DEPDIR)/hio_t04-t04.Po
-rm -f ./$(DEPDIR)/hio_t05-t05.Po -rm -f ./$(DEPDIR)/hio_t05-t05.Po
-rm -f ./$(DEPDIR)/hio_t06-t06.Po
-rm -f ./$(DEPDIR)/hio_te-te.Po -rm -f ./$(DEPDIR)/hio_te-te.Po
-rm -f ./$(DEPDIR)/hio_untar-untar.Po -rm -f ./$(DEPDIR)/hio_untar-untar.Po
-rm -f ./$(DEPDIR)/hio_webs-webs.Po -rm -f ./$(DEPDIR)/hio_webs-webs.Po
+5 -5
View File
@@ -341,8 +341,8 @@ static int on_tcp_write (hio_dev_sck_t* dev, hio_iolen_t wrlen, void* wrctx, con
HIO_MEMSET(&tmrjob, 0, HIO_SIZEOF(tmrjob)); HIO_MEMSET(&tmrjob, 0, HIO_SIZEOF(tmrjob));
tmrjob.ctx = msg; tmrjob.ctx = msg;
hio_gettime (hio, &tmrjob.when); hio_gettime(hio, &tmrjob.when);
HIO_ADD_NTIME (&tmrjob.when, &tmrjob.when, &msgxtn->rtmout); HIO_ADD_NTIME(&tmrjob.when, &tmrjob.when, &msgxtn->rtmout);
tmrjob.handler = on_tcp_reply_timeout; tmrjob.handler = on_tcp_reply_timeout;
tmrjob.idxptr = &msgxtn->rtmridx; tmrjob.idxptr = &msgxtn->rtmridx;
msgxtn->rtmridx = hio_instmrjob(hio, &tmrjob); msgxtn->rtmridx = hio_instmrjob(hio, &tmrjob);
@@ -655,8 +655,8 @@ static int on_udp_write (hio_dev_sck_t* dev, hio_iolen_t wrlen, void* wrctx, con
HIO_DEBUG1 (hio, "DNC - sent dns question over udp - msgid:%d\n", (int)hio_ntoh16(hio_dns_msg_to_pkt(msg)->id)); HIO_DEBUG1 (hio, "DNC - sent dns question over udp - msgid:%d\n", (int)hio_ntoh16(hio_dns_msg_to_pkt(msg)->id));
HIO_MEMSET(&tmrjob, 0, HIO_SIZEOF(tmrjob)); HIO_MEMSET(&tmrjob, 0, HIO_SIZEOF(tmrjob));
tmrjob.ctx = msg; tmrjob.ctx = msg;
hio_gettime (hio, &tmrjob.when); hio_gettime(hio, &tmrjob.when);
HIO_ADD_NTIME (&tmrjob.when, &tmrjob.when, &msgxtn->rtmout); HIO_ADD_NTIME(&tmrjob.when, &tmrjob.when, &msgxtn->rtmout);
tmrjob.handler = on_udp_reply_timeout; tmrjob.handler = on_udp_reply_timeout;
tmrjob.idxptr = &msgxtn->rtmridx; tmrjob.idxptr = &msgxtn->rtmridx;
msgxtn->rtmridx = hio_instmrjob(hio, &tmrjob); msgxtn->rtmridx = hio_instmrjob(hio, &tmrjob);
@@ -771,7 +771,7 @@ hio_svc_dnc_t* hio_svc_dnc_start (hio_t* hio, const hio_skad_t* serv_addr, const
/* initialize the dns cookie key */ /* initialize the dns cookie key */
hio_gettime (hio, &now); hio_gettime(hio, &now);
HIO_MEMCPY(&dnc->cookie.key[0], &now.sec, (HIO_SIZEOF(now.sec) < 8? HIO_SIZEOF(now.sec): 8)); HIO_MEMCPY(&dnc->cookie.key[0], &now.sec, (HIO_SIZEOF(now.sec) < 8? HIO_SIZEOF(now.sec): 8));
HIO_MEMCPY(&dnc->cookie.key[8], &now.nsec, (HIO_SIZEOF(now.nsec) < 8? HIO_SIZEOF(now.nsec): 8)); HIO_MEMCPY(&dnc->cookie.key[8], &now.nsec, (HIO_SIZEOF(now.nsec) < 8? HIO_SIZEOF(now.nsec): 8));
+4 -4
View File
@@ -1283,15 +1283,15 @@ static int fmt_outv (hio_fmtout_t* fmtout, va_list ap)
done: done:
#if defined(HIO_ENABLE_FLTFMT) #if defined(HIO_ENABLE_FLTFMT)
if (fb.fmt.ptr != fb.fmt.sbuf) HIO_MMGR_FREE (fmtout->mmgr, fb.fmt.ptr); if (fb.fmt.ptr != fb.fmt.sbuf) HIO_MMGR_FREE(fmtout->mmgr, fb.fmt.ptr);
if (fb.out.ptr != fb.out.sbuf) HIO_MMGR_FREE (fmtout->mmgr, fb.out.ptr); if (fb.out.ptr != fb.out.sbuf) HIO_MMGR_FREE(fmtout->mmgr, fb.out.ptr);
#endif #endif
return 0; return 0;
oops: oops:
#if defined(HIO_ENABLE_FLTFMT) #if defined(HIO_ENABLE_FLTFMT)
if (fb.fmt.ptr != fb.fmt.sbuf) HIO_MMGR_FREE (fmtout->mmgr, fb.fmt.ptr); if (fb.fmt.ptr != fb.fmt.sbuf) HIO_MMGR_FREE(fmtout->mmgr, fb.fmt.ptr);
if (fb.out.ptr != fb.out.sbuf) HIO_MMGR_FREE (fmtout->mmgr, fb.out.ptr); if (fb.out.ptr != fb.out.sbuf) HIO_MMGR_FREE(fmtout->mmgr, fb.out.ptr);
#endif #endif
return -1; return -1;
} }
+22 -2
View File
@@ -107,9 +107,8 @@ typedef void (*hio_svc_htts_task_on_kill_t) (
hio_svc_htts_task_on_kill_t task_on_kill; \ hio_svc_htts_task_on_kill_t task_on_kill; \
hio_dev_sck_t* task_csck; \ hio_dev_sck_t* task_csck; \
hio_svc_htts_cli_t* task_client; \ hio_svc_htts_cli_t* task_client; \
hio_dev_sck_evcb_link_t task_client_evcb_link; \ const hio_dev_sck_evcb_t* task_evcb; \
hio_htrd_recbs_t task_client_htrd_org_recbs; \ hio_htrd_recbs_t task_client_htrd_org_recbs; \
unsigned int task_client_evcb_pushed: 1; \
unsigned int task_client_htrd_recbs_changed: 1; \ unsigned int task_client_htrd_recbs_changed: 1; \
unsigned int task_keep_client_alive: 1; \ unsigned int task_keep_client_alive: 1; \
unsigned int task_req_qpath_ending_with_slash: 1; \ unsigned int task_req_qpath_ending_with_slash: 1; \
@@ -545,6 +544,27 @@ HIO_EXPORT void hio_svc_htts_task_bindtoclient (
const hio_dev_sck_evcb_t* evcb const hio_dev_sck_evcb_t* evcb
); );
/* The http service's own client handling. While a task is bound its
* handlers run instead of these; a task that wants the default behaviour
* as well calls the matching function explicitly. */
HIO_EXPORT int hio_svc_htts_client_default_on_read (
hio_dev_sck_t* sck,
const void* buf,
hio_iolen_t len,
const hio_skad_t* srcaddr
);
HIO_EXPORT int hio_svc_htts_client_default_on_write (
hio_dev_sck_t* sck,
hio_iolen_t wrlen,
void* wrctx,
const hio_skad_t* dstaddr
);
HIO_EXPORT void hio_svc_htts_client_default_on_disconnect (
hio_dev_sck_t* sck
);
/* Release the client socket. Pass a non-zero 'rcdown' to drop the reference /* Release the client socket. Pass a non-zero 'rcdown' to drop the reference
* the binding took; pass 0 when the caller is already inside the task's own * the binding took; pass 0 when the caller is already inside the task's own
* destruction path. */ * destruction path. */
-27
View File
@@ -258,7 +258,6 @@ typedef void (*hio_dev_sck_on_raw_accept_t) (
); );
typedef struct hio_dev_sck_evcb_t hio_dev_sck_evcb_t; typedef struct hio_dev_sck_evcb_t hio_dev_sck_evcb_t;
typedef struct hio_dev_sck_evcb_link_t hio_dev_sck_evcb_link_t;
struct hio_dev_sck_evcb_t struct hio_dev_sck_evcb_t
{ {
@@ -267,12 +266,6 @@ struct hio_dev_sck_evcb_t
hio_dev_sck_on_disconnect_t on_disconnect; hio_dev_sck_on_disconnect_t on_disconnect;
}; };
struct hio_dev_sck_evcb_link_t
{
hio_dev_sck_evcb_t saved;
void* ctx;
hio_dev_sck_evcb_link_t* prev;
};
enum hio_dev_sck_type_t enum hio_dev_sck_type_t
{ {
@@ -412,7 +405,6 @@ struct hio_dev_sck_t
/* original destination address */ /* original destination address */
hio_skad_t orgdstaddr; hio_skad_t orgdstaddr;
hio_dev_sck_evcb_link_t* evcb_top;
hio_dev_sck_on_write_t on_write; hio_dev_sck_on_write_t on_write;
hio_dev_sck_on_read_t on_read; hio_dev_sck_on_read_t on_read;
@@ -537,25 +529,6 @@ HIO_EXPORT int hio_dev_sck_timedwritev (
const hio_skad_t* dstaddr const hio_skad_t* dstaddr
); );
HIO_EXPORT void hio_dev_sck_pushevcb (
hio_dev_sck_t* dev,
hio_dev_sck_evcb_link_t* link,
const hio_dev_sck_evcb_t* evcb,
void* ctx
);
HIO_EXPORT hio_dev_sck_evcb_link_t* hio_dev_sck_popevcb (
hio_dev_sck_t* dev
);
HIO_EXPORT void* hio_dev_sck_getevcbctx (
hio_dev_sck_t* dev
);
HIO_EXPORT hio_dev_sck_evcb_t* hio_dev_sck_getparentevcb (
hio_dev_sck_t* dev
);
#if defined(HIO_HAVE_INLINE) #if defined(HIO_HAVE_INLINE)
static HIO_INLINE void hio_dev_sck_kill (hio_dev_sck_t* sck) static HIO_INLINE void hio_dev_sck_kill (hio_dev_sck_t* sck)
+18 -50
View File
@@ -82,7 +82,7 @@ hio_t* hio_open (hio_mmgr_t* mmgr, hio_oow_t xtnsize, hio_cmgr_t* cmgr, hio_bitm
if (hio_init(hio, mmgr, cmgr, features, tmrcapa) <= -1) if (hio_init(hio, mmgr, cmgr, features, tmrcapa) <= -1)
{ {
if (errinfo) hio_geterrinf (hio, errinfo); if (errinfo) hio_geterrinf (hio, errinfo);
HIO_MMGR_FREE (mmgr, hio); HIO_MMGR_FREE(mmgr, hio);
hio = HIO_NULL; hio = HIO_NULL;
} }
else HIO_MEMSET(hio + 1, 0, xtnsize); else HIO_MEMSET(hio + 1, 0, xtnsize);
@@ -98,8 +98,8 @@ hio_t* hio_open (hio_mmgr_t* mmgr, hio_oow_t xtnsize, hio_cmgr_t* cmgr, hio_bitm
void hio_close (hio_t* hio) void hio_close (hio_t* hio)
{ {
hio_fini (hio); hio_fini(hio);
HIO_MMGR_FREE (hio->_mmgr, hio); HIO_MMGR_FREE(hio->_mmgr, hio);
} }
int hio_init (hio_t* hio, hio_mmgr_t* mmgr, hio_cmgr_t* cmgr, hio_bitmask_t features, hio_oow_t tmrcapa) int hio_init (hio_t* hio, hio_mmgr_t* mmgr, hio_cmgr_t* cmgr, hio_bitmask_t features, hio_oow_t tmrcapa)
@@ -141,13 +141,13 @@ int hio_init (hio_t* hio, hio_mmgr_t* mmgr, hio_cmgr_t* cmgr, hio_bitmask_t feat
HIO_CWQ_INIT (&hio->cwq); HIO_CWQ_INIT (&hio->cwq);
HIO_SVCL_INIT (&hio->actsvc); HIO_SVCL_INIT (&hio->actsvc);
hio_sys_gettime (hio, &hio->init_time); hio_sys_gettime(hio, &hio->init_time);
return 0; return 0;
oops: oops:
if (hio->tmr.jobs) hio_freemem(hio, hio->tmr.jobs); if (hio->tmr.jobs) hio_freemem(hio, hio->tmr.jobs);
if (sys_inited) hio_sys_fini (hio); if (sys_inited) hio_sys_fini(hio);
if (hio->log.ptr) hio_freemem(hio, hio->log.ptr); if (hio->log.ptr) hio_freemem(hio, hio->log.ptr);
hio->log.capa = 0; hio->log.capa = 0;
@@ -260,7 +260,7 @@ void hio_fini (hio_t* hio)
/* clear unneeded cfmbs insistently - a misbehaving checker will make this cleaning step loop forever*/ /* clear unneeded cfmbs insistently - a misbehaving checker will make this cleaning step loop forever*/
while (!HIO_CFMBL_IS_EMPTY(&hio->cfmb)) clear_unneeded_cfmbs (hio); while (!HIO_CFMBL_IS_EMPTY(&hio->cfmb)) clear_unneeded_cfmbs (hio);
hio_sys_fini (hio); /* finalize the system dependent data */ hio_sys_fini(hio); /* finalize the system dependent data */
if (hio->log.ptr) if (hio->log.ptr)
{ {
@@ -731,8 +731,8 @@ static HIO_INLINE void handle_event (hio_t* hio, hio_dev_t* dev, int events, int
HIO_MEMSET(&tmrjob, 0, HIO_SIZEOF(tmrjob)); HIO_MEMSET(&tmrjob, 0, HIO_SIZEOF(tmrjob));
tmrjob.ctx = dev; tmrjob.ctx = dev;
hio_gettime (hio, &tmrjob.when); hio_gettime(hio, &tmrjob.when);
HIO_ADD_NTIME (&tmrjob.when, &tmrjob.when, &dev->rtmout); HIO_ADD_NTIME(&tmrjob.when, &tmrjob.when, &dev->rtmout);
tmrjob.handler = on_read_timeout; tmrjob.handler = on_read_timeout;
tmrjob.idxptr = &dev->rtmridx; tmrjob.idxptr = &dev->rtmridx;
@@ -1029,13 +1029,9 @@ hio_dev_t* hio_dev_make (hio_t* hio, hio_oow_t dev_size, hio_dev_mth_t* dev_mth,
dev->dev_cap = HIO_DEV_CAP_IN | HIO_DEV_CAP_OUT; dev->dev_cap = HIO_DEV_CAP_IN | HIO_DEV_CAP_OUT;
dev->dev_mth = dev_mth; dev->dev_mth = dev_mth;
dev->dev_evcb_base.evcb = dev_evcb;
dev->dev_evcb_base.ctx = HIO_NULL;
dev->dev_evcb_base.prev = HIO_NULL;
dev->dev_evcb = dev_evcb; dev->dev_evcb = dev_evcb;
dev->dev_evcb_top = &dev->dev_evcb_base;
HIO_INIT_NTIME (&dev->rtmout, 0, 0); HIO_INIT_NTIME(&dev->rtmout, 0, 0);
dev->rtmridx = HIO_TMRIDX_INVALID; dev->rtmridx = HIO_TMRIDX_INVALID;
HIO_WQ_INIT (&dev->wq); HIO_WQ_INIT (&dev->wq);
dev->cw_count = 0; dev->cw_count = 0;
@@ -1167,12 +1163,12 @@ static int schedule_kill_zombie_job (hio_dev_t* dev)
hio_tmrjob_t kill_zombie_job; hio_tmrjob_t kill_zombie_job;
hio_ntime_t tmout; hio_ntime_t tmout;
HIO_INIT_NTIME (&tmout, 3, 0); /* TODO: take it from configuration */ HIO_INIT_NTIME(&tmout, 3, 0); /* TODO: take it from configuration */
HIO_MEMSET(&kill_zombie_job, 0, HIO_SIZEOF(kill_zombie_job)); HIO_MEMSET(&kill_zombie_job, 0, HIO_SIZEOF(kill_zombie_job));
kill_zombie_job.ctx = dev; kill_zombie_job.ctx = dev;
hio_gettime (hio, &kill_zombie_job.when); hio_gettime(hio, &kill_zombie_job.when);
HIO_ADD_NTIME (&kill_zombie_job.when, &kill_zombie_job.when, &tmout); HIO_ADD_NTIME(&kill_zombie_job.when, &kill_zombie_job.when, &tmout);
kill_zombie_job.handler = kill_zombie_job_handler; kill_zombie_job.handler = kill_zombie_job_handler;
/*kill_zombie_job.idxptr = &rdev->tmridx_kill_zombie;*/ /*kill_zombie_job.idxptr = &rdev->tmridx_kill_zombie;*/
@@ -1453,8 +1449,8 @@ update_timer:
HIO_MEMSET(&tmrjob, 0, HIO_SIZEOF(tmrjob)); HIO_MEMSET(&tmrjob, 0, HIO_SIZEOF(tmrjob));
tmrjob.ctx = dev; tmrjob.ctx = dev;
hio_gettime (hio, &tmrjob.when); hio_gettime(hio, &tmrjob.when);
HIO_ADD_NTIME (&tmrjob.when, &tmrjob.when, tmout); HIO_ADD_NTIME(&tmrjob.when, &tmrjob.when, tmout);
tmrjob.handler = on_read_timeout; tmrjob.handler = on_read_timeout;
tmrjob.idxptr = &dev->rtmridx; tmrjob.idxptr = &dev->rtmridx;
@@ -1594,8 +1590,8 @@ static HIO_INLINE int __enqueue_pending_write (hio_dev_t* dev, hio_iolen_t olen,
HIO_MEMSET(&tmrjob, 0, HIO_SIZEOF(tmrjob)); HIO_MEMSET(&tmrjob, 0, HIO_SIZEOF(tmrjob));
tmrjob.ctx = q; tmrjob.ctx = q;
hio_gettime (hio, &tmrjob.when); hio_gettime(hio, &tmrjob.when);
HIO_ADD_NTIME (&tmrjob.when, &tmrjob.when, tmout); HIO_ADD_NTIME(&tmrjob.when, &tmrjob.when, tmout);
tmrjob.handler = on_write_timeout; tmrjob.handler = on_write_timeout;
tmrjob.idxptr = &q->tmridx; tmrjob.idxptr = &q->tmridx;
@@ -1668,8 +1664,8 @@ static HIO_INLINE int __enqueue_pending_sendfile (hio_dev_t* dev, hio_iolen_t ol
HIO_MEMSET(&tmrjob, 0, HIO_SIZEOF(tmrjob)); HIO_MEMSET(&tmrjob, 0, HIO_SIZEOF(tmrjob));
tmrjob.ctx = q; tmrjob.ctx = q;
hio_gettime (hio, &tmrjob.when); hio_gettime(hio, &tmrjob.when);
HIO_ADD_NTIME (&tmrjob.when, &tmrjob.when, tmout); HIO_ADD_NTIME(&tmrjob.when, &tmrjob.when, tmout);
tmrjob.handler = on_write_timeout; tmrjob.handler = on_write_timeout;
tmrjob.idxptr = &q->tmridx; tmrjob.idxptr = &q->tmridx;
@@ -2017,34 +2013,6 @@ int hio_dev_timedsendfile (hio_dev_t* dev, hio_syshnd_t in_fd, hio_foff_t foff,
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
void hio_dev_pushevcb (hio_dev_t* dev, hio_dev_evcb_link_t* link, hio_dev_evcb_t *evcb, void* ctx)
{
link->evcb = evcb;
link->ctx = ctx;
link->prev = dev->dev_evcb_top;
dev->dev_evcb_top = link;
dev->dev_evcb = evcb; /* cached */
}
hio_dev_evcb_link_t* hio_dev_popevcb (hio_dev_t* dev)
{
hio_dev_evcb_link_t* link;
link = dev->dev_evcb_top;
if (!link->prev) return HIO_NULL; /* the base cannot be popped off */
dev->dev_evcb_top = link->prev;
dev->dev_evcb = link->prev->evcb;
link->prev = HIO_NULL; /* clear the stale pointer */
return link;
}
void * hio_dev_getevcbctx (hio_dev_t* dev)
{
return dev->dev_evcb_top->ctx;
}
/* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
void hio_gettime (hio_t* hio, hio_ntime_t* now) void hio_gettime (hio_t* hio, hio_ntime_t* now)
+2 -25
View File
@@ -58,7 +58,6 @@ typedef struct hio_t hio_t;
typedef struct hio_dev_t hio_dev_t; typedef struct hio_dev_t hio_dev_t;
typedef struct hio_dev_mth_t hio_dev_mth_t; typedef struct hio_dev_mth_t hio_dev_mth_t;
typedef struct hio_dev_evcb_t hio_dev_evcb_t; typedef struct hio_dev_evcb_t hio_dev_evcb_t;
typedef struct hio_dev_evcb_link_t hio_dev_evcb_link_t;
typedef struct hio_svc_t hio_svc_t; typedef struct hio_svc_t hio_svc_t;
typedef struct hio_q_t hio_q_t; typedef struct hio_q_t hio_q_t;
@@ -264,13 +263,6 @@ struct hio_dev_evcb_t
int (*on_write) (hio_dev_t* dev, hio_iolen_t wrlen, void* wrctx, const hio_devaddr_t* dstaddr); int (*on_write) (hio_dev_t* dev, hio_iolen_t wrlen, void* wrctx, const hio_devaddr_t* dstaddr);
}; };
struct hio_dev_evcb_link_t
{
hio_dev_evcb_t* evcb;
void* ctx;
hio_dev_evcb_link_t* prev;
};
/** /**
* The #hio_q_t type is a basic structure that holds two pointers to the previous * The #hio_q_t type is a basic structure that holds two pointers to the previous
* item and the next to form a circular doubly linked list to used as a queue. * item and the next to form a circular doubly linked list to used as a queue.
@@ -385,9 +377,7 @@ struct hio_wq_t
hio_oow_t dev_size; \ hio_oow_t dev_size; \
hio_bitmask_t dev_cap; \ hio_bitmask_t dev_cap; \
hio_dev_mth_t* dev_mth; \ hio_dev_mth_t* dev_mth; \
hio_dev_evcb_t* dev_evcb; /* cached for faster access. must be equal to dev_evcb_top->evcb */ \ hio_dev_evcb_t* dev_evcb; \
hio_dev_evcb_link_t* dev_evcb_top; /* top evcb pointer */ \
hio_dev_evcb_link_t dev_evcb_base; /* base space to hold the actual evcb data */ \
hio_ntime_t rtmout; \ hio_ntime_t rtmout; \
hio_tmridx_t rtmridx; \ hio_tmridx_t rtmridx; \
hio_wq_t wq; \ hio_wq_t wq; \
@@ -1043,6 +1033,7 @@ HIO_EXPORT int hio_dev_timedread (
const hio_ntime_t* tmout const hio_ntime_t* tmout
); );
/** /**
* The hio_dev_write() function posts a writing request. * The hio_dev_write() function posts a writing request.
* It attempts to write data immediately if there is no pending requests. * It attempts to write data immediately if there is no pending requests.
@@ -1104,20 +1095,6 @@ HIO_EXPORT int hio_dev_timedsendfile (
void* wrctx void* wrctx
); );
HIO_EXPORT void hio_dev_pushevcb (
hio_dev_t* dev,
hio_dev_evcb_link_t* link,
hio_dev_evcb_t* evcb,
void* ctx
);
HIO_EXPORT hio_dev_evcb_link_t* hio_dev_popevcb (
hio_dev_t* dev
);
HIO_EXPORT void * hio_dev_getevcbctx (
hio_dev_t* dev
);
/* ========================================================================= /* =========================================================================
* SERVICE * SERVICE
+2 -2
View File
@@ -272,7 +272,7 @@ hio_htb_t* hio_htb_open (hio_t* hio, hio_oow_t xtnsize, hio_oow_t capa, int fact
void hio_htb_close (hio_htb_t* htb) void hio_htb_close (hio_htb_t* htb)
{ {
hio_htb_fini (htb); hio_htb_fini(htb);
hio_freemem(htb->hio, htb); hio_freemem(htb->hio, htb);
} }
@@ -318,7 +318,7 @@ int hio_htb_init (hio_htb_t* htb, hio_t* hio, hio_oow_t capa, int factor, int ks
void hio_htb_fini (hio_htb_t* htb) void hio_htb_fini (hio_htb_t* htb)
{ {
hio_htb_clear (htb); hio_htb_clear(htb);
hio_freemem(htb->hio, htb->bucket); hio_freemem(htb->hio, htb->bucket);
} }
+7 -7
View File
@@ -164,10 +164,10 @@ int hio_htrd_init (hio_htrd_t* htrd, hio_t* hio)
if (hio_htre_init(&htrd->re, hio) <= -1) if (hio_htre_init(&htrd->re, hio) <= -1)
{ {
hio_becs_fini (&htrd->fed.b.tra); hio_becs_fini(&htrd->fed.b.tra);
hio_becs_fini (&htrd->fed.b.raw); hio_becs_fini(&htrd->fed.b.raw);
#if 0 #if 0
hio_becs_fini (&htrd->tmp.qparam); hio_becs_fini(&htrd->tmp.qparam);
#endif #endif
return -1; return -1;
} }
@@ -178,12 +178,12 @@ int hio_htrd_init (hio_htrd_t* htrd, hio_t* hio)
void hio_htrd_fini (hio_htrd_t* htrd) void hio_htrd_fini (hio_htrd_t* htrd)
{ {
hio_htre_fini (&htrd->re); hio_htre_fini(&htrd->re);
hio_becs_fini (&htrd->fed.b.tra); hio_becs_fini(&htrd->fed.b.tra);
hio_becs_fini (&htrd->fed.b.raw); hio_becs_fini(&htrd->fed.b.raw);
#if 0 #if 0
hio_becs_fini (&htrd->tmp.qparam); hio_becs_fini(&htrd->tmp.qparam);
#endif #endif
} }
+9 -9
View File
@@ -78,11 +78,11 @@ int hio_htre_init (hio_htre_t* re, hio_t* hio)
void hio_htre_fini (hio_htre_t* re) void hio_htre_fini (hio_htre_t* re)
{ {
#if 0 #if 0
hio_becs_fini (&re->iniline); hio_becs_fini(&re->iniline);
#endif #endif
hio_becs_fini (&re->content); hio_becs_fini(&re->content);
hio_htb_fini (&re->trailers); hio_htb_fini(&re->trailers);
hio_htb_fini (&re->hdrtab); hio_htb_fini(&re->hdrtab);
if (re->orgqpath.buf) if (re->orgqpath.buf)
{ {
@@ -115,12 +115,12 @@ void hio_htre_clear (hio_htre_t* re)
HIO_MEMSET(&re->version, 0, HIO_SIZEOF(re->version)); HIO_MEMSET(&re->version, 0, HIO_SIZEOF(re->version));
HIO_MEMSET(&re->attr, 0, HIO_SIZEOF(re->attr)); HIO_MEMSET(&re->attr, 0, HIO_SIZEOF(re->attr));
hio_htb_clear (&re->hdrtab); hio_htb_clear(&re->hdrtab);
hio_htb_clear (&re->trailers); hio_htb_clear(&re->trailers);
hio_becs_clear (&re->content); hio_becs_clear(&re->content);
#if 0 #if 0
hio_becs_clear (&re->iniline); hio_becs_clear(&re->iniline);
#endif #endif
} }
@@ -241,7 +241,7 @@ void hio_htre_discardcontent (hio_htre_t* re)
* designed to serve a certain usage pattern not including * designed to serve a certain usage pattern not including
* weird combinations. * weird combinations.
*/ */
hio_becs_clear (&re->content); hio_becs_clear(&re->content);
if (re->concb) if (re->concb)
{ {
/* indicate end of content */ /* indicate end of content */
+10 -6
View File
@@ -483,8 +483,14 @@ static int cgi_client_htrd_poke (hio_htrd_t* htrd, hio_htre_t* req)
/* client request got completed */ /* client request got completed */
hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd); hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd);
hio_dev_sck_t* sck = htrdxtn->sck; hio_dev_sck_t* sck = htrdxtn->sck;
#if 0
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck); hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
cgi_t* cgi = (cgi_t*)cli->task; cgi_t* cgi = (cgi_t*)cli->task;
#else
/* this one is one call only. it must return the same value as the above two lines */
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
cgi_t* cgi = (cgi_t*)cli->task;
#endif
/* indicate EOF to the client peer */ /* indicate EOF to the client peer */
if (cgi_write_to_peer(cgi, HIO_NULL, 0) <= -1) return -1; if (cgi_write_to_peer(cgi, HIO_NULL, 0) <= -1) return -1;
@@ -542,7 +548,7 @@ static void cgi_client_on_disconnect (hio_dev_sck_t* sck)
/* call the parent handler*/ /* call the parent handler*/
/*if (fcgi->client_org_on_disconnect) fcgi->client_org_on_disconnect (sck);*/ /*if (fcgi->client_org_on_disconnect) fcgi->client_org_on_disconnect (sck);*/
if (sck->on_disconnect) sck->on_disconnect (sck); /* restored to the orginal parent handler in unbind_task_from_client() */ hio_svc_htts_client_default_on_disconnect (sck); /* restored to the orginal parent handler in unbind_task_from_client() */
/* if the client side is closed, the data from the child process is not read and the write() of the child process call may block. /* if the client side is closed, the data from the child process is not read and the write() of the child process call may block.
* just close the input side of the pipe to the child to prevense this situation */ * just close the input side of the pipe to the child to prevense this situation */
@@ -558,7 +564,6 @@ static void cgi_client_on_disconnect (hio_dev_sck_t* sck)
static int cgi_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t len, const hio_skad_t* srcaddr) static int cgi_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t len, const hio_skad_t* srcaddr)
{ {
hio_dev_sck_evcb_t* parent = hio_dev_sck_getparentevcb(sck);
hio_t* hio = sck->hio; hio_t* hio = sck->hio;
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck); hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
cgi_t* cgi = (cgi_t*)cli->task; cgi_t* cgi = (cgi_t*)cli->task;
@@ -566,7 +571,7 @@ static int cgi_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t
HIO_ASSERT(hio, sck == cli->sck); HIO_ASSERT(hio, sck == cli->sck);
n = parent && parent->on_read? parent->on_read(sck, buf, len, srcaddr): 0; n = hio_svc_htts_client_default_on_read(sck, buf, len, srcaddr);
if (len <= -1) if (len <= -1)
{ {
@@ -599,13 +604,12 @@ oops:
static int cgi_client_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx, const hio_skad_t* dstaddr) static int cgi_client_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx, const hio_skad_t* dstaddr)
{ {
hio_dev_sck_evcb_t* parent = hio_dev_sck_getparentevcb(sck);
hio_t* hio = sck->hio; hio_t* hio = sck->hio;
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck); hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
cgi_t* cgi = (cgi_t*)cli->task; cgi_t* cgi = (cgi_t*)cli->task;
int n; int n;
n = parent && parent->on_write? parent->on_write(sck, wrlen, wrctx, dstaddr): 0; n = hio_svc_htts_client_default_on_write(sck, wrlen, wrctx, dstaddr);
if (wrlen == 0) if (wrlen == 0)
{ {
@@ -659,7 +663,7 @@ static int peer_capture_request_header (hio_htre_t* req, const hio_bch_t* key, c
hio_oow_t val_offset; hio_oow_t val_offset;
hio_bch_t* ptr; hio_bch_t* ptr;
hio_becs_clear (dbuf); hio_becs_clear(dbuf);
if (hio_becs_cpy(dbuf, "HTTP_") == (hio_oow_t)-1 || if (hio_becs_cpy(dbuf, "HTTP_") == (hio_oow_t)-1 ||
hio_becs_cat(dbuf, key) == (hio_oow_t)-1 || hio_becs_cat(dbuf, key) == (hio_oow_t)-1 ||
hio_becs_ccat(dbuf, '\0') == (hio_oow_t)-1) return -1; hio_becs_ccat(dbuf, '\0') == (hio_oow_t)-1) return -1;
+28 -13
View File
@@ -383,7 +383,7 @@ static void fcgi_client_on_disconnect (hio_dev_sck_t* sck)
/* call the parent handler*/ /* call the parent handler*/
/*if (fcgi->client_org_on_disconnect) fcgi->client_org_on_disconnect (sck);*/ /*if (fcgi->client_org_on_disconnect) fcgi->client_org_on_disconnect (sck);*/
if (sck->on_disconnect) sck->on_disconnect (sck); /* restored to the orginal parent handelr in unbind_task_from_client() */ hio_svc_htts_client_default_on_disconnect (sck); /* restored to the orginal parent handelr in unbind_task_from_client() */
HIO_SVC_HTTS_TASK_RCDOWN ((hio_svc_htts_task_t*)fcgi); HIO_SVC_HTTS_TASK_RCDOWN ((hio_svc_htts_task_t*)fcgi);
} }
@@ -394,7 +394,6 @@ static void fcgi_client_on_disconnect (hio_dev_sck_t* sck)
static int fcgi_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t len, const hio_skad_t* srcaddr) static int fcgi_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t len, const hio_skad_t* srcaddr)
{ {
hio_dev_sck_evcb_t* parent = hio_dev_sck_getparentevcb(sck);
hio_t* hio HIO_UNUSED = sck->hio; hio_t* hio HIO_UNUSED = sck->hio;
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck); hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
fcgi_t* fcgi = (fcgi_t*)cli->task; fcgi_t* fcgi = (fcgi_t*)cli->task;
@@ -402,7 +401,7 @@ static int fcgi_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t
HIO_ASSERT(hio, sck == cli->sck); HIO_ASSERT(hio, sck == cli->sck);
n = parent && parent->on_read? parent->on_read(sck, buf, len, srcaddr): 0; n = hio_svc_htts_client_default_on_read(sck, buf, len, srcaddr);
if (len <= -1) if (len <= -1)
{ {
@@ -436,13 +435,12 @@ oops:
static int fcgi_client_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx, const hio_skad_t* dstaddr) static int fcgi_client_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx, const hio_skad_t* dstaddr)
{ {
hio_dev_sck_evcb_t* parent = hio_dev_sck_getparentevcb(sck);
hio_t* hio HIO_UNUSED = sck->hio; hio_t* hio HIO_UNUSED = sck->hio;
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck); hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
fcgi_t* fcgi = (fcgi_t*)cli->task; fcgi_t* fcgi = (fcgi_t*)cli->task;
int n; int n;
n = parent && parent->on_write? parent->on_write(sck, wrlen, wrctx, dstaddr): 0; n = hio_svc_htts_client_default_on_write(sck, wrlen, wrctx, dstaddr);
if (wrlen == 0) if (wrlen == 0)
{ {
@@ -485,7 +483,7 @@ static int peer_capture_request_header (hio_htre_t* req, const hio_bch_t* key, c
if (hio_comp_bcstr(key, "Content-Type", 1) == 0) if (hio_comp_bcstr(key, "Content-Type", 1) == 0)
{ {
/* don't prefix CONTENT_TYPE with HTTP_ */ /* don't prefix CONTENT_TYPE with HTTP_ */
hio_becs_clear (htts->becbuf); hio_becs_clear(htts->becbuf);
} }
else else
{ {
@@ -599,8 +597,8 @@ static int bind_task_to_peer (fcgi_t* fcgi, const hio_skad_t* fcgis_addr)
htrd = hio_htrd_open(fcgi->htts->hio, HIO_SIZEOF(*pxtn)); htrd = hio_htrd_open(fcgi->htts->hio, HIO_SIZEOF(*pxtn));
if (HIO_UNLIKELY(!htrd)) return -1; if (HIO_UNLIKELY(!htrd)) return -1;
hio_htrd_setoption (htrd, HIO_HTRD_SKIP_INITIAL_LINE | HIO_HTRD_RESPONSE); hio_htrd_setoption(htrd, HIO_HTRD_SKIP_INITIAL_LINE | HIO_HTRD_RESPONSE);
hio_htrd_setrecbs (htrd, &peer_htrd_recbs); hio_htrd_setrecbs(htrd, &peer_htrd_recbs);
fcgi->peer = hio_svc_fcgic_tie(fcgi->htts->fcgic, fcgis_addr, fcgi_peer_on_read, fcgi_peer_on_write, fcgi_peer_on_untie, fcgi); fcgi->peer = hio_svc_fcgic_tie(fcgi->htts->fcgic, fcgis_addr, fcgi_peer_on_read, fcgi_peer_on_write, fcgi_peer_on_untie, fcgi);
if (HIO_UNLIKELY(!fcgi->peer)) if (HIO_UNLIKELY(!fcgi->peer))
@@ -666,7 +664,7 @@ static int setup_for_content_length(fcgi_t* fcgi, hio_htre_t* req)
/* change the callbacks to subscribe to contents to be uploaded */ /* change the callbacks to subscribe to contents to be uploaded */
fcgi->task_client_htrd_org_recbs = *hio_htrd_getrecbs(fcgi->task_client->htrd); fcgi->task_client_htrd_org_recbs = *hio_htrd_getrecbs(fcgi->task_client->htrd);
fcgi_client_htrd_recbs.peek = fcgi->task_client_htrd_org_recbs.peek; fcgi_client_htrd_recbs.peek = fcgi->task_client_htrd_org_recbs.peek;
hio_htrd_setrecbs (fcgi->task_client->htrd, &fcgi_client_htrd_recbs); hio_htrd_setrecbs(fcgi->task_client->htrd, &fcgi_client_htrd_recbs);
fcgi->task_client_htrd_recbs_changed = 1; fcgi->task_client_htrd_recbs_changed = 1;
} }
else else
@@ -674,7 +672,7 @@ static int setup_for_content_length(fcgi_t* fcgi, hio_htre_t* req)
/* no content to be uploaded from the client */ /* no content to be uploaded from the client */
/* indicate end of stdin to the peer and disable input wathching from the client */ /* indicate end of stdin to the peer and disable input wathching from the client */
if (fcgi_write_stdin_to_peer(fcgi, HIO_NULL, 0) <= -1) return -1; if (fcgi_write_stdin_to_peer(fcgi, HIO_NULL, 0) <= -1) return -1;
fcgi_mark_over (fcgi, FCGI_OVER_READ_FROM_CLIENT | FCGI_OVER_WRITE_TO_PEER); fcgi_mark_over(fcgi, FCGI_OVER_READ_FROM_CLIENT | FCGI_OVER_WRITE_TO_PEER);
} }
return 0; return 0;
@@ -717,10 +715,20 @@ int hio_svc_htts_dofcgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t*
bound_to_peer = 1; bound_to_peer = 1;
if (hio_svc_htts_task_handleexpect100((hio_svc_htts_task_t*)fcgi, 0) <= -1) goto oops; if (hio_svc_htts_task_handleexpect100((hio_svc_htts_task_t*)fcgi, 0) <= -1) goto oops;
if (setup_for_content_length(fcgi, req) <= -1) goto oops;
/* TODO: store current input watching state and use it when destroying the fcgi data */ /* [NOTE] the records must reach the peer in the order the FastCGI
if (hio_dev_sck_read(csck, !(fcgi->over & FCGI_OVER_READ_FROM_CLIENT)) <= -1) goto oops; * specification lays down: FCGI_BEGIN_REQUEST, then the FCGI_PARAMS
* stream, then the FCGI_STDIN stream. setup_for_content_length() ends
* the stdin stream for a request that carries no body, so it has to
* run after the params - not before, or the peer sees the end of a
* request that has not been begun.
*
* if a call like this is made to this funciton:
* fcgi_write_stdin_to_peer(fcgi, HIO_NULL, 0)
* setup_for_content_length() marks the end of stream.
* if i call setup_for_content_length() after beginrequest(),
* it always sends FCGI_BEGIN_REQUEST even for a body-less request.
*/
/* send FCGI_BEGIN_REQUEST */ /* send FCGI_BEGIN_REQUEST */
if (hio_svc_fcgic_beginrequest(fcgi->peer) <= -1) goto oops; if (hio_svc_fcgic_beginrequest(fcgi->peer) <= -1) goto oops;
@@ -728,6 +736,13 @@ int hio_svc_htts_dofcgi (hio_svc_htts_t* htts, hio_dev_sck_t* csck, hio_htre_t*
if (write_params(fcgi, csck, req, docroot, script) <= -1) goto oops; if (write_params(fcgi, csck, req, docroot, script) <= -1) goto oops;
if (hio_svc_fcgic_writeparam(fcgi->peer, HIO_NULL, 0, HIO_NULL, 0) <= -1) goto oops; /* end of params */ if (hio_svc_fcgic_writeparam(fcgi->peer, HIO_NULL, 0, HIO_NULL, 0) <= -1) goto oops; /* end of params */
/* this may end the stdin stream, so it must follow the params above.
* it also settles the 'over' bits that the read arming below reads. */
if (setup_for_content_length(fcgi, req) <= -1) goto oops;
/* TODO: store current input watching state and use it when destroying the fcgi data */
if (hio_dev_sck_read(csck, !(fcgi->over & FCGI_OVER_READ_FROM_CLIENT)) <= -1) goto oops;
HIO_SVC_HTTS_TASKL_APPEND_TASK (&htts->task, (hio_svc_htts_task_t*)fcgi); HIO_SVC_HTTS_TASKL_APPEND_TASK (&htts->task, (hio_svc_htts_task_t*)fcgi);
HIO_SVC_HTTS_TASK_RCDOWN ((hio_svc_htts_task_t*)fcgi); HIO_SVC_HTTS_TASK_RCDOWN ((hio_svc_htts_task_t*)fcgi);
+9 -8
View File
@@ -219,7 +219,7 @@ static void file_client_on_disconnect (hio_dev_sck_t* sck)
{ {
hio_t* hio = sck->hio; hio_t* hio = sck->hio;
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck); hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
file_t* file = (file_t*)hio_dev_sck_getevcbctx(sck); file_t* file = (file_t*)cli->task;
hio_svc_htts_t* htts = file->htts; hio_svc_htts_t* htts = file->htts;
HIO_ASSERT(hio, sck == cli->sck); HIO_ASSERT(hio, sck == cli->sck);
@@ -242,7 +242,7 @@ static void file_client_on_disconnect (hio_dev_sck_t* sck)
/* call the parent handler. unbind_task_from_client() above popped /* call the parent handler. unbind_task_from_client() above popped
* this task's layer off, so sck->on_disconnect is the handler that * this task's layer off, so sck->on_disconnect is the handler that
* was displaced when the layer was pushed. */ * was displaced when the layer was pushed. */
if (sck->on_disconnect) sck->on_disconnect(sck); hio_svc_htts_client_default_on_disconnect (sck);
HIO_SVC_HTTS_TASK_RCDOWN((hio_svc_htts_task_t*)file); HIO_SVC_HTTS_TASK_RCDOWN((hio_svc_htts_task_t*)file);
} }
@@ -255,7 +255,7 @@ static int file_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t
{ {
hio_t* hio = sck->hio; hio_t* hio = sck->hio;
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck); hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
file_t* file = (file_t*)hio_dev_sck_getevcbctx(sck); file_t* file = (file_t*)cli->task;
HIO_ASSERT(hio, sck == cli->sck); HIO_ASSERT(hio, sck == cli->sck);
HIO_ASSERT(hio, sck == file->task_csck); HIO_ASSERT(hio, sck == file->task_csck);
@@ -312,11 +312,11 @@ oops:
static int file_client_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx, const hio_skad_t* dstaddr) static int file_client_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx, const hio_skad_t* dstaddr)
{ {
hio_t* hio = sck->hio; hio_t* hio = sck->hio;
file_t* file = (file_t*)hio_dev_sck_getevcbctx(sck); hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
hio_dev_sck_evcb_t* parent = hio_dev_sck_getparentevcb(sck); file_t* file = (file_t*)cli->task;
int n; int n;
n = parent && parent->on_write? parent->on_write(sck, wrlen, wrctx, dstaddr): 0; n = hio_svc_htts_client_default_on_write(sck, wrlen, wrctx, dstaddr);
if (wrlen == 0) if (wrlen == 0)
{ {
@@ -352,7 +352,8 @@ static int file_client_htrd_poke (hio_htrd_t* htrd, hio_htre_t* req)
/* client request got completed */ /* client request got completed */
hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd); hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd);
hio_dev_sck_t* sck = htrdxtn->sck; hio_dev_sck_t* sck = htrdxtn->sck;
file_t* file = (file_t*)hio_dev_sck_getevcbctx(sck); hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
file_t* file = (file_t*)cli->task;
/* indicate EOF to the client peer */ /* indicate EOF to the client peer */
if (file_write_to_peer(file, HIO_NULL, 0) <= -1) return -1; if (file_write_to_peer(file, HIO_NULL, 0) <= -1) return -1;
@@ -371,7 +372,7 @@ static int file_client_htrd_push_content (hio_htrd_t* htrd, hio_htre_t* req, con
hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd); hio_svc_htts_cli_htrd_xtn_t* htrdxtn = (hio_svc_htts_cli_htrd_xtn_t*)hio_htrd_getxtn(htrd);
hio_dev_sck_t* sck = htrdxtn->sck; hio_dev_sck_t* sck = htrdxtn->sck;
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck); hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
file_t* file = (file_t*)hio_dev_sck_getevcbctx(sck); file_t* file = (file_t*)cli->task;
HIO_ASSERT(sck->hio, cli->sck == sck); HIO_ASSERT(sck->hio, cli->sck == sck);
return file_write_to_peer(file, data, dlen); return file_write_to_peer(file, data, dlen);
+4 -6
View File
@@ -460,7 +460,7 @@ static void prxy_client_on_disconnect (hio_dev_sck_t* sck)
/* call the parent handler*/ /* call the parent handler*/
/*if (fprxy->client_org_on_disconnect) fprxy->client_org_on_disconnect (sck);*/ /*if (fprxy->client_org_on_disconnect) fprxy->client_org_on_disconnect (sck);*/
if (sck->on_disconnect) sck->on_disconnect (sck); /* restored to the orginal parent handler in unbind_task_from_client() */ hio_svc_htts_client_default_on_disconnect(sck); /* restored to the orginal parent handler in unbind_task_from_client() */
HIO_SVC_HTTS_TASK_RCDOWN ((hio_svc_htts_task_t*)prxy); HIO_SVC_HTTS_TASK_RCDOWN ((hio_svc_htts_task_t*)prxy);
} }
@@ -471,7 +471,6 @@ static void prxy_client_on_disconnect (hio_dev_sck_t* sck)
static int prxy_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t len, const hio_skad_t* srcaddr) static int prxy_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t len, const hio_skad_t* srcaddr)
{ {
hio_dev_sck_evcb_t* parent = hio_dev_sck_getparentevcb(sck);
hio_t* hio = sck->hio; hio_t* hio = sck->hio;
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck); hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
prxy_t* prxy = (prxy_t*)cli->task; prxy_t* prxy = (prxy_t*)cli->task;
@@ -479,7 +478,7 @@ static int prxy_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t
HIO_ASSERT(hio, sck == cli->sck); HIO_ASSERT(hio, sck == cli->sck);
n = parent && parent->on_read? parent->on_read(sck, buf, len, srcaddr): 0; n = hio_svc_htts_client_default_on_read(sck, buf, len, srcaddr);
if (len <= -1) if (len <= -1)
{ {
@@ -512,13 +511,12 @@ oops:
static int prxy_client_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx, const hio_skad_t* dstaddr) static int prxy_client_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx, const hio_skad_t* dstaddr)
{ {
hio_dev_sck_evcb_t* parent = hio_dev_sck_getparentevcb(sck);
hio_t* hio = sck->hio; hio_t* hio = sck->hio;
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck); hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
prxy_t* prxy = (prxy_t*)cli->task; prxy_t* prxy = (prxy_t*)cli->task;
int n; int n;
n = parent && parent->on_write? parent->on_write(sck, wrlen, wrctx, dstaddr): 0; n = hio_svc_htts_client_default_on_write(sck, wrlen, wrctx, dstaddr);
if (wrlen == 0) if (wrlen == 0)
{ {
@@ -572,7 +570,7 @@ static int peer_capture_request_header (hio_htre_t* req, const hio_bch_t* key, c
hio_oow_t val_offset; hio_oow_t val_offset;
hio_bch_t* ptr; hio_bch_t* ptr;
hio_becs_clear (dbuf); hio_becs_clear(dbuf);
if (hio_becs_cpy(dbuf, "HTTP_") == (hio_oow_t)-1 || if (hio_becs_cpy(dbuf, "HTTP_") == (hio_oow_t)-1 ||
hio_becs_cat(dbuf, key) == (hio_oow_t)-1 || hio_becs_cat(dbuf, key) == (hio_oow_t)-1 ||
hio_becs_ccat(dbuf, '\0') == (hio_oow_t)-1) return -1; hio_becs_ccat(dbuf, '\0') == (hio_oow_t)-1) return -1;
+43 -21
View File
@@ -324,6 +324,19 @@ static void listener_on_disconnect (hio_dev_sck_t* sck)
static int client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t len, const hio_skad_t* srcaddr) static int client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t len, const hio_skad_t* srcaddr)
{
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
/* a bound task services the client. it calls
* hio_svc_htts_client_default_on_read() itself if it also wants the
* handling below. */
if (cli->task && cli->task->task_evcb && cli->task->task_evcb->on_read)
return cli->task->task_evcb->on_read(sck, buf, len, srcaddr);
return hio_svc_htts_client_default_on_read(sck, buf, len, srcaddr);
}
int hio_svc_htts_client_default_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t len, const hio_skad_t* srcaddr)
{ {
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck); hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
hio_t* hio = sck->hio; hio_t* hio = sck->hio;
@@ -348,7 +361,7 @@ static int client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t len,
goto oops; goto oops;
} }
hio_gettime (hio, &cli->last_active); hio_gettime(hio, &cli->last_active);
if ((x = hio_htrd_feed(cli->htrd, buf, len, &rem)) <= -1) if ((x = hio_htrd_feed(cli->htrd, buf, len, &rem)) <= -1)
{ {
HIO_DEBUG3(hio, "HTTS(%p) - feed error onto client htrd %p(%d)\n", htts, sck, (int)sck->hnd); HIO_DEBUG3(hio, "HTTS(%p) - feed error onto client htrd %p(%d)\n", htts, sck, (int)sck->hnd);
@@ -381,6 +394,16 @@ oops:
} }
static int client_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx, const hio_skad_t* dstaddr) static int client_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx, const hio_skad_t* dstaddr)
{
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
if (cli->task && cli->task->task_evcb && cli->task->task_evcb->on_write)
return cli->task->task_evcb->on_write(sck, wrlen, wrctx, dstaddr);
return hio_svc_htts_client_default_on_write(sck, wrlen, wrctx, dstaddr);
}
int hio_svc_htts_client_default_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx, const hio_skad_t* dstaddr)
{ {
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck); hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
hio_t* hio = sck->hio; hio_t* hio = sck->hio;
@@ -420,6 +443,19 @@ static int client_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx,
} }
static void client_on_disconnect (hio_dev_sck_t* sck) static void client_on_disconnect (hio_dev_sck_t* sck)
{
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
if (cli->task && cli->task->task_evcb && cli->task->task_evcb->on_disconnect)
{
cli->task->task_evcb->on_disconnect (sck);
return;
}
hio_svc_htts_client_default_on_disconnect (sck);
}
void hio_svc_htts_client_default_on_disconnect (hio_dev_sck_t* sck)
{ {
hio_t* hio = sck->hio; hio_t* hio = sck->hio;
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck); hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
@@ -947,22 +983,12 @@ void hio_svc_htts_task_bindtoclient (hio_svc_htts_task_t* task, hio_dev_sck_t* c
/* task->task_client and task->task_csck are set in hio_svc_htts_task_make() */ /* task->task_client and task->task_csck are set in hio_svc_htts_task_make() */
/* layer this task's handlers over whatever the socket was using. the /* the socket keeps the service's handlers installed throughout. while
* displaced set is remembered in the link, and the task becomes the * this task is the client's current one, they route to this table. */
* layer context its handlers read back with hio_dev_sck_getevcbctx() */ task->task_evcb = evcb;
hio_dev_sck_pushevcb(csck, &task->task_client_evcb_link, evcb, task);
task->task_client_evcb_pushed = 1;
cli->task = task; cli->task = task;
HIO_SVC_HTTS_TASK_RCUP(task); HIO_SVC_HTTS_TASK_RCUP(task);
/* somehow the backpointer to the task is available via two means:
*
* - cli->task
* - hio_dev_sck_getevcbctx()
*
* the two above returns the same pointer.
*/
} }
void hio_svc_htts_task_unbindfromclient (hio_svc_htts_task_t* task, int rcdown) void hio_svc_htts_task_unbindfromclient (hio_svc_htts_task_t* task, int rcdown)
@@ -986,12 +1012,6 @@ void hio_svc_htts_task_unbindfromclient (hio_svc_htts_task_t* task, int rcdown)
task->task_client_htrd_recbs_changed = 0; task->task_client_htrd_recbs_changed = 0;
} }
if (task->task_client_evcb_pushed)
{
hio_dev_sck_popevcb(csck);
task->task_client_evcb_pushed = 0;
}
/* there is some ordering issue in using HIO_SVC_HTTS_TASK_UNREF() /* there is some ordering issue in using HIO_SVC_HTTS_TASK_UNREF()
* because it can destroy the task itself. so reset * because it can destroy the task itself. so reset
* task->task_client->task to null and call RCDOWN() later */ * task->task_client->task to null and call RCDOWN() later */
@@ -1370,7 +1390,9 @@ hio_bch_t* hio_svc_htts_dupmergepaths (hio_svc_htts_t* htts, const hio_bch_t* ba
ta[idx++] = base; ta[idx++] = base;
if (path[0] != '\0') if (path[0] != '\0')
{ {
if (base[hio_count_bcstr(base) - 1] != '/') ta[idx++] = "/"; /* [NOTE] guard the length. an empty base would index base[-1] */
hio_oow_t baselen = hio_count_bcstr(base);
if (baselen <= 0 || base[baselen - 1] != '/') ta[idx++] = "/";
ta[idx++] = path; ta[idx++] = path;
} }
ta[idx++] = HIO_NULL; ta[idx++] = HIO_NULL;
+3 -5
View File
@@ -473,7 +473,7 @@ static void thr_client_on_disconnect (hio_dev_sck_t* sck)
/* call the parent handler*/ /* call the parent handler*/
/*if (thr->client_org_on_disconnect) thr->client_org_on_disconnect (sck);*/ /*if (thr->client_org_on_disconnect) thr->client_org_on_disconnect (sck);*/
if (sck->on_disconnect) sck->on_disconnect (sck); /* restored to the orginal parent handler in unbind_task_from_client() */ hio_svc_htts_client_default_on_disconnect (sck); /* restored to the orginal parent handler in unbind_task_from_client() */
HIO_SVC_HTTS_TASK_RCDOWN ((hio_svc_htts_task_t*)thr); HIO_SVC_HTTS_TASK_RCDOWN ((hio_svc_htts_task_t*)thr);
} }
@@ -484,7 +484,6 @@ static void thr_client_on_disconnect (hio_dev_sck_t* sck)
static int thr_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t len, const hio_skad_t* srcaddr) static int thr_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t len, const hio_skad_t* srcaddr)
{ {
hio_dev_sck_evcb_t* parent = hio_dev_sck_getparentevcb(sck);
hio_t* hio = sck->hio; hio_t* hio = sck->hio;
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck); hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
thr_t* thr = (thr_t*)cli->task; thr_t* thr = (thr_t*)cli->task;
@@ -492,7 +491,7 @@ static int thr_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t
HIO_ASSERT(hio, sck == cli->sck); HIO_ASSERT(hio, sck == cli->sck);
n = parent && parent->on_read? parent->on_read(sck, buf, len, srcaddr): 0; n = hio_svc_htts_client_default_on_read(sck, buf, len, srcaddr);
if (len <= -1) if (len <= -1)
{ {
@@ -525,13 +524,12 @@ oops:
static int thr_client_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx, const hio_skad_t* dstaddr) static int thr_client_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx, const hio_skad_t* dstaddr)
{ {
hio_dev_sck_evcb_t* parent = hio_dev_sck_getparentevcb(sck);
hio_t* hio = sck->hio; hio_t* hio = sck->hio;
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck); hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
thr_t* thr = (thr_t*)cli->task; thr_t* thr = (thr_t*)cli->task;
int n; int n;
n = parent && parent->on_write? parent->on_write(sck, wrlen, wrctx, dstaddr): 0; n = hio_svc_htts_client_default_on_write(sck, wrlen, wrctx, dstaddr);
if (wrlen == 0) if (wrlen == 0)
{ {
+3 -5
View File
@@ -154,7 +154,7 @@ static void txt_client_on_disconnect (hio_dev_sck_t* sck)
/* call the parent handler*/ /* call the parent handler*/
/*if (txt->client_org_on_disconnect) txt->client_org_on_disconnect (sck);*/ /*if (txt->client_org_on_disconnect) txt->client_org_on_disconnect (sck);*/
if (sck->on_disconnect) sck->on_disconnect (sck); /* restored to the orginal parent handler in unbind_task_from_client() */ hio_svc_htts_client_default_on_disconnect (sck); /* restored to the orginal parent handler in unbind_task_from_client() */
HIO_SVC_HTTS_TASK_RCDOWN ((hio_svc_htts_task_t*)txt); HIO_SVC_HTTS_TASK_RCDOWN ((hio_svc_htts_task_t*)txt);
} }
@@ -162,7 +162,6 @@ static void txt_client_on_disconnect (hio_dev_sck_t* sck)
static int txt_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t len, const hio_skad_t* srcaddr) static int txt_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t len, const hio_skad_t* srcaddr)
{ {
hio_dev_sck_evcb_t* parent = hio_dev_sck_getparentevcb(sck);
hio_t* hio = sck->hio; hio_t* hio = sck->hio;
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck); hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
txt_t* txt = (txt_t*)cli->task; txt_t* txt = (txt_t*)cli->task;
@@ -170,7 +169,7 @@ static int txt_client_on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t
HIO_ASSERT(hio, sck == cli->sck); HIO_ASSERT(hio, sck == cli->sck);
n = parent && parent->on_read? parent->on_read(sck, buf, len, srcaddr): 0; n = hio_svc_htts_client_default_on_read(sck, buf, len, srcaddr);
if (len <= -1) if (len <= -1)
{ {
@@ -200,13 +199,12 @@ oops:
static int txt_client_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx, const hio_skad_t* dstaddr) static int txt_client_on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx, const hio_skad_t* dstaddr)
{ {
hio_dev_sck_evcb_t* parent = hio_dev_sck_getparentevcb(sck);
hio_t* hio = sck->hio; hio_t* hio = sck->hio;
hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck); hio_svc_htts_cli_t* cli = hio_dev_sck_getxtn(sck);
txt_t* txt = (txt_t*)cli->task; txt_t* txt = (txt_t*)cli->task;
int n; int n;
n = parent && parent->on_write? parent->on_write(sck, wrlen, wrctx, dstaddr): 0; n = hio_svc_htts_client_default_on_write(sck, wrlen, wrctx, dstaddr);
if (wrlen == 0) if (wrlen == 0)
{ {
+2 -2
View File
@@ -1,5 +1,5 @@
/* /*
Copyright (c) 2016-2018 Chung, Hyung-Hwan. All rights reserved. Copyright (c) 2016-2020 Chung, Hyung-Hwan. All rights reserved.
Redistribution and use in source and binary forms, with or without Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions modification, are permitted provided that the following conditions
@@ -1015,7 +1015,7 @@ hio_jsonwr_t* hio_jsonwr_open (hio_t* hio, hio_oow_t xtnsize, int flags)
void hio_jsonwr_close (hio_jsonwr_t* jsonwr) void hio_jsonwr_close (hio_jsonwr_t* jsonwr)
{ {
hio_jsonwr_fini (jsonwr); hio_jsonwr_fini(jsonwr);
hio_freemem(jsonwr->hio, jsonwr); hio_freemem(jsonwr->hio, jsonwr);
} }
+54 -54
View File
@@ -46,7 +46,7 @@
static void on_connect_timeout (hio_t* hio, const hio_ntime_t* now, hio_tmrjob_t* job) static void on_connect_timeout (hio_t* hio, const hio_ntime_t* now, hio_tmrjob_t* job)
{ {
hio_dev_mar_t* rdev = (hio_dev_mar_t*)job->ctx; hio_dev_mar_t* rdev = (hio_dev_mar_t*)job->ctx;
hio_dev_mar_halt (rdev); hio_dev_mar_halt(rdev);
} }
static int sched_connect_timeout (hio_dev_t* dev) static int sched_connect_timeout (hio_dev_t* dev)
@@ -59,8 +59,8 @@ static int sched_connect_timeout (hio_dev_t* dev)
{ {
HIO_MEMSET(&tmrjob, 0, HIO_SIZEOF(tmrjob)); HIO_MEMSET(&tmrjob, 0, HIO_SIZEOF(tmrjob));
tmrjob.ctx = rdev; tmrjob.ctx = rdev;
hio_gettime (hio, &tmrjob.when); hio_gettime(hio, &tmrjob.when);
HIO_ADD_NTIME (&tmrjob.when, &tmrjob.when, &rdev->tmout.c); HIO_ADD_NTIME(&tmrjob.when, &tmrjob.when, &rdev->tmout.c);
tmrjob.handler = on_connect_timeout; tmrjob.handler = on_connect_timeout;
tmrjob.idxptr = &rdev->ctmridx; tmrjob.idxptr = &rdev->ctmridx;
rdev->ctmridx = hio_instmrjob(hio, &tmrjob); rdev->ctmridx = hio_instmrjob(hio, &tmrjob);
@@ -81,7 +81,7 @@ static void desched_connect_timeout (hio_dev_t* dev)
if (rdev->ctmridx != HIO_TMRIDX_INVALID) if (rdev->ctmridx != HIO_TMRIDX_INVALID)
{ {
hio_deltmrjob (hio, rdev->ctmridx); hio_deltmrjob(hio, rdev->ctmridx);
HIO_ASSERT(hio, rdev->ctmridx == HIO_TMRIDX_INVALID); HIO_ASSERT(hio, rdev->ctmridx == HIO_TMRIDX_INVALID);
} }
} }
@@ -105,7 +105,7 @@ static int dev_mar_make (hio_dev_t* dev, void* ctx)
if (mysql_options(rdev->hnd, MYSQL_OPT_NONBLOCK, 0) != 0) if (mysql_options(rdev->hnd, MYSQL_OPT_NONBLOCK, 0) != 0)
{ {
hio_seterrbfmt(hio, HIO_ESYSERR, "%hs", mysql_error(rdev->hnd)); hio_seterrbfmt(hio, HIO_ESYSERR, "%hs", mysql_error(rdev->hnd));
mysql_close (rdev->hnd); mysql_close(rdev->hnd);
rdev->hnd = HIO_NULL; rdev->hnd = HIO_NULL;
return -1; return -1;
} }
@@ -155,11 +155,11 @@ static int dev_mar_kill (hio_dev_t* dev, int force)
hio_t* hio = dev->hio; hio_t* hio = dev->hio;
hio_dev_mar_t* rdev = (hio_dev_mar_t*)dev; hio_dev_mar_t* rdev = (hio_dev_mar_t*)dev;
desched_connect_timeout (dev); desched_connect_timeout(dev);
/* if rdev->connected is 0 at this point, /* if rdev->connected is 0 at this point,
* the underlying socket of this device is down */ * the underlying socket of this device is down */
if (HIO_LIKELY(rdev->on_disconnect)) rdev->on_disconnect (rdev); if (HIO_LIKELY(rdev->on_disconnect)) rdev->on_disconnect(rdev);
/* hack */ /* hack */
if (!rdev->broken) if (!rdev->broken)
@@ -174,19 +174,19 @@ static int dev_mar_kill (hio_dev_t* dev, int force)
*/ */
if (rdev->connected) if (rdev->connected)
{ {
shutdown (mysql_get_socket(rdev->hnd), SHUT_RDWR); shutdown(mysql_get_socket(rdev->hnd), SHUT_RDWR);
} }
} }
if (rdev->res) if (rdev->res)
{ {
mysql_free_result (rdev->res); mysql_free_result(rdev->res);
rdev->res = HIO_NULL; rdev->res = HIO_NULL;
} }
if (rdev->hnd) if (rdev->hnd)
{ {
mysql_close (rdev->hnd); mysql_close(rdev->hnd);
rdev->hnd = HIO_NULL; rdev->hnd = HIO_NULL;
} }
@@ -245,12 +245,12 @@ static void start_fetch_row (hio_dev_mar_t* rdev)
status = mysql_fetch_row_start(&row, rdev->res); status = mysql_fetch_row_start(&row, rdev->res);
HIO_DEV_MAR_SET_PROGRESS (rdev, HIO_DEV_MAR_ROW_FETCHING); HIO_DEV_MAR_SET_PROGRESS(rdev, HIO_DEV_MAR_ROW_FETCHING);
if (status) if (status)
{ {
/* row not fetched */ /* row not fetched */
rdev->row_fetched_deferred = 0; rdev->row_fetched_deferred = 0;
watch_mysql (rdev, status); watch_mysql(rdev, status);
} }
else else
{ {
@@ -258,7 +258,7 @@ static void start_fetch_row (hio_dev_mar_t* rdev)
rdev->row_fetched_deferred = 1; rdev->row_fetched_deferred = 1;
rdev->row_wstatus = status; rdev->row_wstatus = status;
rdev->row = row; rdev->row = row;
watch_mysql (rdev, MYSQL_WAIT_READ | MYSQL_WAIT_WRITE); watch_mysql(rdev, MYSQL_WAIT_READ | MYSQL_WAIT_WRITE);
} }
} }
@@ -289,9 +289,9 @@ static int dev_mar_ioctl (hio_dev_t* dev, int cmd, void* arg)
if (status) if (status)
{ {
/* not connected */ /* not connected */
sched_connect_timeout (dev); sched_connect_timeout(dev);
HIO_DEV_MAR_SET_PROGRESS (rdev, HIO_DEV_MAR_CONNECTING); HIO_DEV_MAR_SET_PROGRESS(rdev, HIO_DEV_MAR_CONNECTING);
watch_mysql (rdev, status); watch_mysql(rdev, status);
} }
else else
{ {
@@ -309,11 +309,11 @@ static int dev_mar_ioctl (hio_dev_t* dev, int cmd, void* arg)
} }
/* connected immediately. postpone actual handling to the ready() callback */ /* connected immediately. postpone actual handling to the ready() callback */
HIO_DEV_MAR_SET_PROGRESS (rdev, HIO_DEV_MAR_CONNECTING); HIO_DEV_MAR_SET_PROGRESS(rdev, HIO_DEV_MAR_CONNECTING);
rdev->connected_deferred = 1; /* to let the ready() handler to trigger on_connect() */ rdev->connected_deferred = 1; /* to let the ready() handler to trigger on_connect() */
/* regiter it in the multiplexer so that the ready() handler is /* regiter it in the multiplexer so that the ready() handler is
* invoked to call the on_connect() callback */ * invoked to call the on_connect() callback */
watch_mysql (rdev, MYSQL_WAIT_READ | MYSQL_WAIT_WRITE); /* TODO: verify this */ watch_mysql(rdev, MYSQL_WAIT_READ | MYSQL_WAIT_WRITE); /* TODO: verify this */
} }
return 0; return 0;
} }
@@ -339,11 +339,11 @@ static int dev_mar_ioctl (hio_dev_t* dev, int cmd, void* arg)
syshnd = mysql_get_socket(rdev->hnd); syshnd = mysql_get_socket(rdev->hnd);
status = mysql_real_query_start(&err, rdev->hnd, qstr->ptr, qstr->len); status = mysql_real_query_start(&err, rdev->hnd, qstr->ptr, qstr->len);
HIO_DEV_MAR_SET_PROGRESS (rdev, HIO_DEV_MAR_QUERY_STARTING); HIO_DEV_MAR_SET_PROGRESS(rdev, HIO_DEV_MAR_QUERY_STARTING);
if (status) if (status)
{ {
/* not done */ /* not done */
watch_mysql (rdev, status); watch_mysql(rdev, status);
} }
else else
{ {
@@ -367,8 +367,8 @@ static int dev_mar_ioctl (hio_dev_t* dev, int cmd, void* arg)
/* remember the previous handle - this may be needed by the poll/select based multiplexer */ /* remember the previous handle - this may be needed by the poll/select based multiplexer */
rdev->broken_syshnd = syshnd; rdev->broken_syshnd = syshnd;
watch_mysql (rdev, 0); watch_mysql(rdev, 0);
hio_dev_mar_halt (rdev); /* i can't keep this device alive regardless of the caller's post-action */ hio_dev_mar_halt(rdev); /* i can't keep this device alive regardless of the caller's post-action */
hio_seterrbfmt(hio, HIO_ECONLOST, "%js", prev_errmsg); hio_seterrbfmt(hio, HIO_ECONLOST, "%js", prev_errmsg);
} }
return -1; return -1;
@@ -376,7 +376,7 @@ static int dev_mar_ioctl (hio_dev_t* dev, int cmd, void* arg)
/* sent without an error */ /* sent without an error */
rdev->query_started_deferred = 1; rdev->query_started_deferred = 1;
watch_mysql (rdev, MYSQL_WAIT_READ | MYSQL_WAIT_WRITE); watch_mysql(rdev, MYSQL_WAIT_READ | MYSQL_WAIT_WRITE);
} }
return 0; return 0;
} }
@@ -393,7 +393,7 @@ static int dev_mar_ioctl (hio_dev_t* dev, int cmd, void* arg)
} }
} }
start_fetch_row (rdev); start_fetch_row(rdev);
return 0; return 0;
} }
@@ -458,8 +458,8 @@ static int dev_evcb_mar_ready (hio_dev_t* dev, int events)
/* connection esablished dev_mar_ioctl() but postponed to this function */ /* connection esablished dev_mar_ioctl() but postponed to this function */
rdev->connected_deferred = 0; rdev->connected_deferred = 0;
rdev->connected = 1; /* really connected */ rdev->connected = 1; /* really connected */
HIO_DEV_MAR_SET_PROGRESS (rdev, HIO_DEV_MAR_CONNECTED); HIO_DEV_MAR_SET_PROGRESS(rdev, HIO_DEV_MAR_CONNECTED);
if (rdev->on_connect) rdev->on_connect (rdev); if (rdev->on_connect) rdev->on_connect(rdev);
} }
else else
{ {
@@ -473,7 +473,7 @@ static int dev_evcb_mar_ready (hio_dev_t* dev, int events)
if (status) if (status)
{ {
/* connection in progress */ /* connection in progress */
watch_mysql (rdev, status); watch_mysql(rdev, status);
} }
else else
{ {
@@ -481,11 +481,11 @@ static int dev_evcb_mar_ready (hio_dev_t* dev, int events)
if (tmp) if (tmp)
{ {
/* established ok */ /* established ok */
desched_connect_timeout (dev); desched_connect_timeout(dev);
watch_mysql (rdev, status); watch_mysql(rdev, status);
rdev->connected = 1; /* really connected */ rdev->connected = 1; /* really connected */
HIO_DEV_MAR_SET_PROGRESS (rdev, HIO_DEV_MAR_CONNECTED); HIO_DEV_MAR_SET_PROGRESS(rdev, HIO_DEV_MAR_CONNECTED);
if (rdev->on_connect) rdev->on_connect (rdev); if (rdev->on_connect) rdev->on_connect(rdev);
} }
else else
{ {
@@ -509,12 +509,12 @@ static int dev_evcb_mar_ready (hio_dev_t* dev, int events)
* close(6); <- mysql_real_connect_cont(); * close(6); <- mysql_real_connect_cont();
* epoll_ctl(4, EPOLL_CTL_DEL, 6, 0x7ffc785e7154) = -1 EBADF (Bad file descriptor) <- by hio_dev_watch() in watch_mysql * epoll_ctl(4, EPOLL_CTL_DEL, 6, 0x7ffc785e7154) = -1 EBADF (Bad file descriptor) <- by hio_dev_watch() in watch_mysql
*/ */
watch_mysql (rdev, 0); watch_mysql(rdev, 0);
/* on_disconnect() will be called without on_connect(). /* on_disconnect() will be called without on_connect().
* you may assume that the initial connection attempt failed. * you may assume that the initial connection attempt failed.
* reconnection doesn't apply in this context. */ * reconnection doesn't apply in this context. */
hio_dev_mar_halt (rdev); hio_dev_mar_halt(rdev);
} }
} }
} }
@@ -524,8 +524,8 @@ static int dev_evcb_mar_ready (hio_dev_t* dev, int events)
if (rdev->query_started_deferred) if (rdev->query_started_deferred)
{ {
rdev->query_started_deferred = 0; rdev->query_started_deferred = 0;
HIO_DEV_MAR_SET_PROGRESS (rdev, HIO_DEV_MAR_QUERY_STARTED); HIO_DEV_MAR_SET_PROGRESS(rdev, HIO_DEV_MAR_QUERY_STARTED);
if (rdev->on_query_started) rdev->on_query_started (rdev, 0, HIO_NULL); if (rdev->on_query_started) rdev->on_query_started(rdev, 0, HIO_NULL);
} }
else else
{ {
@@ -537,7 +537,7 @@ static int dev_evcb_mar_ready (hio_dev_t* dev, int events)
if (status) if (status)
{ {
watch_mysql (rdev, status); watch_mysql(rdev, status);
} }
else else
{ {
@@ -556,22 +556,22 @@ static int dev_evcb_mar_ready (hio_dev_t* dev, int events)
rdev->broken = 1; rdev->broken = 1;
rdev->broken_syshnd = syshnd; rdev->broken_syshnd = syshnd;
watch_mysql (rdev, 0); watch_mysql(rdev, 0);
hio_dev_mar_halt (rdev); /* i can't keep this device alive regardless of the caller's post-action */ hio_dev_mar_halt(rdev); /* i can't keep this device alive regardless of the caller's post-action */
/* don't invoke on_query_started(). in this case, on_disconnect() will be called later */ /* don't invoke on_query_started(). in this case, on_disconnect() will be called later */
} }
else else
{ {
/* query not sent for other reasons. probably nothing to watch? */ /* query not sent for other reasons. probably nothing to watch? */
watch_mysql (rdev, 0); /* TODO: use status instead of 0? is status reliable in this context? */ watch_mysql(rdev, 0); /* TODO: use status instead of 0? is status reliable in this context? */
if (rdev->on_query_started) rdev->on_query_started (rdev, err, mysql_error(rdev->hnd)); if (rdev->on_query_started) rdev->on_query_started(rdev, err, mysql_error(rdev->hnd));
} }
} }
else else
{ {
/* query really sent */ /* query really sent */
HIO_DEV_MAR_SET_PROGRESS (rdev, HIO_DEV_MAR_QUERY_STARTED); HIO_DEV_MAR_SET_PROGRESS(rdev, HIO_DEV_MAR_QUERY_STARTED);
if (rdev->on_query_started) rdev->on_query_started (rdev, 0, HIO_NULL); if (rdev->on_query_started) rdev->on_query_started(rdev, 0, HIO_NULL);
} }
} }
} }
@@ -591,16 +591,16 @@ static int dev_evcb_mar_ready (hio_dev_t* dev, int events)
if (!row) if (!row)
{ {
HIO_ASSERT(hio, rdev->res != HIO_NULL); HIO_ASSERT(hio, rdev->res != HIO_NULL);
mysql_free_result (rdev->res); /* this doesn't block after the last row */ mysql_free_result(rdev->res); /* this doesn't block after the last row */
rdev->res = HIO_NULL; rdev->res = HIO_NULL;
watch_mysql (rdev, rdev->row_wstatus); watch_mysql(rdev, rdev->row_wstatus);
} }
HIO_DEV_MAR_SET_PROGRESS (rdev, HIO_DEV_MAR_ROW_FETCHED); HIO_DEV_MAR_SET_PROGRESS(rdev, HIO_DEV_MAR_ROW_FETCHED);
if (HIO_LIKELY(rdev->on_row_fetched)) rdev->on_row_fetched (rdev, row); if (HIO_LIKELY(rdev->on_row_fetched)) rdev->on_row_fetched(rdev, row);
if (row) start_fetch_row (rdev); if (row) start_fetch_row(rdev);
} }
else else
{ {
@@ -613,22 +613,22 @@ static int dev_evcb_mar_ready (hio_dev_t* dev, int events)
if (!row) if (!row)
{ {
/* the last row has been received - cleanup before invoking the callback */ /* the last row has been received - cleanup before invoking the callback */
watch_mysql (rdev, status); watch_mysql(rdev, status);
HIO_ASSERT(hio, rdev->res != HIO_NULL); HIO_ASSERT(hio, rdev->res != HIO_NULL);
mysql_free_result (rdev->res); /* this doesn't block after the last row */ mysql_free_result(rdev->res); /* this doesn't block after the last row */
rdev->res = HIO_NULL; rdev->res = HIO_NULL;
} }
HIO_DEV_MAR_SET_PROGRESS (rdev, HIO_DEV_MAR_ROW_FETCHED); HIO_DEV_MAR_SET_PROGRESS(rdev, HIO_DEV_MAR_ROW_FETCHED);
if (HIO_LIKELY(rdev->on_row_fetched)) rdev->on_row_fetched (rdev, row); if (HIO_LIKELY(rdev->on_row_fetched)) rdev->on_row_fetched(rdev, row);
if (row) start_fetch_row (rdev); /* arrange to fetch the next row */ if (row) start_fetch_row(rdev); /* arrange to fetch the next row */
} }
else else
{ {
/* no row is available */ /* no row is available */
watch_mysql (rdev, status); watch_mysql(rdev, status);
} }
} }
@@ -680,5 +680,5 @@ int hio_dev_mar_fetchrows (hio_dev_mar_t* dev)
hio_oow_t hio_dev_mar_escapebchars (hio_dev_mar_t* dev, const hio_bch_t* qstr, hio_oow_t qlen, hio_bch_t* buf) hio_oow_t hio_dev_mar_escapebchars (hio_dev_mar_t* dev, const hio_bch_t* qstr, hio_oow_t qlen, hio_bch_t* buf)
{ {
hio_dev_mar_t* rdev = (hio_dev_mar_t*)dev; hio_dev_mar_t* rdev = (hio_dev_mar_t*)dev;
return mysql_real_escape_string (rdev->hnd, buf, qstr, qlen); return mysql_real_escape_string(rdev->hnd, buf, qstr, qlen);
} }
+10 -51
View File
@@ -1482,7 +1482,7 @@ fcntl (rdev->hnd, F_SETFL, flags | O_NONBLOCK);
} }
else else
{ {
HIO_INIT_NTIME (&rdev->tmout, -1, 0); /* just in case */ HIO_INIT_NTIME(&rdev->tmout, -1, 0); /* just in case */
if (!HIO_IS_NEG_NTIME(&conn->connect_tmout)) if (!HIO_IS_NEG_NTIME(&conn->connect_tmout))
{ {
@@ -1502,7 +1502,7 @@ fcntl (rdev->hnd, F_SETFL, flags | O_NONBLOCK);
#if defined(USE_SSL) #if defined(USE_SSL)
rdev->ssl_ctx = ssl_ctx; rdev->ssl_ctx = ssl_ctx;
#endif #endif
HIO_DEV_SCK_SET_PROGRESS (rdev, HIO_DEV_SCK_CONNECTING); HIO_DEV_SCK_SET_PROGRESS(rdev, HIO_DEV_SCK_CONNECTING);
return 0; return 0;
} }
} }
@@ -1543,7 +1543,7 @@ fcntl (rdev->hnd, F_SETFL, flags | O_NONBLOCK);
rdev->ssl_ctx = ssl_ctx; rdev->ssl_ctx = ssl_ctx;
#endif #endif
/* set progress CONNECTING so that the ready handler invokes on_connect() */ /* set progress CONNECTING so that the ready handler invokes on_connect() */
HIO_DEV_SCK_SET_PROGRESS (rdev, HIO_DEV_SCK_CONNECTING); HIO_DEV_SCK_SET_PROGRESS(rdev, HIO_DEV_SCK_CONNECTING);
return 0; return 0;
} }
} }
@@ -1591,7 +1591,7 @@ fcntl (rdev->hnd, F_SETFL, flags | O_NONBLOCK);
rdev->tmout = lstn->accept_tmout; rdev->tmout = lstn->accept_tmout;
HIO_DEV_SCK_SET_PROGRESS (rdev, HIO_DEV_SCK_LISTENING); HIO_DEV_SCK_SET_PROGRESS(rdev, HIO_DEV_SCK_LISTENING);
return 0; return 0;
} }
} }
@@ -1759,7 +1759,7 @@ static int harvest_outgoing_connection (hio_dev_sck_t* rdev)
if (x == 0) if (x == 0)
{ {
/* underlying socket connected but not SSL-connected */ /* underlying socket connected but not SSL-connected */
HIO_DEV_SCK_SET_PROGRESS (rdev, HIO_DEV_SCK_CONNECTING_SSL); HIO_DEV_SCK_SET_PROGRESS(rdev, HIO_DEV_SCK_CONNECTING_SSL);
HIO_ASSERT(hio, rdev->tmrjob_index == HIO_TMRIDX_INVALID); HIO_ASSERT(hio, rdev->tmrjob_index == HIO_TMRIDX_INVALID);
@@ -1784,7 +1784,7 @@ static int harvest_outgoing_connection (hio_dev_sck_t* rdev)
{ {
ssl_connected: ssl_connected:
#endif #endif
HIO_DEV_SCK_SET_PROGRESS (rdev, HIO_DEV_SCK_CONNECTED); HIO_DEV_SCK_SET_PROGRESS(rdev, HIO_DEV_SCK_CONNECTED);
if (rdev->on_connect) rdev->on_connect (rdev); if (rdev->on_connect) rdev->on_connect (rdev);
#if defined(USE_SSL) #if defined(USE_SSL)
} }
@@ -1905,7 +1905,7 @@ static int make_accepted_client_connection (hio_dev_sck_t* rdev, hio_syshnd_t cl
if (rdev->ssl_ctx) if (rdev->ssl_ctx)
{ {
HIO_DEV_SCK_SET_PROGRESS (clidev, HIO_DEV_SCK_ACCEPTING_SSL); HIO_DEV_SCK_SET_PROGRESS(clidev, HIO_DEV_SCK_ACCEPTING_SSL);
HIO_ASSERT(hio, clidev->state & HIO_DEV_SCK_ACCEPTING_SSL); HIO_ASSERT(hio, clidev->state & HIO_DEV_SCK_ACCEPTING_SSL);
/* actual SSL acceptance must be completed in the client device */ /* actual SSL acceptance must be completed in the client device */
@@ -1922,7 +1922,7 @@ static int make_accepted_client_connection (hio_dev_sck_t* rdev, hio_syshnd_t cl
} }
else else
{ {
HIO_DEV_SCK_SET_PROGRESS (clidev, HIO_DEV_SCK_ACCEPTED); HIO_DEV_SCK_SET_PROGRESS(clidev, HIO_DEV_SCK_ACCEPTED);
/*if (clidev->on_connect(clidev) <= -1) hio_dev_sck_halt (clidev);*/ /*if (clidev->on_connect(clidev) <= -1) hio_dev_sck_halt (clidev);*/
if (clidev->on_connect) clidev->on_connect (clidev); if (clidev->on_connect) clidev->on_connect (clidev);
} }
@@ -2070,7 +2070,7 @@ static int dev_evcb_sck_ready_stream (hio_dev_t* dev, int events)
rdev->tmrjob_index = HIO_TMRIDX_INVALID; rdev->tmrjob_index = HIO_TMRIDX_INVALID;
} }
HIO_DEV_SCK_SET_PROGRESS (rdev, HIO_DEV_SCK_CONNECTED); HIO_DEV_SCK_SET_PROGRESS(rdev, HIO_DEV_SCK_CONNECTED);
if (rdev->on_connect) rdev->on_connect (rdev); if (rdev->on_connect) rdev->on_connect (rdev);
return 0; return 0;
} }
@@ -2142,7 +2142,7 @@ static int dev_evcb_sck_ready_stream (hio_dev_t* dev, int events)
rdev->tmrjob_index = HIO_TMRIDX_INVALID; rdev->tmrjob_index = HIO_TMRIDX_INVALID;
} }
HIO_DEV_SCK_SET_PROGRESS (rdev, HIO_DEV_SCK_ACCEPTED); HIO_DEV_SCK_SET_PROGRESS(rdev, HIO_DEV_SCK_ACCEPTED);
if (rdev->on_connect) rdev->on_connect (rdev); if (rdev->on_connect) rdev->on_connect (rdev);
return 0; return 0;
@@ -2633,47 +2633,6 @@ int hio_dev_sck_writetosidechan (hio_dev_sck_t* dev, const void* dptr, hio_oow_t
/* ========================================================================= */ /* ========================================================================= */
void hio_dev_sck_pushevcb (hio_dev_sck_t* dev, hio_dev_sck_evcb_link_t* link, const hio_dev_sck_evcb_t* evcb, void* ctx)
{
link->saved.on_read = dev->on_read;
link->saved.on_write = dev->on_write;
link->saved.on_disconnect = dev->on_disconnect;
link->ctx = ctx;
link->prev = dev->evcb_top;
dev->evcb_top = link;
/* a null member means "leave the layer below in place" */
if (evcb->on_read) dev->on_read = evcb->on_read;
if (evcb->on_write) dev->on_write = evcb->on_write;
if (evcb->on_disconnect) dev->on_disconnect = evcb->on_disconnect;
}
hio_dev_sck_evcb_link_t* hio_dev_sck_popevcb (hio_dev_sck_t* dev)
{
hio_dev_sck_evcb_link_t* link;
link = dev->evcb_top;
if (!link) return HIO_NULL; /* nothing in the stack */
dev->on_read = link->saved.on_read;
dev->on_write = link->saved.on_write;
dev->on_disconnect = link->saved.on_disconnect;
dev->evcb_top = link->prev;
link->prev = HIO_NULL;
return link;
}
void* hio_dev_sck_getevcbctx (hio_dev_sck_t* dev)
{
return dev->evcb_top? dev->evcb_top->ctx: HIO_NULL;
}
hio_dev_sck_evcb_t* hio_dev_sck_getparentevcb (hio_dev_sck_t* dev)
{
return dev->evcb_top? &dev->evcb_top->saved: HIO_NULL;
}
/* ========================================================================= */ /* ========================================================================= */
hio_uint16_t hio_checksum_ip (const void* hdr, hio_oow_t len) hio_uint16_t hio_checksum_ip (const void* hdr, hio_oow_t len)
+8 -8
View File
@@ -101,7 +101,7 @@ void hio_sys_gettime (hio_t* hio, hio_ntime_t* now)
msec = elapsed - HIO_SEC_TO_MSEC(et.sec); msec = elapsed - HIO_SEC_TO_MSEC(et.sec);
et.nsec = HIO_MSEC_TO_NSEC(msec); et.nsec = HIO_MSEC_TO_NSEC(msec);
HIO_ADD_NTIME (&xtn->tc_last_ret , &xtn->tc_last_ret, &et); HIO_ADD_NTIME(&xtn->tc_last_ret , &xtn->tc_last_ret, &et);
*now = xtn->tc_last_ret; *now = xtn->tc_last_ret;
#elif defined(__DOS__) && (defined(_INTELC32_) || defined(__WATCOMC__)) #elif defined(__DOS__) && (defined(_INTELC32_) || defined(__WATCOMC__))
@@ -126,7 +126,7 @@ void hio_sys_gettime (hio_t* hio, hio_ntime_t* now)
# error UNSUPPORTED CLOCKS_PER_SEC # error UNSUPPORTED CLOCKS_PER_SEC
#endif #endif
HIO_ADD_NTIME (&xtn->tc_last_ret , &xtn->tc_last_ret, &et); HIO_ADD_NTIME(&xtn->tc_last_ret , &xtn->tc_last_ret, &et);
*now = xtn->tc_last_ret; *now = xtn->tc_last_ret;
#elif defined(macintosh) #elif defined(macintosh)
@@ -134,18 +134,18 @@ void hio_sys_gettime (hio_t* hio, hio_ntime_t* now)
hio_uint64_t tick64; hio_uint64_t tick64;
Microseconds (&tick); Microseconds (&tick);
tick64 = *(hio_uint64_t*)&tick; tick64 = *(hio_uint64_t*)&tick;
HIO_INIT_NTIME (now, HIO_USEC_TO_SEC(tick64), HIO_USEC_TO_NSEC(tick64)); HIO_INIT_NTIME(now, HIO_USEC_TO_SEC(tick64), HIO_USEC_TO_NSEC(tick64));
#elif defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC) #elif defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
struct timespec ts; struct timespec ts;
clock_gettime (CLOCK_MONOTONIC, &ts); clock_gettime(CLOCK_MONOTONIC, &ts);
HIO_INIT_NTIME(now, ts.tv_sec, ts.tv_nsec); HIO_INIT_NTIME(now, ts.tv_sec, ts.tv_nsec);
#elif defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_REALTIME) #elif defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
struct timespec ts; struct timespec ts;
clock_gettime (CLOCK_REALTIME, &ts); clock_gettime(CLOCK_REALTIME, &ts);
HIO_INIT_NTIME(now, ts.tv_sec, ts.tv_nsec); HIO_INIT_NTIME(now, ts.tv_sec, ts.tv_nsec);
#else #else
struct timeval tv; struct timeval tv;
gettimeofday (&tv, HIO_NULL); gettimeofday(&tv, HIO_NULL);
HIO_INIT_NTIME(now, tv.tv_sec, HIO_USEC_TO_NSEC(tv.tv_usec)); HIO_INIT_NTIME(now, tv.tv_sec, HIO_USEC_TO_NSEC(tv.tv_usec));
#endif #endif
} }
@@ -155,11 +155,11 @@ void hio_sys_getrealtime (hio_t* hio, hio_ntime_t* now)
{ {
#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_REALTIME) #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
struct timespec ts; struct timespec ts;
clock_gettime (CLOCK_REALTIME, &ts); clock_gettime(CLOCK_REALTIME, &ts);
HIO_INIT_NTIME(now, ts.tv_sec, ts.tv_nsec); HIO_INIT_NTIME(now, ts.tv_sec, ts.tv_nsec);
#else #else
struct timeval tv; struct timeval tv;
gettimeofday (&tv, HIO_NULL); gettimeofday(&tv, HIO_NULL);
HIO_INIT_NTIME(now, tv.tv_sec, HIO_USEC_TO_NSEC(tv.tv_usec)); HIO_INIT_NTIME(now, tv.tv_sec, HIO_USEC_TO_NSEC(tv.tv_usec));
#endif #endif
} }
+6 -6
View File
@@ -51,9 +51,9 @@ int hio_sys_init (hio_t* hio)
return 0; return 0;
oops: oops:
if (time_inited) hio_sys_finitime (hio); if (time_inited) hio_sys_finitime(hio);
if (mux_inited) hio_sys_finimux (hio); if (mux_inited) hio_sys_finimux(hio);
if (log_inited) hio_sys_finilog (hio); if (log_inited) hio_sys_finilog(hio);
if (hio->sysdep) if (hio->sysdep)
{ {
hio_freemem(hio, hio->sysdep); hio_freemem(hio, hio->sysdep);
@@ -64,9 +64,9 @@ oops:
void hio_sys_fini (hio_t* hio) void hio_sys_fini (hio_t* hio)
{ {
hio_sys_finitime (hio); hio_sys_finitime(hio);
if (hio->_features & HIO_FEATURE_MUX) hio_sys_finimux (hio); if (hio->_features & HIO_FEATURE_MUX) hio_sys_finimux(hio);
if (hio->_features & HIO_FEATURE_LOG) hio_sys_finilog (hio); if (hio->_features & HIO_FEATURE_LOG) hio_sys_finilog(hio);
hio_freemem(hio, hio->sysdep); hio_freemem(hio, hio->sysdep);
hio->sysdep = HIO_NULL; hio->sysdep = HIO_NULL;
+8 -8
View File
@@ -146,7 +146,7 @@ static int x_process_header (hio_tar_t* tar)
tar->x.hi.fp = HIO_NULL; tar->x.hi.fp = HIO_NULL;
} }
hio_becs_clear (&tar->x.hi.filename); hio_becs_clear(&tar->x.hi.filename);
if (tar->x.root[0] != '\0') if (tar->x.root[0] != '\0')
{ {
if (hio_becs_cat(&tar->x.hi.filename, tar->x.root) == (hio_oow_t)-1) return -1; if (hio_becs_cat(&tar->x.hi.filename, tar->x.root) == (hio_oow_t)-1) return -1;
@@ -159,22 +159,22 @@ static int x_process_header (hio_tar_t* tar)
switch (hdr->typeflag) switch (hdr->typeflag)
{ {
case HIO_TAR_LNKTYPE: case HIO_TAR_LNKTYPE:
link (hdr->linkname, filename); link(hdr->linkname, filename);
break; break;
case HIO_TAR_SYMTYPE: case HIO_TAR_SYMTYPE:
symlink (hdr->linkname, filename); /* TODO: error check */ symlink(hdr->linkname, filename); /* TODO: error check */
break; break;
case HIO_TAR_CHRTYPE: case HIO_TAR_CHRTYPE:
mknod (filename, S_IFCHR | tar->x.hi.filemode, ((tar->x.hi.devmajor << 8) | tar->x.hi.devminor)); mknod(filename, S_IFCHR | tar->x.hi.filemode, ((tar->x.hi.devmajor << 8) | tar->x.hi.devminor));
break; break;
case HIO_TAR_BLKTYPE: case HIO_TAR_BLKTYPE:
mknod (filename, S_IFBLK | tar->x.hi.filemode, ((tar->x.hi.devmajor << 8) | tar->x.hi.devminor)); mknod(filename, S_IFBLK | tar->x.hi.filemode, ((tar->x.hi.devmajor << 8) | tar->x.hi.devminor));
break; break;
case HIO_TAR_DIRTYPE: case HIO_TAR_DIRTYPE:
create_dir (filename, tar->x.hi.filemode); create_dir(filename, tar->x.hi.filemode);
break; break;
case HIO_TAR_FIFOTYPE: case HIO_TAR_FIFOTYPE:
mkfifo (filename, tar->x.hi.filemode); mkfifo(filename, tar->x.hi.filemode);
break; break;
case HIO_TAR_CONTTYPE: /* treate it like REGTYPE for now */ case HIO_TAR_CONTTYPE: /* treate it like REGTYPE for now */
@@ -189,7 +189,7 @@ static int x_process_header (hio_tar_t* tar)
return -1; return -1;
} }
fchmod (fileno(fp), tar->x.hi.filemode); fchmod(fileno(fp), tar->x.hi.filemode);
tar->x.hi.fp = fp; tar->x.hi.fp = fp;
tar->x.state = HIO_TAR_STATE_FILE; tar->x.state = HIO_TAR_STATE_FILE;
+6 -6
View File
@@ -167,7 +167,7 @@ void hio_firetmrjobs (hio_t* hio, const hio_ntime_t* tm, hio_oow_t* firecnt)
/* if the current time is not specified, get it from the system */ /* if the current time is not specified, get it from the system */
if (tm) now = *tm; if (tm) now = *tm;
else hio_gettime (hio, &now); else hio_gettime(hio, &now);
while (hio->tmr.size > 0) while (hio->tmr.size > 0)
{ {
@@ -192,10 +192,10 @@ int hio_gettmrtmout (hio_t* hio, const hio_ntime_t* tm, hio_ntime_t* tmout)
/* if the current time is not specified, get it from the system */ /* if the current time is not specified, get it from the system */
if (tm) now = *tm; if (tm) now = *tm;
else hio_gettime (hio, &now); else hio_gettime(hio, &now);
HIO_SUB_NTIME (tmout, &hio->tmr.jobs[0].when, &now); HIO_SUB_NTIME(tmout, &hio->tmr.jobs[0].when, &now);
if (tmout->sec < 0) HIO_CLEAR_NTIME (tmout); if (tmout->sec < 0) HIO_CLEAR_NTIME(tmout);
return 1; /* tmout is set */ return 1; /* tmout is set */
} }
@@ -242,8 +242,8 @@ int hio_schedtmrjobafter (hio_t* hio, const hio_ntime_t* fire_after, hio_tmrjob_
HIO_ASSERT(hio, !HIO_IS_NEG_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);
return hio_schedtmrjobat(hio, &fire_at, handler, tmridx, ctx); return hio_schedtmrjobat(hio, &fire_at, handler, tmridx, ctx);
} }
+24 -3
View File
@@ -14,10 +14,17 @@ LDFLAGS_COMMON=-L$(abs_builddir)/../lib -L$(libdir)
LIBADD_COMMON = ../lib/libhio.la $(LIBM) LIBADD_COMMON = ../lib/libhio.la $(LIBM)
check_SCRIPTS = s-001.sh check_SCRIPTS = s-001.sh s-002.sh
EXTRA_DIST = $(check_SCRIPTS) tap.inc t-cgi.sh EXTRA_DIST = $(check_SCRIPTS) tap.inc t-cgi.sh
check_PROGRAMS = t-001 t-002 t-003 t-004 t-005 t-006 t-007 t-008 ## programs run as tests
TESTPROGS = t-001 t-002 t-003 t-004 t-005 t-006 t-007 t-008
## helpers the test scripts drive. built with the tests, but not tests
## themselves - they are servers and would never exit.
HELPERPROGS = fcgis httssvr
check_PROGRAMS = $(TESTPROGS) $(HELPERPROGS)
t_001_SOURCES = t-001.c tap.h t_001_SOURCES = t-001.c tap.h
t_001_CPPFLAGS = $(CPPFLAGS_COMMON) t_001_CPPFLAGS = $(CPPFLAGS_COMMON)
@@ -69,8 +76,22 @@ t_008_CFLAGS = $(CFLAGS_COMMON)
t_008_LDFLAGS = $(LDFLAGS_COMMON) t_008_LDFLAGS = $(LDFLAGS_COMMON)
t_008_LDADD = $(LIBADD_COMMON) t_008_LDADD = $(LIBADD_COMMON)
## a minimal FastCGI responder, driven by s-002.sh
fcgis_SOURCES = fcgis.c
fcgis_CPPFLAGS = $(CPPFLAGS_COMMON)
fcgis_CFLAGS = $(CFLAGS_COMMON)
fcgis_LDFLAGS = $(LDFLAGS_COMMON)
fcgis_LDADD = $(LIBADD_COMMON)
## an http server exercising the htts task types, driven by s-002.sh
httssvr_SOURCES = httssvr.c
httssvr_CPPFLAGS = $(CPPFLAGS_COMMON)
httssvr_CFLAGS = $(CFLAGS_COMMON)
httssvr_LDFLAGS = $(LDFLAGS_COMMON)
httssvr_LDADD = $(LIBADD_COMMON)
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/ac/tap-driver.sh LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/ac/tap-driver.sh
TESTS = $(check_PROGRAMS) $(check_SCRIPTS) TESTS = $(TESTPROGS) $(check_SCRIPTS)
TEST_EXTENSIONS = .sh TEST_EXTENSIONS = .sh
SH_LOG_DRIVER = $(LOG_DRIVER) SH_LOG_DRIVER = $(LOG_DRIVER)
+86 -15
View File
@@ -89,9 +89,8 @@ PRE_UNINSTALL = :
POST_UNINSTALL = : POST_UNINSTALL = :
build_triplet = @build@ build_triplet = @build@
host_triplet = @host@ host_triplet = @host@
check_PROGRAMS = t-001$(EXEEXT) t-002$(EXEEXT) t-003$(EXEEXT) \ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2)
t-004$(EXEEXT) t-005$(EXEEXT) t-006$(EXEEXT) t-007$(EXEEXT) \ TESTS = $(am__EXEEXT_1) $(check_SCRIPTS)
t-008$(EXEEXT)
subdir = t subdir = t
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
@@ -107,15 +106,31 @@ mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/lib/hio-cfg.h CONFIG_HEADER = $(top_builddir)/lib/hio-cfg.h
CONFIG_CLEAN_FILES = CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES = CONFIG_CLEAN_VPATH_FILES =
am_t_001_OBJECTS = t_001-t-001.$(OBJEXT) am__EXEEXT_1 = t-001$(EXEEXT) t-002$(EXEEXT) t-003$(EXEEXT) \
t_001_OBJECTS = $(am_t_001_OBJECTS) t-004$(EXEEXT) t-005$(EXEEXT) t-006$(EXEEXT) t-007$(EXEEXT) \
t-008$(EXEEXT)
am__EXEEXT_2 = fcgis$(EXEEXT) httssvr$(EXEEXT)
am_fcgis_OBJECTS = fcgis-fcgis.$(OBJEXT)
fcgis_OBJECTS = $(am_fcgis_OBJECTS)
am__DEPENDENCIES_1 = am__DEPENDENCIES_1 =
am__DEPENDENCIES_2 = ../lib/libhio.la $(am__DEPENDENCIES_1) am__DEPENDENCIES_2 = ../lib/libhio.la $(am__DEPENDENCIES_1)
t_001_DEPENDENCIES = $(am__DEPENDENCIES_2) fcgis_DEPENDENCIES = $(am__DEPENDENCIES_2)
AM_V_lt = $(am__v_lt_@AM_V@) AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent am__v_lt_0 = --silent
am__v_lt_1 = am__v_lt_1 =
fcgis_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(fcgis_CFLAGS) $(CFLAGS) \
$(fcgis_LDFLAGS) $(LDFLAGS) -o $@
am_httssvr_OBJECTS = httssvr-httssvr.$(OBJEXT)
httssvr_OBJECTS = $(am_httssvr_OBJECTS)
httssvr_DEPENDENCIES = $(am__DEPENDENCIES_2)
httssvr_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(httssvr_CFLAGS) \
$(CFLAGS) $(httssvr_LDFLAGS) $(LDFLAGS) -o $@
am_t_001_OBJECTS = t_001-t-001.$(OBJEXT)
t_001_OBJECTS = $(am_t_001_OBJECTS)
t_001_DEPENDENCIES = $(am__DEPENDENCIES_2)
t_001_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ t_001_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(t_001_CFLAGS) $(CFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(t_001_CFLAGS) $(CFLAGS) \
$(t_001_LDFLAGS) $(LDFLAGS) -o $@ $(t_001_LDFLAGS) $(LDFLAGS) -o $@
@@ -176,7 +191,8 @@ am__v_at_1 =
DEFAULT_INCLUDES = DEFAULT_INCLUDES =
depcomp = $(SHELL) $(top_srcdir)/ac/depcomp depcomp = $(SHELL) $(top_srcdir)/ac/depcomp
am__maybe_remake_depfiles = depfiles am__maybe_remake_depfiles = depfiles
am__depfiles_remade = ./$(DEPDIR)/t_001-t-001.Po \ am__depfiles_remade = ./$(DEPDIR)/fcgis-fcgis.Po \
./$(DEPDIR)/httssvr-httssvr.Po ./$(DEPDIR)/t_001-t-001.Po \
./$(DEPDIR)/t_002-t-002.Po ./$(DEPDIR)/t_003-t-003.Po \ ./$(DEPDIR)/t_002-t-002.Po ./$(DEPDIR)/t_003-t-003.Po \
./$(DEPDIR)/t_004-t-004.Po ./$(DEPDIR)/t_005-t-005.Po \ ./$(DEPDIR)/t_004-t-004.Po ./$(DEPDIR)/t_005-t-005.Po \
./$(DEPDIR)/t_006-t-006.Po ./$(DEPDIR)/t_007-t-007.Po \ ./$(DEPDIR)/t_006-t-006.Po ./$(DEPDIR)/t_007-t-007.Po \
@@ -200,12 +216,14 @@ AM_V_CCLD = $(am__v_CCLD_@AM_V@)
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 = am__v_CCLD_1 =
SOURCES = $(t_001_SOURCES) $(t_002_SOURCES) $(t_003_SOURCES) \ SOURCES = $(fcgis_SOURCES) $(httssvr_SOURCES) $(t_001_SOURCES) \
$(t_004_SOURCES) $(t_005_SOURCES) $(t_006_SOURCES) \ $(t_002_SOURCES) $(t_003_SOURCES) $(t_004_SOURCES) \
$(t_007_SOURCES) $(t_008_SOURCES) $(t_005_SOURCES) $(t_006_SOURCES) $(t_007_SOURCES) \
DIST_SOURCES = $(t_001_SOURCES) $(t_002_SOURCES) $(t_003_SOURCES) \ $(t_008_SOURCES)
$(t_004_SOURCES) $(t_005_SOURCES) $(t_006_SOURCES) \ DIST_SOURCES = $(fcgis_SOURCES) $(httssvr_SOURCES) $(t_001_SOURCES) \
$(t_007_SOURCES) $(t_008_SOURCES) $(t_002_SOURCES) $(t_003_SOURCES) $(t_004_SOURCES) \
$(t_005_SOURCES) $(t_006_SOURCES) $(t_007_SOURCES) \
$(t_008_SOURCES)
am__can_run_installinfo = \ am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \ case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \ n|no|NO) false;; \
@@ -593,8 +611,10 @@ CPPFLAGS_COMMON = \
CFLAGS_COMMON = CFLAGS_COMMON =
LDFLAGS_COMMON = -L$(abs_builddir)/../lib -L$(libdir) LDFLAGS_COMMON = -L$(abs_builddir)/../lib -L$(libdir)
LIBADD_COMMON = ../lib/libhio.la $(LIBM) LIBADD_COMMON = ../lib/libhio.la $(LIBM)
check_SCRIPTS = s-001.sh check_SCRIPTS = s-001.sh s-002.sh
EXTRA_DIST = $(check_SCRIPTS) tap.inc t-cgi.sh EXTRA_DIST = $(check_SCRIPTS) tap.inc t-cgi.sh
TESTPROGS = t-001 t-002 t-003 t-004 t-005 t-006 t-007 t-008
HELPERPROGS = fcgis httssvr
t_001_SOURCES = t-001.c tap.h t_001_SOURCES = t-001.c tap.h
t_001_CPPFLAGS = $(CPPFLAGS_COMMON) t_001_CPPFLAGS = $(CPPFLAGS_COMMON)
t_001_CFLAGS = $(CFLAGS_COMMON) t_001_CFLAGS = $(CFLAGS_COMMON)
@@ -635,8 +655,17 @@ t_008_CPPFLAGS = $(CPPFLAGS_COMMON)
t_008_CFLAGS = $(CFLAGS_COMMON) t_008_CFLAGS = $(CFLAGS_COMMON)
t_008_LDFLAGS = $(LDFLAGS_COMMON) t_008_LDFLAGS = $(LDFLAGS_COMMON)
t_008_LDADD = $(LIBADD_COMMON) t_008_LDADD = $(LIBADD_COMMON)
fcgis_SOURCES = fcgis.c
fcgis_CPPFLAGS = $(CPPFLAGS_COMMON)
fcgis_CFLAGS = $(CFLAGS_COMMON)
fcgis_LDFLAGS = $(LDFLAGS_COMMON)
fcgis_LDADD = $(LIBADD_COMMON)
httssvr_SOURCES = httssvr.c
httssvr_CPPFLAGS = $(CPPFLAGS_COMMON)
httssvr_CFLAGS = $(CFLAGS_COMMON)
httssvr_LDFLAGS = $(LDFLAGS_COMMON)
httssvr_LDADD = $(LIBADD_COMMON)
LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/ac/tap-driver.sh LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) $(top_srcdir)/ac/tap-driver.sh
TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
TEST_EXTENSIONS = .sh TEST_EXTENSIONS = .sh
SH_LOG_DRIVER = $(LOG_DRIVER) SH_LOG_DRIVER = $(LOG_DRIVER)
SH_LOG_COMPILER = /bin/sh SH_LOG_COMPILER = /bin/sh
@@ -678,6 +707,14 @@ clean-checkPROGRAMS:
$(am__rm_f) $(check_PROGRAMS) $(am__rm_f) $(check_PROGRAMS)
test -z "$(EXEEXT)" || $(am__rm_f) $(check_PROGRAMS:$(EXEEXT)=) test -z "$(EXEEXT)" || $(am__rm_f) $(check_PROGRAMS:$(EXEEXT)=)
fcgis$(EXEEXT): $(fcgis_OBJECTS) $(fcgis_DEPENDENCIES) $(EXTRA_fcgis_DEPENDENCIES)
@rm -f fcgis$(EXEEXT)
$(AM_V_CCLD)$(fcgis_LINK) $(fcgis_OBJECTS) $(fcgis_LDADD) $(LIBS)
httssvr$(EXEEXT): $(httssvr_OBJECTS) $(httssvr_DEPENDENCIES) $(EXTRA_httssvr_DEPENDENCIES)
@rm -f httssvr$(EXEEXT)
$(AM_V_CCLD)$(httssvr_LINK) $(httssvr_OBJECTS) $(httssvr_LDADD) $(LIBS)
t-001$(EXEEXT): $(t_001_OBJECTS) $(t_001_DEPENDENCIES) $(EXTRA_t_001_DEPENDENCIES) t-001$(EXEEXT): $(t_001_OBJECTS) $(t_001_DEPENDENCIES) $(EXTRA_t_001_DEPENDENCIES)
@rm -f t-001$(EXEEXT) @rm -f t-001$(EXEEXT)
$(AM_V_CCLD)$(t_001_LINK) $(t_001_OBJECTS) $(t_001_LDADD) $(LIBS) $(AM_V_CCLD)$(t_001_LINK) $(t_001_OBJECTS) $(t_001_LDADD) $(LIBS)
@@ -716,6 +753,8 @@ mostlyclean-compile:
distclean-compile: distclean-compile:
-rm -f *.tab.c -rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fcgis-fcgis.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/httssvr-httssvr.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_001-t-001.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_001-t-001.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_002-t-002.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_002-t-002.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_003-t-003.Po@am__quote@ # am--include-marker @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t_003-t-003.Po@am__quote@ # am--include-marker
@@ -755,6 +794,34 @@ am--depfiles: $(am__depfiles_remade)
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
fcgis-fcgis.o: fcgis.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fcgis_CPPFLAGS) $(CPPFLAGS) $(fcgis_CFLAGS) $(CFLAGS) -MT fcgis-fcgis.o -MD -MP -MF $(DEPDIR)/fcgis-fcgis.Tpo -c -o fcgis-fcgis.o `test -f 'fcgis.c' || echo '$(srcdir)/'`fcgis.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fcgis-fcgis.Tpo $(DEPDIR)/fcgis-fcgis.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fcgis.c' object='fcgis-fcgis.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fcgis_CPPFLAGS) $(CPPFLAGS) $(fcgis_CFLAGS) $(CFLAGS) -c -o fcgis-fcgis.o `test -f 'fcgis.c' || echo '$(srcdir)/'`fcgis.c
fcgis-fcgis.obj: fcgis.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fcgis_CPPFLAGS) $(CPPFLAGS) $(fcgis_CFLAGS) $(CFLAGS) -MT fcgis-fcgis.obj -MD -MP -MF $(DEPDIR)/fcgis-fcgis.Tpo -c -o fcgis-fcgis.obj `if test -f 'fcgis.c'; then $(CYGPATH_W) 'fcgis.c'; else $(CYGPATH_W) '$(srcdir)/fcgis.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/fcgis-fcgis.Tpo $(DEPDIR)/fcgis-fcgis.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='fcgis.c' object='fcgis-fcgis.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(fcgis_CPPFLAGS) $(CPPFLAGS) $(fcgis_CFLAGS) $(CFLAGS) -c -o fcgis-fcgis.obj `if test -f 'fcgis.c'; then $(CYGPATH_W) 'fcgis.c'; else $(CYGPATH_W) '$(srcdir)/fcgis.c'; fi`
httssvr-httssvr.o: httssvr.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(httssvr_CPPFLAGS) $(CPPFLAGS) $(httssvr_CFLAGS) $(CFLAGS) -MT httssvr-httssvr.o -MD -MP -MF $(DEPDIR)/httssvr-httssvr.Tpo -c -o httssvr-httssvr.o `test -f 'httssvr.c' || echo '$(srcdir)/'`httssvr.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/httssvr-httssvr.Tpo $(DEPDIR)/httssvr-httssvr.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='httssvr.c' object='httssvr-httssvr.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(httssvr_CPPFLAGS) $(CPPFLAGS) $(httssvr_CFLAGS) $(CFLAGS) -c -o httssvr-httssvr.o `test -f 'httssvr.c' || echo '$(srcdir)/'`httssvr.c
httssvr-httssvr.obj: httssvr.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(httssvr_CPPFLAGS) $(CPPFLAGS) $(httssvr_CFLAGS) $(CFLAGS) -MT httssvr-httssvr.obj -MD -MP -MF $(DEPDIR)/httssvr-httssvr.Tpo -c -o httssvr-httssvr.obj `if test -f 'httssvr.c'; then $(CYGPATH_W) 'httssvr.c'; else $(CYGPATH_W) '$(srcdir)/httssvr.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/httssvr-httssvr.Tpo $(DEPDIR)/httssvr-httssvr.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='httssvr.c' object='httssvr-httssvr.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(httssvr_CPPFLAGS) $(CPPFLAGS) $(httssvr_CFLAGS) $(CFLAGS) -c -o httssvr-httssvr.obj `if test -f 'httssvr.c'; then $(CYGPATH_W) 'httssvr.c'; else $(CYGPATH_W) '$(srcdir)/httssvr.c'; fi`
t_001-t-001.o: t-001.c t_001-t-001.o: t-001.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(t_001_CPPFLAGS) $(CPPFLAGS) $(t_001_CFLAGS) $(CFLAGS) -MT t_001-t-001.o -MD -MP -MF $(DEPDIR)/t_001-t-001.Tpo -c -o t_001-t-001.o `test -f 't-001.c' || echo '$(srcdir)/'`t-001.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(t_001_CPPFLAGS) $(CPPFLAGS) $(t_001_CFLAGS) $(CFLAGS) -MT t_001-t-001.o -MD -MP -MF $(DEPDIR)/t_001-t-001.Tpo -c -o t_001-t-001.o `test -f 't-001.c' || echo '$(srcdir)/'`t-001.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/t_001-t-001.Tpo $(DEPDIR)/t_001-t-001.Po @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/t_001-t-001.Tpo $(DEPDIR)/t_001-t-001.Po
@@ -1240,6 +1307,8 @@ clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
mostlyclean-am mostlyclean-am
distclean: distclean-am distclean: distclean-am
-rm -f ./$(DEPDIR)/fcgis-fcgis.Po
-rm -f ./$(DEPDIR)/httssvr-httssvr.Po
-rm -f ./$(DEPDIR)/t_001-t-001.Po -rm -f ./$(DEPDIR)/t_001-t-001.Po
-rm -f ./$(DEPDIR)/t_002-t-002.Po -rm -f ./$(DEPDIR)/t_002-t-002.Po
-rm -f ./$(DEPDIR)/t_003-t-003.Po -rm -f ./$(DEPDIR)/t_003-t-003.Po
@@ -1293,6 +1362,8 @@ install-ps-am:
installcheck-am: installcheck-am:
maintainer-clean: maintainer-clean-am maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/fcgis-fcgis.Po
-rm -f ./$(DEPDIR)/httssvr-httssvr.Po
-rm -f ./$(DEPDIR)/t_001-t-001.Po -rm -f ./$(DEPDIR)/t_001-t-001.Po
-rm -f ./$(DEPDIR)/t_002-t-002.Po -rm -f ./$(DEPDIR)/t_002-t-002.Po
-rm -f ./$(DEPDIR)/t_003-t-003.Po -rm -f ./$(DEPDIR)/t_003-t-003.Po
+303
View File
@@ -0,0 +1,303 @@
/*
* A minimal FastCGI responder, built on hio itself, for the test suite.
*
* It speaks just enough of the protocol to answer a request:
* BEGIN_REQUEST / PARAMS / STDIN in, STDOUT / END_REQUEST out. The reply
* body is a fixed marker so a test can tell that a request really
* travelled through the fcgi task and the FastCGI protocol both ways
* rather than being answered somewhere else.
*
* The client keeps a connection open across requests, so a connection is
* served until the peer closes it rather than being torn down after one.
*
* Usage: hio-fcgis <ipaddr:port> [ready-file]
*
* If ready-file is given it is created once the listener is accepting,
* which lets a harness start requests without racing this process.
*/
#include <hio.h>
#include <hio-sck.h>
#include <hio-fcgi.h>
#include <hio-utl.h>
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <signal.h>
#include <stdlib.h>
#define RESPONSE_BODY "fcgi-ok\r\n"
/* what a connection has accumulated but not yet consumed */
#define INBUF_CAPA 65536
typedef struct conn_xtn_t conn_xtn_t;
struct conn_xtn_t
{
hio_uint8_t buf[INBUF_CAPA];
hio_oow_t len;
/* a request is answerable once it has been begun and both of its
* streams have ended. they are tracked separately because the order
* they arrive in is not guaranteed - see the note in consume_records() */
hio_uint16_t id;
unsigned int begun: 1;
unsigned int params_done: 1;
unsigned int stdin_done: 1;
};
static void reset_request (conn_xtn_t* cx)
{
cx->id = 0;
cx->begun = 0;
cx->params_done = 0;
cx->stdin_done = 0;
}
static hio_t* g_hio = HIO_NULL;
static int g_verbose = 0;
static void on_sigint (int sig)
{
if (g_hio) hio_stop (g_hio, HIO_STOPREQ_TERMINATION);
}
/* ------------------------------------------------------------------ */
/* The record layout is taken from hio-fcgi.h. Since both this responder
* and the library's client read it from the same header, a packing
* mistake would make the two agree with each other while disagreeing
* with the wire. Check it against the specification once at startup so
* that shows up as a loud failure instead of a silent one. */
static int check_wire_layout (void)
{
if (HIO_SIZEOF(hio_fcgi_record_header_t) != 8 ||
offsetof(hio_fcgi_record_header_t, version) != 0 ||
offsetof(hio_fcgi_record_header_t, type) != 1 ||
offsetof(hio_fcgi_record_header_t, id) != 2 ||
offsetof(hio_fcgi_record_header_t, content_len) != 4 ||
offsetof(hio_fcgi_record_header_t, padding_len) != 6)
{
fprintf (stderr, "hio_fcgi_record_header_t does not match the FastCGI wire layout\n");
return -1;
}
if (HIO_SIZEOF(hio_fcgi_begin_request_body_t) != 8 ||
HIO_SIZEOF(hio_fcgi_end_request_body_t) != 8)
{
fprintf (stderr, "FastCGI body structures do not match the wire layout\n");
return -1;
}
return 0;
}
static int write_record (hio_dev_sck_t* sck, int type, hio_uint16_t id, const void* data, hio_uint16_t len)
{
hio_fcgi_record_header_t hdr;
memset (&hdr, 0, HIO_SIZEOF(hdr));
hdr.version = HIO_FCGI_VERSION;
hdr.type = type;
hdr.id = hio_hton16(id);
hdr.content_len = hio_hton16(len);
if (hio_dev_sck_write(sck, &hdr, HIO_SIZEOF(hdr), HIO_NULL, HIO_NULL) <= -1) return -1;
if (len > 0 && hio_dev_sck_write(sck, data, len, HIO_NULL, HIO_NULL) <= -1) return -1;
return 0;
}
static int respond (hio_dev_sck_t* sck, hio_uint16_t id)
{
static const char out[] = "Content-Type: text/plain\r\n\r\n" RESPONSE_BODY;
hio_fcgi_end_request_body_t end;
if (write_record(sck, HIO_FCGI_STDOUT, id, out, HIO_SIZEOF(out) - 1) <= -1) return -1;
if (write_record(sck, HIO_FCGI_STDOUT, id, HIO_NULL, 0) <= -1) return -1; /* end of stream */
memset (&end, 0, HIO_SIZEOF(end));
end.app_status = hio_hton32(0);
end.proto_status = HIO_FCGI_REQUEST_COMPLETE;
return write_record(sck, HIO_FCGI_END_REQUEST, id, &end, HIO_SIZEOF(end));
}
/* consume as many whole records as the buffer holds */
static int consume_records (hio_dev_sck_t* sck, conn_xtn_t* cx)
{
while (cx->len >= HIO_SIZEOF(hio_fcgi_record_header_t))
{
hio_fcgi_record_header_t hdr;
hio_oow_t clen, plen, total;
memcpy (&hdr, cx->buf, HIO_SIZEOF(hdr));
clen = hio_ntoh16(hdr.content_len);
plen = hdr.padding_len;
total = HIO_SIZEOF(hdr) + clen + plen;
if (g_verbose) fprintf (stderr, "record type=%d id=%d clen=%d have=%d\n",
(int)hdr.type, (int)hio_ntoh16(hdr.id), (int)clen, (int)cx->len);
if (cx->len < total) break; /* wait for the rest of this record */
/* Answer once the request has been begun and both of its streams
* have ended, rather than on any single record. A responder has no
* business assuming the three arrive in one particular order, and
* tracking them separately keeps this working whatever order a
* client picks. */
switch (hdr.type)
{
case HIO_FCGI_BEGIN_REQUEST:
cx->id = hio_ntoh16(hdr.id);
cx->begun = 1;
break;
case HIO_FCGI_PARAMS:
if (clen == 0) cx->params_done = 1;
break;
case HIO_FCGI_STDIN:
if (clen == 0) cx->stdin_done = 1;
break;
}
if (cx->begun && cx->params_done && cx->stdin_done)
{
if (respond(sck, cx->id) <= -1) return -1;
reset_request (cx); /* the connection may carry more requests */
}
memmove (cx->buf, &cx->buf[total], cx->len - total);
cx->len -= total;
}
return 0;
}
/* ------------------------------------------------------------------ */
static int on_read (hio_dev_sck_t* sck, const void* buf, hio_iolen_t len, const hio_skad_t* srcaddr)
{
conn_xtn_t* cx = hio_dev_sck_getxtn(sck);
if (len <= 0) return 0; /* error or peer closed - let the device wind down */
if (cx->len + len > HIO_SIZEOF(cx->buf))
{
/* a test request never gets near this; treat it as a protocol error */
hio_dev_sck_halt (sck);
return 0;
}
memcpy (&cx->buf[cx->len], buf, len);
cx->len += len;
if (consume_records(sck, cx) <= -1) hio_dev_sck_halt (sck);
return 0;
}
static int on_write (hio_dev_sck_t* sck, hio_iolen_t wrlen, void* wrctx, const hio_skad_t* dstaddr)
{
return 0;
}
static void on_connect (hio_dev_sck_t* sck)
{
if (sck->state & HIO_DEV_SCK_ACCEPTED)
{
conn_xtn_t* cx = hio_dev_sck_getxtn(sck);
cx->len = 0;
reset_request (cx);
if (g_verbose) fprintf (stderr, "accepted\n");
}
}
static void on_disconnect (hio_dev_sck_t* sck)
{
}
/* ------------------------------------------------------------------ */
int main (int argc, char* argv[])
{
hio_dev_sck_t* svr;
hio_dev_sck_make_t m;
hio_dev_sck_bind_t b;
hio_dev_sck_listen_t l;
hio_skad_t addr;
int ret = -1;
if (argc < 2 || argc > 3)
{
fprintf (stderr, "Usage: %s <ipaddr:port> [ready-file]\n", argv[0]);
return -1;
}
if (check_wire_layout() <= -1) return -1;
g_verbose = (getenv("HIO_FCGIS_VERBOSE") != HIO_NULL);
g_hio = hio_open(HIO_NULL, 0, HIO_NULL, HIO_FEATURE_ALL, 256, HIO_NULL);
if (!g_hio)
{
fprintf (stderr, "unable to open hio\n");
return -1;
}
signal (SIGINT, on_sigint);
signal (SIGTERM, on_sigint);
signal (SIGPIPE, SIG_IGN);
if (hio_bcstrtoskad(g_hio, argv[1], &addr) <= -1)
{
fprintf (stderr, "invalid address - %s\n", argv[1]);
goto oops;
}
memset (&m, 0, HIO_SIZEOF(m));
m.type = (hio_skad_get_family(&addr) == HIO_AF_INET)? HIO_DEV_SCK_TCP4: HIO_DEV_SCK_TCP6;
m.on_read = on_read;
m.on_write = on_write;
m.on_connect = on_connect;
m.on_disconnect = on_disconnect;
svr = hio_dev_sck_make(g_hio, HIO_SIZEOF(conn_xtn_t), &m);
if (!svr)
{
fprintf (stderr, "unable to make a socket - %s\n", hio_geterrbmsg(g_hio));
goto oops;
}
memset (&b, 0, HIO_SIZEOF(b));
b.localaddr = addr;
b.options = HIO_DEV_SCK_BIND_REUSEADDR;
if (hio_dev_sck_bind(svr, &b) <= -1)
{
fprintf (stderr, "unable to bind - %s\n", hio_geterrbmsg(g_hio));
goto oops;
}
memset (&l, 0, HIO_SIZEOF(l));
l.backlogs = 64;
if (hio_dev_sck_listen(svr, &l) <= -1)
{
fprintf (stderr, "unable to listen - %s\n", hio_geterrbmsg(g_hio));
goto oops;
}
if (argc >= 3)
{
/* tell the harness the listener is up, so it never races us */
FILE* fp = fopen(argv[2], "w");
if (fp)
{
fputs ("ready\n", fp);
fclose (fp);
}
}
hio_loop (g_hio);
ret = 0;
oops:
if (g_hio) hio_close (g_hio);
return ret;
}
+20
View File
@@ -215,6 +215,14 @@ if (hio_htre_getcontentlen(req) > 0)
x = hio_svc_htts_dotxt(htts, csck, req, HIO_HTTP_STATUS_OK, "text/plain", qpath, 0, HIO_NULL); x = hio_svc_htts_dotxt(htts, csck, req, HIO_HTTP_STATUS_OK, "text/plain", qpath, 0, HIO_NULL);
else if (hio_comp_bcstr_limited(qpath, "/cgi/", 5, 1) == 0) else if (hio_comp_bcstr_limited(qpath, "/cgi/", 5, 1) == 0)
x = hio_svc_htts_docgi(htts, csck, req, "", qpath + 4, 0, HIO_NULL); x = hio_svc_htts_docgi(htts, csck, req, "", qpath + 4, 0, HIO_NULL);
else if (hio_comp_bcstr_limited(qpath, "/prxy/", 6, 1) == 0)
{
/* forward to an upstream http server. the test harness runs
* one on this port. */
hio_skad_t prxy_addr;
hio_bcstrtoskad(hio, "127.0.0.1:9001", &prxy_addr);
x = hio_svc_htts_doprxy(htts, csck, req, &prxy_addr, 0, HIO_NULL);
}
else if (hio_comp_bcstr_limited(qpath, "/fcgi/", 5, 1) == 0) else if (hio_comp_bcstr_limited(qpath, "/fcgi/", 5, 1) == 0)
{ {
hio_skad_t fcgis_addr; hio_skad_t fcgis_addr;
@@ -270,6 +278,18 @@ void* thr_func (void* arg)
goto oops; goto oops;
} }
{
/* the fcgi task refuses with 503 unless the client service is up.
* the timeouts must be non-zero: a zeroed 'c' is a 0-second connect
* deadline, so the peer is untied before it ever connects. */
hio_svc_fcgic_tmout_t fcgic_tmout;
memset (&fcgic_tmout, 0, HIO_SIZEOF(fcgic_tmout));
HIO_INIT_NTIME (&fcgic_tmout.c, 5, 0);
HIO_INIT_NTIME (&fcgic_tmout.r, 60, 0);
HIO_INIT_NTIME (&fcgic_tmout.w, -1, 0);
hio_svc_htts_enablefcgic (htts, &fcgic_tmout);
}
pthread_mutex_lock (&g_htts_mutex); pthread_mutex_lock (&g_htts_mutex);
htts_no = g_htts_no; htts_no = g_htts_no;
g_htts[htts_no] = htts; g_htts[htts_no] = htts;
Executable
+146
View File
@@ -0,0 +1,146 @@
#!/bin/sh
# End-to-end coverage for the http task modules that s-001.sh does not
# reach. httssvr routes by path prefix, so txt, thr and fcgi are all
# exercisable here; fcgi talks to fcgis, the minimal responder in
# this directory.
#
# prxy is still uncovered: http-prxy.c never connects its peer socket
# (no hio_dev_sck_connect anywhere in the file) so the task cannot
# currently reach an upstream. httssvr has a /prxy/ route ready for when
# that is finished.
[ -z "$srcdir" ] && srcdir=$(dirname "$0")
. "${srcdir}/tap.inc"
SRVPORT=9988
SRVADDR="127.0.0.1:${SRVPORT}"
start_server()
{
# the fcgi task needs a responder listening on the port httssvr targets
fcgiready="/tmp/s-002-fcgi.$$.ready"
rm -f "${fcgiready}"
./fcgis 127.0.0.1:9000 "${fcgiready}" >/dev/null 2>&1 &
fcgipid=$!
# it creates the ready file once it is accepting, so nothing races it
i=0
while [ $i -lt 50 ] && [ ! -f "${fcgiready}" ]; do
i=$((i + 1))
sleep 0.1
done
[ -f "${fcgiready}" ] || fcgipid=""
./httssvr >/dev/null 2>&1 &
srvpid=$!
# wait for the listener rather than sleeping a fixed amount
i=0
while [ $i -lt 50 ]; do
curl -s -m 1 -o /dev/null "http://${SRVADDR}/txt/ping" 2>/dev/null && return 0
i=$((i + 1))
sleep 0.1
done
return 1
}
stop_server()
{
kill -TERM ${srvpid} 2>/dev/null
wait ${srvpid} 2>/dev/null
if [ -n "${fcgipid}" ]; then
kill -TERM ${fcgipid} 2>/dev/null
wait ${fcgipid} 2>/dev/null
fi
rm -f "${fcgiready}"
}
test_fcgi()
{
local msg="httssvr fcgi task"
if [ -z "${fcgipid}" ]; then
tap_fail "$msg - fcgis did not come up"
tap_fail "$msg - fcgis did not come up"
return
fi
local hc=$(curl -s -m 10 -w '%{http_code}' -o /dev/null "http://${SRVADDR}/fcgi/x.php")
tap_ensure "$hc" "200" "$msg - got $hc"
# the body can only come from the responder, so this proves the
# request traversed the fcgi task and the FastCGI protocol both ways
local body=$(curl -s -m 10 "http://${SRVADDR}/fcgi/x.php" | tr -d '\r\n')
tap_ensure "$body" "fcgi-ok" "$msg - body came from the fcgi responder"
}
test_txt()
{
local msg="httssvr txt task"
local hc=$(curl -s -m 5 -w '%{http_code}' -o /dev/null "http://${SRVADDR}/txt/hello")
tap_ensure "$hc" "200" "$msg - got $hc"
# dotxt() echoes the query path back as the body
local body=$(curl -s -m 5 "http://${SRVADDR}/txt/hello")
tap_ensure "$body" "/txt/hello" "$msg - body echoes the query path"
# the task must release the client so the next request reuses the
# connection. each -w applies to its own request, so the second line
# is the one that matters.
local n=$(curl -s -m 5 -o /dev/null -w '%{num_connects}\n' "http://${SRVADDR}/txt/one" \
-o /dev/null -w '%{num_connects}\n' "http://${SRVADDR}/txt/two" | tail -1)
tap_ensure "$n" "0" "$msg - connection is reused after the task completes"
}
test_thr()
{
local msg="httssvr thr task"
local hc=$(curl -s -m 5 -w '%{http_code}' -o /dev/null "http://${SRVADDR}/thr/x")
tap_ensure "$hc" "200" "$msg - got $hc"
# thr2 serves the filesystem path following /thr2, so point it at a
# real file to exercise the success path...
local tmpf="/tmp/s-002.$$.txt"
echo "thr2-payload" > "${tmpf}"
local body=$(curl -s -m 5 "http://${SRVADDR}/thr2${tmpf}")
tap_ensure "$body" "thr2-payload" "$msg - thr2 serves a file through the thread"
# ...and at a missing one to exercise the error path
local hc2=$(curl -s -m 5 -w '%{http_code}' -o /dev/null "http://${SRVADDR}/thr2/no/such/file")
tap_ensure "$hc2" "404" "$msg - thr2 reports 404 for a missing file"
rm -f "${tmpf}"
}
test_mixed_load()
{
local msg="httssvr mixed task load"
local ok=0 i=0
# alternate task types on the same server to shake out cross-task
# client-binding mistakes
while [ $i -lt 12 ]; do
for p in /txt/a /thr/b /txt/c; do
local hc=$(curl -s -m 5 -o /dev/null -w '%{http_code}' "http://${SRVADDR}${p}")
[ "$hc" = "200" ] && ok=$((ok + 1))
done
i=$((i + 1))
done
tap_ensure "$ok" "36" "$msg - 36/36 requests succeeded"
# and the server must still be alive afterwards
kill -0 ${srvpid} 2>/dev/null && tap_ok "$msg - server still running" \
|| tap_fail "$msg - server died"
}
if start_server; then
test_txt
test_thr
test_fcgi
test_mixed_load
stop_server
else
tap_skip "httssvr did not come up"
fi
tap_end
-78
View File
@@ -574,83 +574,6 @@ done:
if (b && b->magic == TDEV_LIVE) hio_dev_kill ((hio_dev_t*)b); if (b && b->magic == TDEV_LIVE) hio_dev_kill ((hio_dev_t*)b);
} }
/* ------------------------------------------------------------------ */
/* evcb stack */
/* ------------------------------------------------------------------ */
static int g_layer_read[2];
static int layer_x_on_read (hio_dev_t* dev, const void* p, hio_iolen_t l, const hio_devaddr_t* s)
{
g_layer_read[0]++;
return 0;
}
static int layer_y_on_read (hio_dev_t* dev, const void* p, hio_iolen_t l, const hio_devaddr_t* s)
{
g_layer_read[1]++;
return 0;
}
static int layer_on_write (hio_dev_t* dev, hio_iolen_t l, void* c, const hio_devaddr_t* a)
{
return 0;
}
/* declared the way every device type in the library declares its own: one
* file-scope table per role, shared by every device playing that role.
* that sharing is the whole point of the pattern, and it is what any
* stack-link stored inside the table has to survive. */
static hio_dev_evcb_t g_layer_x = { HIO_NULL, layer_x_on_read, layer_on_write };
static hio_dev_evcb_t g_layer_y = { HIO_NULL, layer_y_on_read, layer_on_write };
/* the stack links are per-device storage owned by the pusher */
static hio_dev_evcb_link_t g_link_a, g_link_b0, g_link_b1;
static void test_evcb_stack (void)
{
tdev_t* a = HIO_NULL, * b = HIO_NULL;
int pa = -1, pb = -1;
obs_reset ();
g_layer_read[0] = g_layer_read[1] = 0;
a = make_tdev(11, &pa);
b = make_tdev(12, &pb);
if (!a || !b) { skip ("device creation failed", 7); goto done; }
OK (a->dev_evcb == &tdev_evcb && b->dev_evcb == &tdev_evcb,
"both devices start on the base handler table");
hio_dev_pushevcb ((hio_dev_t*)a, &g_link_a, &g_layer_x, a);
OK (a->dev_evcb == &g_layer_x, "push swaps the device onto the pushed table");
OK (hio_dev_getevcbctx((hio_dev_t*)a) == a, "the pushed layer's context is readable");
/* b stacks two deep and reuses the very table a is already sitting on -
* the ordinary case when one handler set serves many connections */
hio_dev_pushevcb ((hio_dev_t*)b, &g_link_b0, &g_layer_y, b);
hio_dev_pushevcb ((hio_dev_t*)b, &g_link_b1, &g_layer_x, b);
OK (b->dev_evcb == &g_layer_x, "a second device can stack two layers deep");
OK (hio_dev_getevcbctx((hio_dev_t*)a) == a && hio_dev_getevcbctx((hio_dev_t*)b) == b,
"each device keeps its own context for the same shared table");
hio_dev_popevcb ((hio_dev_t*)a);
OK (a->dev_evcb == (hio_dev_evcb_t*)&tdev_evcb,
"popping restores a device's own previous table, not another device's");
/* and behaviourally: input on 'a' must reach the base handler again */
if (write(pa, "z", 1) == 1) pump ();
OK (g_on_read_calls == 1 && g_layer_read[0] == 0 && g_layer_read[1] == 0,
"after popping, events are delivered to the base handler");
done:
if (b) { while (hio_dev_popevcb((hio_dev_t*)b)) ; }
if (pa >= 0) close (pa);
if (pb >= 0) close (pb);
if (a && a->magic == TDEV_LIVE) hio_dev_kill ((hio_dev_t*)a);
if (b && b->magic == TDEV_LIVE) hio_dev_kill ((hio_dev_t*)b);
}
static void test_fini_kills_survivors (void) static void test_fini_kills_survivors (void)
{ {
/* devices still active or halted at hio_close() time must be destroyed */ /* devices still active or halted at hio_close() time must be destroyed */
@@ -707,7 +630,6 @@ int main (void)
test_zombie_escalation (); test_zombie_escalation ();
test_read_and_eof (); test_read_and_eof ();
test_kill_peer_from_callback (); test_kill_peer_from_callback ();
test_evcb_stack ();
test_fini_kills_survivors (); test_fini_kills_survivors ();
hio_close (g_hio); hio_close (g_hio);