Index: benchmark/io/http/worker.cfa
===================================================================
--- benchmark/io/http/worker.cfa	(revision 07997cd791b7a0e04d564b2c80dba2c524a0d108)
+++ benchmark/io/http/worker.cfa	(revision 3f95dab13f46929be6718df860c0fada67fb412c)
@@ -13,4 +13,6 @@
 #include "protocol.hfa"
 #include "filecache.hfa"
+
+static const unsigned long long period = 50_000_000;
 
 //=============================================================================================
@@ -95,5 +97,10 @@
 		// Send the desired file
 		int ret = answer_sendfile( this.pipe, fd, ans_fd, count, this.stats.sendfile );
-		if( ret == -ECONNRESET ) break REQUEST;
+		if(ret < 0) {
+			if( ret == -ECONNABORTED ) break REQUEST;
+			if( ret == -ECONNRESET ) break REQUEST;
+			if( ret == -EPIPE ) break REQUEST;
+			abort( "sendfile error: %d (%d) %s\n", ret, (int)errno, strerror(errno) );
+		}
 
 		if( options.log ) mutex(sout) sout | "=== Answer sent ===";
@@ -102,5 +109,5 @@
 	if (stats_thrd) {
 		unsigned long long next = rdtscl();
-		if(next > (last + 500000000)) {
+		if(next > (last + period)) {
 			if(try_lock(stats_thrd->stats.lock __cfaabi_dbg_ctx2)) {
 				push(this.stats.sendfile, stats_thrd->stats.send);
@@ -141,4 +148,6 @@
 		char buffer[len];
 		handle_connection( this.conn, fd, buffer, len, 0p, last );
+		this.conn.stats.sendfile.maxfd = max(this.conn.stats.sendfile.maxfd, fd);
+		this.conn.stats.sendfile.close++;
 
 		if( options.log ) mutex(sout) sout | "=== Connection closed ===";
@@ -162,4 +171,5 @@
 	/* paranoid */ assert( this.conn.pipe[0] != -1 );
 	/* paranoid */ assert( this.conn.pipe[1] != -1 );
+	this.conn.stats.sendfile.maxfd = max(this.conn.pipe[0], this.conn.pipe[1]);
 	for() {
 		size_t len = options.socket.buflen;
@@ -173,8 +183,14 @@
 		if( options.log ) mutex(sout) sout | "=== Waiting new connection ===";
 		handle_connection( this.conn, p.out.fd, buffer, len, &p.f, last );
+		if(this.done) break;
+		this.conn.stats.sendfile.maxfd = max(this.conn.stats.sendfile.maxfd, p.out.fd);
+		this.conn.stats.sendfile.close++;
 
 		if( options.log ) mutex(sout) sout | "=== Connection closed ===";
-		if(this.done) break;
-	}
+	}
+
+	lock(stats_thrd->stats.lock __cfaabi_dbg_ctx2);
+	push(this.conn.stats.sendfile, stats_thrd->stats.send);
+	unlock(stats_thrd->stats.lock);
 }
 
@@ -198,4 +214,5 @@
 
 static inline void push_connection( Acceptor & this, int fd ) {
+	this.stats.accepts++;
 	PendingRead * p = 0p;
 	for() {
@@ -212,5 +229,6 @@
 
 // #define ACCEPT_SPIN
-#define ACCEPT_MANY
+#define ACCEPT_ONE
+// #define ACCEPT_MANY
 
 void main( Acceptor & this ) {
@@ -232,5 +250,4 @@
 			abort( "accept error: (%d) %s\n", (int)errno, strerror(errno) );
 		}
-		this.stats.accepts++;
 
 		if(this.done) return;
@@ -242,5 +259,35 @@
 		if (stats_thrd) {
 			unsigned long long next = rdtscl();
-			if(next > (last + 500000000)) {
+			if(next > (last + period)) {
+				if(try_lock(stats_thrd->stats.lock)) {
+					push(this.stats, stats_thrd->stats.accpt);
+					unlock(stats_thrd->stats.lock);
+					last = next;
+				}
+			}
+		}
+
+		if( options.log ) sout | "=== Accepting connection ===";
+	}
+
+#elif defined(ACCEPT_ONE)
+	if( options.log ) sout | "=== Accepting connection ===";
+	for() {
+		int fd = cfa_accept4(this.sockfd, this.[addr, addrlen, flags], 0);
+		if(fd < 0) {
+			if( errno == ECONNABORTED ) break;
+			if( this.done && (errno == EINVAL || errno == EBADF) ) break;
+			abort( "accept error: (%d) %s\n", (int)errno, strerror(errno) );
+		}
+
+		if(this.done) return;
+
+		if( options.log ) sout | "=== New connection" | fd | "" | ", waiting for requests ===";
+
+		if(fd) push_connection(this, fd);
+
+		if (stats_thrd) {
+			unsigned long long next = rdtscl();
+			if(next > (last + period)) {
 				if(try_lock(stats_thrd->stats.lock)) {
 					push(this.stats, stats_thrd->stats.accpt);
@@ -269,5 +316,5 @@
 		if (stats_thrd) {
 			unsigned long long next = rdtscl();
-			if(next > (last + 500000000)) {
+			if(next > (last + period)) {
 				if(try_lock(stats_thrd->stats.lock __cfaabi_dbg_ctx2)) {
 					push(this.stats, stats_thrd->stats.accpt);
@@ -284,5 +331,4 @@
 				int fd = get_res(res);
 				reset(res);
-				this.stats.accepts++;
 				if(fd < 0) {
 					if( errno == ECONNABORTED ) continue;
@@ -319,3 +365,6 @@
 #error no accept algorithm specified
 #endif
-}
+	lock(stats_thrd->stats.lock);
+	push(this.stats, stats_thrd->stats.accpt);
+	unlock(stats_thrd->stats.lock);
+}
