فهرست منبع

drop redundant conn->writing member

this information is already encoded in the socket notifier's config.
Oswald Buddenhagen 5 سال پیش
والد
کامیت
c391b06b07
4فایلهای تغییر یافته به همراه12 افزوده شده و 4 حذف شده
  1. 1 0
      src/common.h
  2. 1 3
      src/socket.c
  3. 0 1
      src/socket.h
  4. 10 0
      src/util.c

+ 1 - 0
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 {

+ 1 - 3
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 );
 }
 

+ 0 - 1
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

+ 10 - 0
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 )
 {