]> code.delx.au - pulseaudio/commit
fdsem: Remember pa_write() type in pa_fdsem_post()
authorPeter Meerwald <p.meerwald@bct-electronic.com>
Tue, 9 Apr 2013 14:10:16 +0000 (16:10 +0200)
committerArun Raghavan <arun.raghavan@collabora.co.uk>
Mon, 3 Jun 2013 19:08:40 +0000 (00:38 +0530)
commit8336078afac0375f14a3ef91e8a3d31655ea5ff4
tree631f3c6b338531da061b159b8b662e21613d1883
parent5237bab36e22341dd25a5aa61f906748779c750e
fdsem: Remember pa_write() type in pa_fdsem_post()

pa_write() knows two types of operation:
calling send() and calling write()

there is a flag (a pointer to an int) passed to pa_write()
which can remember which write type was successful

if the pointer is NULL or the int is 0, send() is tried first,
with a fallback to write() if send() resulted in ENOTSOCK

pa_fdsem_post() calls pa_write() with a NULL pointer;
unfortunately (at least with HAVE_SYS_EVENTFD_H #define'd) send()
always fails here and write() is called -- causing an extra syscall
quite frequently

strace:
send(17, "\1\0\0\0\0\0\0\0", 8, MSG_NOSIGNAL) = -1 ENOTSOCK (Socket operation on non-socket)
write(17, "\1\0\0\0\0\0\0\0", 8) = 8

the patch adds a write_type field to pa_fdsem to the successful
pa_write() type can be remembered and unnecessary send() calls are
avoided

Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
src/pulsecore/fdsem.c