Re: comm_write(), write cancellations, etc

From: Henrik Nordstrom <henrik_at_henriknordstrom.net>
Date: Tue, 26 Aug 2008 00:31:32 +0200

On fre, 2008-08-22 at 23:16 +0800, Adrian Chadd wrote:

> I've been staring at the comm code in Squid-2 to get an idea of how to
> implement properly async copy-free network IO. Its tricky to say the
> least.

I have said it many times over the years in different words: Any data
should be stored in refcounted buffers, with no explicit owner defining
the lifetime, and at most a single owner who may allocate space in
unused areas of the buffer.

The buffer stays for as long as there is references to data in that
buffer. When the last reference dies the buffer is freed.

Approaches where I/O data buffers is embedded in other objects will
seriously restrict and complicate implementation, and also opens for
many cancellation corner cases which is very hard to debug.

It's very obvious on the write side, but just as real issue and very
very harmful on the read side as well. Network I/O is just one facet of
this, I/O between modules is just about the same problem especially when
you consider multi-threading stuff.

Regards
Henrik

Received on Mon Aug 25 2008 - 22:31:40 MDT

This archive was generated by hypermail 2.2.0 : Tue Aug 26 2008 - 12:00:07 MDT