fixing some bugs regarding mux update - wip

This commit is contained in:
hyung-hwan 2019-01-28 17:41:50 +00:00
parent e9c42b28c6
commit 470e459781
8 changed files with 172 additions and 85 deletions

View File

@ -347,6 +347,7 @@ pdfdir = @pdfdir@
prefix = @prefix@ prefix = @prefix@
program_transform_name = @program_transform_name@ program_transform_name = @program_transform_name@
psdir = @psdir@ psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@ sharedstatedir = @sharedstatedir@
srcdir = @srcdir@ srcdir = @srcdir@
@ -577,7 +578,7 @@ distdir: $(DISTFILES)
! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r "$(distdir)" || chmod -R a+r "$(distdir)"
dist-gzip: distdir dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__post_remove_distdir) $(am__post_remove_distdir)
dist-bzip2: distdir dist-bzip2: distdir
@ -603,7 +604,7 @@ dist-shar: distdir
@echo WARNING: "Support for shar distribution archives is" \ @echo WARNING: "Support for shar distribution archives is" \
"deprecated." >&2 "deprecated." >&2
@echo WARNING: "It will be removed altogether in Automake 2.0" >&2 @echo WARNING: "It will be removed altogether in Automake 2.0" >&2
shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__post_remove_distdir) $(am__post_remove_distdir)
dist-zip: distdir dist-zip: distdir
@ -621,7 +622,7 @@ dist dist-all:
distcheck: dist distcheck: dist
case '$(DIST_ARCHIVES)' in \ case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \ *.tar.gz*) \
eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \ *.tar.bz2*) \
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.lz*) \ *.tar.lz*) \
@ -631,7 +632,7 @@ distcheck: dist
*.tar.Z*) \ *.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \ *.shar.gz*) \
eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
*.zip*) \ *.zip*) \
unzip $(distdir).zip ;;\ unzip $(distdir).zip ;;\
esac esac

60
mio/configure vendored
View File

@ -771,6 +771,7 @@ infodir
docdir docdir
oldincludedir oldincludedir
includedir includedir
runstatedir
localstatedir localstatedir
sharedstatedir sharedstatedir
sysconfdir sysconfdir
@ -861,6 +862,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc' sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com' sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var' localstatedir='${prefix}/var'
runstatedir='${localstatedir}/run'
includedir='${prefix}/include' includedir='${prefix}/include'
oldincludedir='/usr/include' oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@ -1113,6 +1115,15 @@ do
| -silent | --silent | --silen | --sile | --sil) | -silent | --silent | --silen | --sile | --sil)
silent=yes ;; silent=yes ;;
-runstatedir | --runstatedir | --runstatedi | --runstated \
| --runstate | --runstat | --runsta | --runst | --runs \
| --run | --ru | --r)
ac_prev=runstatedir ;;
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
| --run=* | --ru=* | --r=*)
runstatedir=$ac_optarg ;;
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;; ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@ -1250,7 +1261,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \ datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
libdir localedir mandir libdir localedir mandir runstatedir
do do
eval ac_val=\$$ac_var eval ac_val=\$$ac_var
# Remove trailing slashes. # Remove trailing slashes.
@ -1403,6 +1414,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var] --localstatedir=DIR modifiable single-machine data [PREFIX/var]
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib] --libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include] --includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include] --oldincludedir=DIR C header files for non-gcc [/usr/include]
@ -19145,6 +19157,52 @@ fi
rm -f core conftest.err conftest.$ac_objext \ rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext conftest$ac_exeext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for strftime %z" >&5
$as_echo_n "checking for strftime %z... " >&6; }
if test "$cross_compiling" = yes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: unknown" >&5
$as_echo "unknown" >&6; }
$as_echo "#define HAVE_STRFTIME_SMALL_Z 1" >>confdefs.h
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <string.h>
#if defined(HAVE_SYS_TIME_H)
#include <sys/time.h>
#endif
#if defined(HAVE_TIME_H)
#include <time.h>
#endif
int main ()
{
char buf[100];
time_t t = 0;
strftime (buf, sizeof(buf), "%z", gmtime(&t));
return (strcmp(buf, "%z") == 0 || strcmp(buf, "z") == 0)? 1: 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
$as_echo "#define HAVE_STRFTIME_SMALL_Z 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
# The cast to long int works around a bug in the HP C Compiler # The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.

View File

@ -380,6 +380,34 @@ AC_TRY_LINK(
[AC_MSG_RESULT(no)] [AC_MSG_RESULT(no)]
) )
AC_MSG_CHECKING([for strftime %z])
AC_TRY_RUN(
[#include <string.h>
#if defined(HAVE_SYS_TIME_H)
#include <sys/time.h>
#endif
#if defined(HAVE_TIME_H)
#include <time.h>
#endif
int main ()
{
char buf[100];
time_t t = 0;
strftime (buf, sizeof(buf), "%z", gmtime(&t));
return (strcmp(buf, "%z") == 0 || strcmp(buf, "z") == 0)? 1: 0;
}],
[
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_STRFTIME_SMALL_Z], [1], [strftime supports %z])
],
[AC_MSG_RESULT(no)],
[
dnl cross-compiling, assume yes
AC_MSG_RESULT(unknown)
AC_DEFINE([HAVE_STRFTIME_SMALL_Z], [1], [strftime supports %z])
]
)
dnl check the size of primitive data types dnl check the size of primitive data types
AC_CHECK_SIZEOF(char,,[[]]) AC_CHECK_SIZEOF(char,,[[]])
AC_CHECK_SIZEOF(short,,[[]]) AC_CHECK_SIZEOF(short,,[[]])

View File

@ -365,6 +365,7 @@ pdfdir = @pdfdir@
prefix = @prefix@ prefix = @prefix@
program_transform_name = @program_transform_name@ program_transform_name = @program_transform_name@
psdir = @psdir@ psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@ sharedstatedir = @sharedstatedir@
srcdir = @srcdir@ srcdir = @srcdir@

View File

@ -430,6 +430,12 @@ mio_ooi_t mio_logbfmt (mio_t* mio, mio_bitmask_t mask, const mio_bch_t* fmt, ...
* it'll get turned back on */ * it'll get turned back on */
mask |= (mio->log.default_type_mask & MIO_LOG_ALL_TYPES); mask |= (mio->log.default_type_mask & MIO_LOG_ALL_TYPES);
} }
else if (!(mask & MIO_LOG_ALL_TYPES))
{
/* no type is set in the given mask and no default type is set.
* make it UNTYPED. */
mask |= MIO_LOG_UNTYPED;
}
fo.mask = mask; fo.mask = mask;
fo.putch = put_ooch; fo.putch = put_ooch;
@ -458,6 +464,10 @@ mio_ooi_t mio_logufmt (mio_t* mio, mio_bitmask_t mask, const mio_uch_t* fmt, ...
mask &= ~MIO_LOG_UNTYPED; mask &= ~MIO_LOG_UNTYPED;
mask |= (mio->log.default_type_mask & MIO_LOG_ALL_TYPES); mask |= (mio->log.default_type_mask & MIO_LOG_ALL_TYPES);
} }
else if (!(mask & MIO_LOG_ALL_TYPES))
{
mask |= MIO_LOG_UNTYPED;
}
fo.mask = mask; fo.mask = mask;
fo.putch = put_ooch; fo.putch = put_ooch;

View File

@ -128,31 +128,31 @@ static void tcp_sck_on_disconnect (mio_dev_sck_t* tcp)
switch (MIO_DEV_SCK_GET_PROGRESS(tcp)) switch (MIO_DEV_SCK_GET_PROGRESS(tcp))
{ {
case MIO_DEV_SCK_CONNECTING: case MIO_DEV_SCK_CONNECTING:
printf ("OUTGOING SESSION DISCONNECTED - FAILED TO CONNECT (%d) TO REMOTE SERVER\n", (int)tcp->sck); MIO_INFO1 (tcp->mio, "OUTGOING SESSION DISCONNECTED - FAILED TO CONNECT (%d) TO REMOTE SERVER\n", (int)tcp->sck);
break; break;
case MIO_DEV_SCK_CONNECTING_SSL: case MIO_DEV_SCK_CONNECTING_SSL:
printf ("OUTGOING SESSION DISCONNECTED - FAILED TO SSL-CONNECT (%d) TO REMOTE SERVER\n", (int)tcp->sck); MIO_INFO1 (tcp->mio, "OUTGOING SESSION DISCONNECTED - FAILED TO SSL-CONNECT (%d) TO REMOTE SERVER\n", (int)tcp->sck);
break; break;
case MIO_DEV_SCK_LISTENING: case MIO_DEV_SCK_LISTENING:
printf ("SHUTTING DOWN THE SERVER SOCKET(%d)...\n", (int)tcp->sck); MIO_INFO1 (tcp->mio, "SHUTTING DOWN THE SERVER SOCKET(%d)...\n", (int)tcp->sck);
break; break;
case MIO_DEV_SCK_CONNECTED: case MIO_DEV_SCK_CONNECTED:
printf ("OUTGOING CLIENT CONNECTION GOT TORN DOWN(%d).......\n", (int)tcp->sck); MIO_INFO1 (tcp->mio, "OUTGOING CLIENT CONNECTION GOT TORN DOWN(%d).......\n", (int)tcp->sck);
break; break;
case MIO_DEV_SCK_ACCEPTING_SSL: case MIO_DEV_SCK_ACCEPTING_SSL:
printf ("INCOMING SSL-ACCEPT GOT DISCONNECTED(%d) ....\n", (int)tcp->sck); MIO_INFO1 (tcp->mio, "INCOMING SSL-ACCEPT GOT DISCONNECTED(%d) ....\n", (int)tcp->sck);
break; break;
case MIO_DEV_SCK_ACCEPTED: case MIO_DEV_SCK_ACCEPTED:
printf ("INCOMING CLIENT BEING SERVED GOT DISCONNECTED(%d).......\n", (int)tcp->sck); MIO_INFO1 (tcp->mio, "INCOMING CLIENT BEING SERVED GOT DISCONNECTED(%d).......\n", (int)tcp->sck);
break; break;
default: default:
printf ("SOCKET DEVICE DISCONNECTED (%d - %x)\n", (int)tcp->sck, (unsigned int)tcp->state); MIO_INFO2 (tcp->mio, "SOCKET DEVICE DISCONNECTED (%d - %x)\n", (int)tcp->sck, (unsigned int)tcp->state);
break; break;
} }
} }
@ -174,14 +174,13 @@ static void tcp_sck_on_connect (mio_dev_sck_t* tcp)
if (tcp->state & MIO_DEV_SCK_CONNECTED) if (tcp->state & MIO_DEV_SCK_CONNECTED)
{ {
mio_logbfmt (tcp->mio, MIO_LOG_UNTYPED | MIO_LOG_INFO, "DEVICE connected to a remote server... LOCAL %hs:%d REMOTE %hs:%d.", MIO_INFO5 (tcp->mio, "DEVICE connected to a remote server... LOCAL %hs:%d REMOTE %hs:%d SCK: %d\n",
buf1, mio_getsckaddrport(&tcp->localaddr), buf2, mio_getsckaddrport(&tcp->remoteaddr)); buf1, mio_getsckaddrport(&tcp->localaddr), buf2, mio_getsckaddrport(&tcp->remoteaddr), tcp->sck);
printf ("DEVICE connected to a remote server... LOCAL %s:%d REMOTE %s:%d.",
buf1, mio_getsckaddrport(&tcp->localaddr), buf2, mio_getsckaddrport(&tcp->remoteaddr));
} }
else if (tcp->state & MIO_DEV_SCK_ACCEPTED) else if (tcp->state & MIO_DEV_SCK_ACCEPTED)
{ {
printf ("DEVICE accepted client device... .LOCAL %s:%d REMOTE %s:%d\n", buf1, mio_getsckaddrport(&tcp->localaddr), buf2, mio_getsckaddrport(&tcp->remoteaddr)); MIO_INFO5 (tcp->mio, "DEVICE accepted client device... .LOCAL %s:%d REMOTE %s:%d\n",
buf1, mio_getsckaddrport(&tcp->localaddr), buf2, mio_getsckaddrport(&tcp->remoteaddr), tcp->sck);
} }
if (mio_dev_sck_write(tcp, "hello", 5, MIO_NULL, MIO_NULL) <= -1) if (mio_dev_sck_write(tcp, "hello", 5, MIO_NULL, MIO_NULL) <= -1)
@ -197,20 +196,29 @@ static int tcp_sck_on_write (mio_dev_sck_t* tcp, mio_iolen_t wrlen, void* wrctx,
if (wrlen <= -1) if (wrlen <= -1)
{ {
printf ("TCP_SCK_ON_WRITE SEDING TIMED OUT...........\n"); MIO_INFO1 (tcp->mio, "TCP_SCK_ON_WRITE(%d) >>> SEDING TIMED OUT...........\n", (int)tcp->sck);
mio_dev_sck_halt (tcp); mio_dev_sck_halt (tcp);
} }
else else
{ {
ts = (tcp_server_t*)(tcp + 1); ts = (tcp_server_t*)(tcp + 1);
printf ("TCP_SCK_ON_WRITE >>> SENT MESSAGE %d of length %ld\n", ts->tally, (long int)wrlen); if (wrlen == 0)
{
MIO_INFO1 (tcp->mio, "TCP_SCK_ON_WRITE(%d) >>> CLOSED WRITING END\n", (int)tcp->sck);
}
else
{
MIO_INFO3 (tcp->mio, "TCP_SCK_ON_WRITE(%d) >>> SENT MESSAGE %d of length %ld\n", (int)tcp->sck, ts->tally, (long int)wrlen);
}
ts->tally++; ts->tally++;
// if (ts->tally >= 2) mio_dev_sck_halt (tcp); // if (ts->tally >= 2) mio_dev_sck_halt (tcp);
printf ("TCP_SCK_ON_WRITE ENABLING READING..............................\n");
MIO_INIT_NTIME (&tmout, 5, 0); MIO_INIT_NTIME (&tmout, 5, 0);
//mio_dev_sck_read (tcp, 1); //mio_dev_sck_read (tcp, 1);
MIO_INFO3 (tcp->mio, "TCP_SCK_ON_WRITE(%d) >>> REQUESTING to READ with timeout of %ld.%08ld\n", (int)tcp->sck, (long int)tmout.sec, (long int)tmout.nsec);
mio_dev_sck_timedread (tcp, 1, &tmout); mio_dev_sck_timedread (tcp, 1, &tmout);
} }
return 0; return 0;
@ -223,19 +231,19 @@ static int x = 0;
if (len <= -1) if (len <= -1)
{ {
printf ("TCP_SCK_ON_READ STREAM DEVICE: TIMED OUT...\n"); MIO_INFO1 (tcp->mio, "TCP_SCK_ON_READ(%d) STREAM DEVICE: TIMED OUT...\n", (int)tcp->sck);
mio_dev_sck_halt (tcp); mio_dev_sck_halt (tcp);
return 0; return 0;
} }
else if (len <= 0) else if (len <= 0)
{ {
printf ("TCP_SCK_ON_READ STREAM DEVICE: EOF RECEIVED...\n"); MIO_INFO1 (tcp->mio, "TCP_SCK_ON_READ(%d) STREAM DEVICE: EOF RECEIVED...\n", (int)tcp->sck);
/* no outstanding request. but EOF */ /* no outstanding request. but EOF */
mio_dev_sck_halt (tcp); mio_dev_sck_halt (tcp);
return 0; return 0;
} }
printf ("TCP_SCK_ON_READ read %d\n", (int)len); MIO_INFO2 (tcp->mio, "TCP_SCK_ON_READ(%d) - received %d bytes\n", (int)tcp->sck, (int)len);
{ {
mio_ntime_t tmout; mio_ntime_t tmout;
@ -244,23 +252,24 @@ static char a ='A';
char* xxx = malloc (1000000); char* xxx = malloc (1000000);
memset (xxx, a++ ,1000000); memset (xxx, a++ ,1000000);
printf ("TCP_SCK_ON_READ initiating write... of %d\n", 1000000); MIO_INFO2 (tcp->mio, "TCP_SCK_ON_READ(%d) >>> REQUESTING to write data of %d bytes\n", (int)tcp->sck, 1000000);
//return mio_dev_sck_write (tcp, "HELLO", 5, MIO_NULL); //return mio_dev_sck_write (tcp, "HELLO", 5, MIO_NULL);
MIO_INIT_NTIME (&tmout, 5, 0); MIO_INIT_NTIME (&tmout, 5, 0);
n = mio_dev_sck_timedwrite(tcp, xxx, 1000000, &tmout, MIO_NULL, MIO_NULL); n = mio_dev_sck_timedwrite(tcp, xxx, 1000000, &tmout, MIO_NULL, MIO_NULL);
free (xxx); free (xxx);
if (n <= -1) return -1; if (n <= -1) return -1;
} }
printf ("TCP_SCK_ON_READ DISABLING READING..............................\n"); MIO_INFO1 (tcp->mio, "TCP_SCK_ON_READ(%d) - DISABLING READ\n", (int)tcp->sck);
mio_dev_sck_read (tcp, 0); mio_dev_sck_read (tcp, 0);
printf ("TCP_SCK_ON_READ WRITING 0.............................\n"); #if 0
MIO_INFO1 (tcp->mio, "TCP_SCK_ON_READ(%d) - REQUESTING TO CLOSE WRITING END\n", (int)tcp->sck);
/* post the write finisher - close the writing end */ /* post the write finisher - close the writing end */
n = mio_dev_sck_write(tcp, MIO_NULL, 0, MIO_NULL, MIO_NULL); n = mio_dev_sck_write(tcp, MIO_NULL, 0, MIO_NULL, MIO_NULL);
if (n <= -1) return -1; if (n <= -1) return -1;
#endif
return 0; return 0;

View File

@ -508,6 +508,9 @@
/* Define to 1 if you have the <stdlib.h> header file. */ /* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H #undef HAVE_STDLIB_H
/* strftime supports %z */
#undef HAVE_STRFTIME_SMALL_Z
/* Define to 1 if you have the <strings.h> header file. */ /* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H #undef HAVE_STRINGS_H

View File

@ -912,6 +912,7 @@ int mio_dev_ioctl (mio_dev_t* dev, int cmd, void* arg)
int mio_dev_watch (mio_dev_t* dev, mio_dev_watch_cmd_t cmd, int events) int mio_dev_watch (mio_dev_t* dev, mio_dev_watch_cmd_t cmd, int events)
{ {
mio_t* mio = dev->mio;
int mux_cmd; int mux_cmd;
int dev_capa; int dev_capa;
@ -1003,24 +1004,26 @@ static void on_read_timeout (mio_t* mio, const mio_ntime_t* now, mio_tmrjob_t* j
static int __dev_read (mio_dev_t* dev, int enabled, const mio_ntime_t* tmout, void* rdctx) static int __dev_read (mio_dev_t* dev, int enabled, const mio_ntime_t* tmout, void* rdctx)
{ {
mio_t* mio = dev->mio;
if (dev->dev_capa & MIO_DEV_CAPA_IN_CLOSED) if (dev->dev_capa & MIO_DEV_CAPA_IN_CLOSED)
{ {
dev->mio->errnum = MIO_ENOCAPA; mio_seterrbfmt (mio, MIO_ENOCAPA, "unable to read closed device");
return -1; return -1;
} }
if (enabled) if (enabled)
{ {
dev->dev_capa &= ~MIO_DEV_CAPA_IN_DISABLED; dev->dev_capa &= ~MIO_DEV_CAPA_IN_DISABLED;
if (!dev->mio->in_exec && (dev->dev_capa & MIO_DEV_CAPA_IN_WATCHED)) goto renew_watch_now; if (/*!mio->in_exec && */!(dev->dev_capa & MIO_DEV_CAPA_IN_WATCHED)) goto renew_watch_now;
} }
else else
{ {
dev->dev_capa |= MIO_DEV_CAPA_IN_DISABLED; dev->dev_capa |= MIO_DEV_CAPA_IN_DISABLED;
if (!dev->mio->in_exec && !(dev->dev_capa & MIO_DEV_CAPA_IN_WATCHED)) goto renew_watch_now; if (/*!mio->in_exec && */(dev->dev_capa & MIO_DEV_CAPA_IN_WATCHED)) goto renew_watch_now;
} }
dev->mio->renew_watch = 1; mio->renew_watch = 1;
goto update_timer; goto update_timer;
renew_watch_now: renew_watch_now:
@ -1031,7 +1034,7 @@ update_timer:
if (dev->rtmridx != MIO_TMRIDX_INVALID) if (dev->rtmridx != MIO_TMRIDX_INVALID)
{ {
/* read timeout already on the socket. remove it first */ /* read timeout already on the socket. remove it first */
mio_deltmrjob (dev->mio, dev->rtmridx); mio_deltmrjob (mio, dev->rtmridx);
dev->rtmridx = MIO_TMRIDX_INVALID; dev->rtmridx = MIO_TMRIDX_INVALID;
} }
@ -1046,7 +1049,7 @@ update_timer:
tmrjob.handler = on_read_timeout; tmrjob.handler = on_read_timeout;
tmrjob.idxptr = &dev->rtmridx; tmrjob.idxptr = &dev->rtmridx;
dev->rtmridx = mio_instmrjob(dev->mio, &tmrjob); dev->rtmridx = mio_instmrjob(mio, &tmrjob);
if (dev->rtmridx == MIO_TMRIDX_INVALID) if (dev->rtmridx == MIO_TMRIDX_INVALID)
{ {
/* if timer registration fails, timeout will never be triggered */ /* if timer registration fails, timeout will never be triggered */
@ -1060,32 +1063,6 @@ update_timer:
int mio_dev_read (mio_dev_t* dev, int enabled) int mio_dev_read (mio_dev_t* dev, int enabled)
{ {
return __dev_read(dev, enabled, MIO_NULL, MIO_NULL); return __dev_read(dev, enabled, MIO_NULL, MIO_NULL);
#if 0
if (dev->dev_capa & MIO_DEV_CAPA_IN_CLOSED)
{
dev->mio->errnum = MIO_ENOCAPA;
return -1;
}
if (enabled)
{
dev->dev_capa &= ~MIO_DEV_CAPA_IN_DISABLED;
if (!dev->mio->in_exec && (dev->dev_capa & MIO_DEV_CAPA_IN_WATCHED)) goto renew_watch_now;
}
else
{
dev->dev_capa |= MIO_DEV_CAPA_IN_DISABLED;
if (!dev->mio->in_exec && !(dev->dev_capa & MIO_DEV_CAPA_IN_WATCHED)) goto renew_watch_now;
}
dev->mio->renew_watch = 1;
return 0;
renew_watch_now:
if (mio_dev_watch(dev, MIO_DEV_WATCH_RENEW, 0) <= -1) return -1;
return 0;
#endif
} }
int mio_dev_timedread (mio_dev_t* dev, int enabled, const mio_ntime_t* tmout) int mio_dev_timedread (mio_dev_t* dev, int enabled, const mio_ntime_t* tmout)
@ -1247,7 +1224,7 @@ enqueue_data:
} }
MIO_WQ_ENQ (&dev->wq, q); MIO_WQ_ENQ (&dev->wq, q);
if (!dev->mio->in_exec && !(dev->dev_capa & MIO_DEV_CAPA_OUT_WATCHED)) if (!mio->in_exec && !(dev->dev_capa & MIO_DEV_CAPA_OUT_WATCHED))
{ {
/* if output is not being watched, arrange to do so */ /* if output is not being watched, arrange to do so */
if (mio_dev_watch(dev, MIO_DEV_WATCH_RENEW, 0) <= -1) if (mio_dev_watch(dev, MIO_DEV_WATCH_RENEW, 0) <= -1)
@ -1259,7 +1236,7 @@ enqueue_data:
} }
else else
{ {
dev->mio->renew_watch = 1; mio->renew_watch = 1;
} }
return 0; /* request pused to a write queue. */ return 0; /* request pused to a write queue. */