[PULL wayland] fd leak checks and a socket fallback

Thiago Macieira thiago.macieira at intel.com
Mon Apr 23 05:10:00 PDT 2012

On segunda-feira, 23 de abril de 2012 11.22.16, Pekka Paalanen wrote:
> > PS: if you're reading this and you want to run Wayland on your non-Linux 
> > system, you should also add those to your OS. Yesterday.
> Hi Thiago,
> you speak with the voice of reason. Unfortunately, I doubt reason or
> sanity is something to be strongly associated with Android. I'm not
> ready take on such battle for now.

Well, they said that bionic was a stripped-down version of libc, sometimes 
deviating from POSIX, and it would only be used to support Android's own 

However, since Android is heavily based on Java, which in turn encourages the 
use of threads for everything, I really can't see how they can write the C 
backends for those libraries without the thread-safe system calls. In fact, I 
was quite surprised no one had thought of that before Ulrich Drepper came up 
with them back in 2008.

In any case, while on Linux, the constants are cross-architecture, so you can 
#define them if they weren't before. If the libc doesn't provide the system 
calls, there are workarounds:

 1) open & socket - no new system call required, just a new constant
 2) dup3 - just use F_DUPFD_CLOEXEC, which we do in Wayland
 3) pipe2, accept4, eventfd2, epoll_create1, etc. - can use syscall:
	syscall(__NR_accept4, fd, &addr, &addrlen, SOCK_CLOEXEC);

Option 3 is unavailable if bionic doesn't provide the syscall(3) function. I'd 
say that writing assembly to make the system call is above the pain threshold 
for solving this particular issue. In that case, we can point the finger at 
them and say "it's not thread-safe and it's entirely your fault".

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center
     Intel Sweden AB - Registration Number: 556189-6027
     Knarrarnäsgatan 15, 164 40 Kista, Stockholm, Sweden
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20120423/11be424b/attachment.pgp>

More information about the wayland-devel mailing list