cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Strange behavior with multi-interface and async DNS-resolve on windows

From: Christian Hägele <haegele_at_teamviewer.com>
Date: Mon, 17 Oct 2011 08:48:55 +0000 (UTC)

Daniel Stenberg <daniel <at> haxx.se> writes:

> Does it really cause any harm?

It doesn't cause any real harm. As the title says it's strange behavior,
because that socket is a dummy-socket.
I looked for hours in my code to find the mistake I made until I came up with
the reason for this dummy-socket.
Now I just ignore the socket and the problem is solved that way.
 
> Aren't all sockets libcurl informs it about "never heard of" until it tells
> the app about them?

Not when you use the CURLOPT_OPENSOCKETFUNCTION and
CURLOPT_CLOSESOCKETFUNCTION. I create a map with some additional information
when a socket is created. And the dummy-socket is, opposed to all other
sockets, not found in my map.
Maybe my design is a bit strange, but as I mentioned in an earlier post I can't
think of a better design when using boost::asio on windows (using IOCP) with
the curl multi-interface.
 
> I think excluding this socket from that system might be more complicated than
> including it, and since it won't ever have "traffic" it shouldn't be much of
> a problem.

That's totally your decision. But I am sure a lot of programmers wonder what
this socket is about. And the fastest code is the code never called. Right now
the callback is always called twice with a dummy socket.
 
> > In multi.c multi_getsock when the state is CURLM_STATE_WAITRESOLVE the
> > dummy-sock is pulled out and added to the observed sockets, but this is not
> > necessary when using a separate thread for async DNS-resolve (as described
> > above on windows).
>
> I think that's exactly what the comment about is about.
>
> How important that comment and its effects are, is another matter. Did you
> try just removing it to see what kind of impact you get on your application?

I did not dig that deep into the implementation, yet. Maybe I give it a try,
because I can think of better workarounds for the empty fd_set than creating a
dummy-socket as a member where no action will ever be on.
Right now I am only using the mult-interface on windows and don't have the
overview over the whole library, thus can't judge how important workaround for
some cases are.

Regards,

Christian

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-10-17