|
|
|
@ -7,6 +7,21 @@ void io_wantwrite_really(int64 d, io_entry* e);
|
|
|
|
|
|
|
|
|
|
int64 io_canwrite() {
|
|
|
|
|
io_entry* e;
|
|
|
|
|
|
|
|
|
|
#if defined(HAVE_SIGIO)
|
|
|
|
|
/* We promise that the user can call io_canread() and read, and
|
|
|
|
|
* the user uses io_tryread or calls io_eagain_read to signal if
|
|
|
|
|
* there is no more data to read. That means if the user does not
|
|
|
|
|
* call io_eagain_read, we need to know which fd it was so we can
|
|
|
|
|
* keep it in the alternative queue. */
|
|
|
|
|
if (alt_curwrite!=-1) {
|
|
|
|
|
e=iarray_get(&io_fds,alt_curwrite);
|
|
|
|
|
e->next_write=alt_firstwrite;
|
|
|
|
|
alt_firstwrite=alt_curwrite;
|
|
|
|
|
alt_curwrite=-1;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (first_writeable==-1)
|
|
|
|
|
#if defined(HAVE_SIGIO)
|
|
|
|
|
{
|
|
|
|
@ -46,9 +61,15 @@ int64 io_canwrite() {
|
|
|
|
|
#endif
|
|
|
|
|
) {
|
|
|
|
|
#if defined(HAVE_SIGIO)
|
|
|
|
|
#if 0
|
|
|
|
|
/* this code violates an invariant that the other code has, namely
|
|
|
|
|
* that e->next_read is -1 once the fd is dequeued. */
|
|
|
|
|
e->next_write=alt_firstwrite;
|
|
|
|
|
alt_firstwrite=r;
|
|
|
|
|
debug_printf(("io_canwrite: enqueue %ld in alt write queue (next is %ld)\n",alt_firstwrite,e->next_write));
|
|
|
|
|
#else
|
|
|
|
|
alt_curwrite=r;
|
|
|
|
|
#endif
|
|
|
|
|
if (io_waitmode!=_SIGIO)
|
|
|
|
|
#endif
|
|
|
|
|
e->canwrite=0;
|
|
|
|
|