cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: binding to --interface

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Tue, 23 Mar 2004 15:46:21 +0100 (CET)

On Tue, 23 Mar 2004, Gisle Vanem wrote:

> But on Linux it just prints a warning if setsockopt(..SO_BINDTODEVICE)
> fails. This seems inconsistent. IMHO, the bindlocal() function should just
> fail.

The situation is more complicated than that. It still binds to the interface,
it just doesn't bind "as hard" as it would've done if SO_BINDTODEVICE would've
worked. Try it on a machine with multiple network interfaces and you'll see!

> But below is a patch to give meaningful errno handling for all.

Nice, thanks!

> BTW. Is the use of strerror (fortunately only in ftp.c) thread-safe on most
> platforms? Can't we just print the value from Curl_ourerrno() as we do most
> other places?

I thought about that too. The switch you patch here looks a bit stupid to have
just for this purpose. We should either use strerror() or provide a working
internal strerror()-replacement.

... and based on the POSIX 1003.1 document[*] IT IS NOT guaranteed to be
thread-safe:

  "The strerror() function need not be reentrant. A function that is not
  required to be reentrant is not required to be thread-safe."

That document proceeds to describe the strerror_r() function which supposedly
is the thread-safe vesion of strerror(). I have no idea how wide-spread the
support for this function is, so I figure we should provide our own internal
replacement anyway and add a check for strerror_r() in the configure script
and use that if available.

You feel like writing a patch for this? ;-) (The patch you just provided has
been applied and committed.)

[*] = http://www.opengroup.org/onlinepubs/007904975/functions/strerror.html

-- 
     Daniel Stenberg -- http://curl.haxx.se -- http://daniel.haxx.se
      Dedicated custom curl help for hire: http://haxx.se/curl.html
Received on 2004-03-23