diff --git a/src/common.h b/src/common.h index c00495f..f95a8e2 100644 --- a/src/common.h +++ b/src/common.h @@ -235,6 +235,7 @@ typedef struct notifier { void init_notifier( notifier_t *sn, int fd, void (*cb)( int, void * ), void *aux ); void conf_notifier( notifier_t *sn, short and_events, short or_events ); +short notifier_config( notifier_t *sn ); void wipe_notifier( notifier_t *sn ); typedef struct { diff --git a/src/socket.c b/src/socket.c index b7b6fc2..0599aba 100644 --- a/src/socket.c +++ b/src/socket.c @@ -884,7 +884,6 @@ do_queued_write( conn_t *conn ) return -1; if (n != (int)len) { conn->write_offset += (uint)n; - conn->writing = 1; return 0; } conn->write_offset = 0; @@ -894,7 +893,6 @@ do_queued_write( conn_t *conn ) if (conn->ssl && SSL_pending( conn->ssl )) conf_wakeup( &conn->ssl_fake, 0 ); #endif - conn->writing = 0; conn->write_callback( conn->callback_aux ); return -1; } @@ -1103,7 +1101,7 @@ socket_fake_cb( void *aux ) /* Ensure that a pending write gets queued. */ do_flush( conn ); /* If no writes are ongoing, start writing now. */ - if (!conn->writing) + if (!(notifier_config( &conn->notify ) & POLLOUT)) do_queued_write( conn ); } diff --git a/src/socket.h b/src/socket.h index bcc7fe1..5334a89 100644 --- a/src/socket.h +++ b/src/socket.h @@ -103,7 +103,6 @@ typedef struct { /* writing */ buff_chunk_t *append_buf; /* accumulating buffer */ buff_chunk_t *write_buf, **write_buf_append; /* buffer head & tail */ - int writing; #ifdef HAVE_LIBZ uint append_avail; /* space left in accumulating buffer */ #endif diff --git a/src/util.c b/src/util.c index c6c597c..a4ee67d 100644 --- a/src/util.c +++ b/src/util.c @@ -704,6 +704,16 @@ conf_notifier( notifier_t *sn, short and_events, short or_events ) #endif } +short +notifier_config( notifier_t *sn ) +{ +#ifdef HAVE_SYS_POLL_H + return pollfds[sn->index].events; +#else + return sn->events; +#endif +} + void wipe_notifier( notifier_t *sn ) {