doc/publican: stop excessive rebuilds

Traced down to the server/client target always rebuilding, causing a rebuild
of everything else. Rework this so the target name is a file we actually
produce and can check for a timestamp.

Note: this also changes the generated file from the doxygen directory into the
en-US publican path and renames it to (server|client)API.xml.tmp to avoid
copying it into the xml output directory.
wayland-client: Initialize newly created wl_proxys to zero

Up until now, newly created wl_proxys (with proxy_create or
wl_proxy_create_for_id) are not initialized properly after memory
allocation. The wl_display object in contrast is. To prevent giving
uninitialized data to the user (e.g. user_data) an appropriate memset
has been added. Also, after a memset members don't have to be
explicitly initialized with zero anymore.

Signed-off-by: Nils Chr. Brause <nilschrbrause@googlemail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
client: add display_wakeup_threads function

This helper function wraps the always-repeated pattern:

  display->read_serial++;
  pthread_cond_broadcast(&display->reader_cond);

[Pekka Paalanen: minor whitespace and comment fixes.]

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
display-test: make use of create_thread function

This function is used in one test only, but its functionality can be
used in another tests to (create thread and wait until it is sleeping).
We just need to pass the starting function for the thread as an argument.

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
doc: Quell warnings about missing man3 directory before its been built

The shell command for dist_man3_MANS gets invoked several times during
the make process but before the man pages have been generated, which
causes the following warnings when running `make`:

    find: `man/man3': No such file or directory
    find: `man/man3': No such file or directory
    find: `man/man3': No such file or directory
      GEN    xml/client/index.xml

Despite these error messages, the generated dist tarball contains the
man3 pages as intended, both before and after this patch.

    $ make dist
    $ tar xxf wayland-1.5.90.tar.xz
    $ find wayland-1.5.90/doc/doxygen/man/man3 -name "wl_*.3" | wc -l
    85

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
Acked-by: Peter Hutterer <peter.hutterer@who-t.net>
Tested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
configure.ac: bump version to 1.5.92 for rc1

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
tests: use nanosleep instead of usleep

man usleep says that bahaviour of using usleep with SIGALRM signal
is unspecified. So create our own usleep that calls nanosleep instead.

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
tests: add display test that highlights another bug in read_events

When wl_display_read_events() returns with errno == EAGAIN, we
naturally try to call it again. But this next call results in deadlock.

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
client: fix bug with display->reader_count < 0

If we will try call wl_display_read_events() again,
after we got EAGAIN from previous call, we get deadlock
as shown in test. The bug works like this: after first call
to wl_display_read_events() the display->reader_count is 0
and next call will decrease it to -1 so the thread will make
sleeping itself and we have a deadlock.

We have two options here:

Either we can wake up all threads before returning from
read_events() and thus force the programmer to do the whole
prepare+read loop again. Waking up all the threads could bring
unnecessary overhead.

The other solution, that I chose, is to return without waking up
the threads, so that programmer can try read again
- it feels natural after getting EAGAIN. Thus the proper use
of wl_display_read_events should look like:

    do {
        ret = wl_display_read_events(display);
    } while (ret == 0 && errno == EAGAIN);

The solution is simple. Before returning from read_events under
these circumstances, increase the display->reader_count back to 1,
so that next trial will have the same execution path as the one
before.

Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>