diff --git a/src/internal/toksvc_log_impl.c b/src/internal/toksvc_log_impl.c index b6a9cbb..2d4e8fb 100644 --- a/src/internal/toksvc_log_impl.c +++ b/src/internal/toksvc_log_impl.c @@ -64,6 +64,7 @@ static int32_t toks_log_write_impl( void * hevent; int fdtype; nt_iosb iosb; + const char * ch; /* size */ if (size >= 0x80000000) @@ -73,6 +74,7 @@ static int32_t toks_log_write_impl( hevent = toks_get_driver_hevent(dctx); rtdata = toks_get_driver_rtdata(dctx); hlog = rtdata->hlog; + ch = buf; /* hio, io type */ if (hlog) { @@ -92,26 +94,26 @@ static int32_t toks_log_write_impl( : toks_ntapi->zw_write_file; /* iowrite */ - status = iofn( - hio,hevent, - 0,0,&iosb, - (void *)buf,size, - 0,0); - - /* todo: flush */ - switch (status) { - case NT_STATUS_PENDING: - status = toks_ntapi->zw_wait_for_single_object( + do { + iosb.status = NT_STATUS_PENDING; + + status = iofn( + hio,hevent, + 0,0,&iosb, + (void *)ch, + size,0,0); + + if (status == NT_STATUS_PENDING) + toks_ntapi->zw_wait_for_single_object( hevent,0,0); - break; - default: - iosb.status = status; - break; - } + size -= iosb.info; + ch += iosb.info; + } while (size && (iosb.status == NT_STATUS_SUCCESS)); + /* ret */ - return iosb.status ? iosb.status : iosb.info; + return iosb.status; } void toks_log_header(