added mio_schedtmrjobat() and mio_schedtmrjobafter()

touched up some log messages in sck.c
This commit is contained in:
2020-08-01 15:56:53 +00:00
parent c230c92249
commit e77391da1d
7 changed files with 85 additions and 47 deletions

View File

@ -988,23 +988,6 @@ static void handle_signal (int sig)
if (g_mio) mio_stop (g_mio, MIO_STOPREQ_TERMINATION);
}
static int schedule_timer_job_after (mio_t* mio, const mio_ntime_t* fire_after, mio_tmrjob_handler_t handler, void* ctx)
{
mio_tmrjob_t tmrjob;
memset (&tmrjob, 0, MIO_SIZEOF(tmrjob));
tmrjob.ctx = ctx;
mio_gettime (mio, &tmrjob.when);
MIO_ADD_NTIME (&tmrjob.when, &tmrjob.when, fire_after);
tmrjob.handler = handler;
tmrjob.idxptr = MIO_NULL;
return mio_instmrjob(mio, &tmrjob);
}
static void send_test_query (mio_t* mio, const mio_ntime_t* now, mio_tmrjob_t* job)
{
//if (!mio_svc_dnc_resolve((mio_svc_dnc_t*)job->ctx, "www.microsoft.com", MIO_DNS_RRT_CNAME, MIO_SVC_DNC_RESOLVE_FLAG_COOKIE, on_dnc_resolve, 0))
@ -1340,7 +1323,7 @@ for (i = 0; i < 5; i++)
{
mio_ntime_t x;
MIO_INIT_NTIME (&x, 5, 0);
schedule_timer_job_after (mio, &x, send_test_query, dnc);
mio_schedtmrjobafter (mio, &x, send_test_query, MIO_NULL, dnc);
if (!mio_svc_dnc_resolve(dnc, "b.wild.com", MIO_DNS_RRT_A, MIO_SVC_DNC_RESOLVE_FLAG_PREFER_TCP, on_dnc_resolve, 0))
{

View File

@ -342,6 +342,7 @@ struct xx_mq_t
static xx_mq_t xx_mq;
#if 0
static int schedule_timer_job_at (mio_dev_sck_t* dev, const mio_ntime_t* fire_at, mio_tmrjob_handler_t handler, mio_tmridx_t* tmridx)
{
mio_tmrjob_t tmrjob;
@ -355,6 +356,7 @@ static int schedule_timer_job_at (mio_dev_sck_t* dev, const mio_ntime_t* fire_at
return mio_instmrjob(dev->mio, &tmrjob);
}
#endif
static void enable_accept (mio_t* mio, const mio_ntime_t* now, mio_tmrjob_t* job)
{
@ -408,7 +410,7 @@ static int try_to_accept (mio_dev_sck_t* sck, mio_dev_sck_qxmsg_t* qxmsg, int in
}
if (xx_tmridx == MIO_TMRIDX_INVALID)
schedule_timer_job_at (sck, MIO_NULL, enable_accept, &xx_tmridx);
mio_schedtmrjobat (mio, MIO_NULL, enable_accept, &xx_tmridx, sck);
return 0; /* enqueued for later writing */
}
@ -488,6 +490,7 @@ static int add_listener (mio_t* mio, mio_bch_t* addrstr)
memset (&mi, 0, MIO_SIZEOF(mi));
mi.type = (mio_skad_family(&bi.localaddr) == MIO_AF_INET? MIO_DEV_SCK_TCP4: MIO_DEV_SCK_TCP6);
mi.options = MIO_DEV_SCK_MAKE_LENIENT;
mi.on_write = tcp_sck_on_write;
mi.on_read = tcp_sck_on_read;
mi.on_connect = tcp_sck_on_connect; /* this is invoked on a client accept as well */