Subject: Re: [PATCH 1/4] ares_cancel(): ensure cancellation of all requests

Re: [PATCH 1/4] ares_cancel(): ensure cancellation of all requests

From: Tommie Gannert <tommie_at_spotify.com>
Date: Thu, 21 Mar 2013 11:45:41 +0100

2013/3/21 Alexander Klauer <Alexander.Klauer_at_itwm.fraunhofer.de>:
> An invocation of ares_cancel() walks through the request list, calling
> the callbacks of all pending requests on a channel. Previously, if such
> a callback added a new request to the channel, the request list might
> not end up empty, causing an abort by assertion failure. The present
> commit ensures that all such newly added requests are cancelled
> immediately and make it never into request list. Thus, the crash is
> avoided, and it is made certain that upon return of ares_cancel(), there
> are no requests whatsoever on the channel.

There are two possible contracts I could see for this:

 1) ares_cancel() guarantees that all active requests when entering the
    function will be cancelled.
 2) ares_cancel() guarantees there are no active requests when the
    function exits.

The patch clearly implements (2). What are your thoughts on semantics here?
I've never had to use ares_cancel(), so I don't know if it currently states (2).

Personally, I would find it somewhat surprising if I couldn't create
new requests
within an ares_cancel()-executed callback, and would prefer (1).

-- 
Tommie
Received on 2013-03-21