Quells a doxygen warning:
src/wayland-server.c:790: warning: argument 'None' of command @param is
not found in the argument list of wl_display::wl_display_create(void)
Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Use $XDG_RUNTIME_DIR/wayland-tests for tests. This way we won't be
messing XDG_RUNTIME_DIR and it also fixes a bug, when socket-test
failed when another compositor was running.
Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Giulio Camuffo <giuliocamuffo@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Ensure that the round trip succeeds.
Signed-off-by: Philip Withnall <philip at tecnocode.co.uk>
Signed-off-by: Karsten Otto <ottoka at posteo.de>
Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This happens on EOF if using a poll function such as select() or
kqueue() which doesn’t distinguish EOF events.
Currently execution should never reach the point where recvmsg() returns
EOF (len == 0). Instead, epoll() will detect this and indicate EPOLLHUP,
which is handled a few lines above, closing the connection. However,
other event mechanisms may not be able to distinguish EOF from regular
readability (in the case of select()) or inconsistently across platforms
(in the case of POLLHUP). There is also the possibility of half-closed
connections (shutdown(), POLLRDHUP), though this may not be an issue
with Wayland.
This will not cause problems if the FD polls as readable but actually is
not — in that case, recvmsg() will return EAGAIN.
Signed-off-by: Philip Withnall <philip at tecnocode.co.uk>
Signed-off-by: Karsten Otto <ottoka at posteo.de>
Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Signed-off-by: Philip Withnall <philip at tecnocode.co.uk>
Signed-off-by: Karsten Otto <ottoka at posteo.de>
Reviewed-by: David Fort <contact at hardening-consulting.com>
Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
It expects ((msg_controllen == 0) == (msg_control == NULL)), and returns
EINVAL otherwise. It can't hurt to be tidy about things on other platforms
either though.
See: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=99356#c5
Signed-off-by: Philip Withnall <philip at tecnocode.co.uk>
Signed-off-by: Karsten Otto <ottoka at posteo.de>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Calling close() on the same file descriptor that a previous call to
close() already closed is wrong, and racy if another thread received
that same file descriptor as a eg. new socket or actual file.
There are two situations where wl_connection_destroy() would close its
file descriptor and then another function up in the call chain would
close the same file descriptor:
* When wl_client_create() fails after calling wl_connection_create(),
it will call wl_connection_destroy() before returning. However, its
caller will always close the file descriptor if wl_client_create()
fails.
* wl_display_disconnect() unconditionally closes the display file
descriptor and also calls wl_connection_destroy().
So these two seem to expect wl_connection_destroy() to leave the file
descriptor open. The other caller of wl_connection_destroy(),
wl_client_destroy(), does however expect wl_connection_destroy() to
close its file descriptor, alas.
This patch changes wl_connection_destroy() to indulge this majority of
two callers by simply not closing the file descriptor. For the benefit
of wl_client_destroy(), wl_connection_destroy() then returns the
unclosed file descriptor so that wl_client_destroy() can close it
itself.
Since wl_connection_destroy() is a private function called from few
places, changing its semantics seemed like the more expedient way to
address the double-close() problem than shuffling around the logic in
wl_client_create() to somehow enable it to always avoid calling
wl_connection_destroy().
Signed-off-by: Benjamin Herr <ben@0x539.de>
Reviewed-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Doxygen represents all spacing in code blocks with <sp/> tags, so these
need to be turned back into spaces.
Signed-off-by: Benjamin Herr <ben@0x539.de>
xsl:value-of would strip all the nested markup of the selected doxygen
elements, so that \ref, \sa and \code formatting didn't actually work.
Signed-off-by: Benjamin Herr <ben@0x539.de>
These blocks were misformatted in normal paragraph style in the
generated docs. Also, added \comment{} for comments within one code
example.
Signed-off-by: Benjamin Herr <ben@0x539.de>
On the interfaces where it was missing:
- wl_data_device
- wl_shell
- wl_pointer
add an error code for requests that set a wl_surface role when the
wl_surface already has a different role.
This is needed for compositors to appropriately report wl_surface
role violations.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
Acked-by: Jason Ekstrand <jason.ekstrand@intel.com>
Now that we have defined "role", use the term.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Reword the conditions to make use of the definition of "role".
It is still forbidden to create more than one wl_subsurface for a
wl_surface at a time.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Now that we have defined "role", use the term.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Now that we have defined "role", use the term.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Define what a role is, and what restrictions there are.
A change to existing behaviour is that a role cannot be changed at all
once set. However, this is unlikely to cause problems, as there is no
reason to re-use wl_surfaces in clients.
v2: give more concrete examples of roles, define losing a role, Jasper
rewrote the paragraph on how a role is set.
v3: make role permanent, there is no such thing as "losing a role".
Re-issuing the same role again must be allowed for wl_pointer.set_cursor
et al. to work.
v4: clarify the semantics of destroying a role object.
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
Publican isn't packaged for some distros, xmlto is a lot more common. Most of
what publican provides for us is the stylesheet anyway, so we can just use
xmlto and the publican stylesheet to get roughly the same look.
PDF and XML generation has been dropped, this needs a bit more more effort
than a mere switchover to xmlto.
The top-level directory structure imposed by publican is kept for now
(specifically the Wayland/en-US/html tree). This makes it easier to transition over
for packagers. Note that the list of files inside has changed.
CSS files are taken from publican to keep a uniform look compared to previous
documentations. Stylesheets are licensed under CC0 1.0 Universal license, see
publican/LICENSE:
1. Files in the datadir/Common_Content directory and its subdirectories are
licensed under the CC0 1.0 Universal license.
To the extent possible under law, the developers of Publican waive all
copyright and related or neighboring rights to the files contained
in the datadir/Common_Content directory and its subdirectories.
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Calling wl_display_read_events() after an error should be equivalent
to wl_display_cancel_read(), so that display state is consistent.
Thanks to Pekka Paalanen <pekka.paalanen@collabora.co.uk>
for pointing that out.
Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
If wl_connection_read returned EAGAIN, we must wake up sleeping
threads. If we don't do this and the thread calling
wl_connection_read won't call wl_display_read_events again,
the sleeping threads will sleep indefinitely.
Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
When wl_connection_read() in wl_display_read_events() returns with EAGAIN,
we want the sleeping threads to be woken up. Test it!
Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
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>
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>
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>
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>
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>
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.
This prevents from blocking shown in one display test. Also, it
makes sense to not proceed further in the code of the function
when an error ocurred.
v2. set errno
put note about the errno into wl_display_prepare_read doc
check for error with mutex locked
v3.
set errno to display->last_error
check for the error only in wl_display_read_events. It's sufficient
as prevention for the hanging and programmer doesn't need to
check if wl_display_prepare_read (that was previously covered by
this patch too) returned an error or the queue just was not empty.
Without the check, it could result in indefinite looping.
Thanks to Pekka Paalanen <pekka.paalanen@collabora.co.uk> for
constant reviewing and discussing this patch.
Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
In previous commit we removed unused variables. One of them was
pthread_cond_t that was formerly used when reading from display, but
later was (erroneously) made unused. This patch fixes this error
and is a fix for the failing test introduced few patches ago (tests:
test if thread can block on error)
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
The wl_event_queue cond variable has been replaced by the wl_display
reader_cond variable (commit 3c7e8bfbb4).
This cond variable is never waited for anymore, just
signaled/broadcasted, and thus can be safely removed.
The wl_display event_queue_list and link from wl_event_queue
can be removed as well, since it was only used to iterate over
the event queue list in order to broadcast the now unused cond.
No regression on queue unit tests.
Signed-off-by: Olivier Blin <olivier.blin@softathome.com>
v2: fixed and rebased after 886b09c9a3
added signed-off-by
v3: removed link from wl_event_queue
Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This test shows that it's possible to successfully call wl_display_prepare_read
and wl_display_read_events after an error occurred. That may lead to
deadlock.
When you call prepare read from two threads and then call read_events,
one thread gets sleeping. The call from the other thread will return -1 and invokes
display_fatal_error, but since
we have display->last_error already set, the broadcast is not called and
the sleeping thread sleeps indefinitely.
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
wl_display_read_events() can make a thread wait until some other thread
ends reading. Normally it wakes up all threads after the reading is
done. But there's a place when it does not get to waking up the threads
- when an error occurs. This test reveals bug that can block programs.
If a thread is waiting in wl_display_read_events() and another thread
calls wl_display_read_events and the reading fails,
then the sleeping thread is not woken up. This is because
display_handle_error is using old pthread_cond instead of new
display->reader_cond, that was added along with wl_display_read_events().
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Most of the code of the queue-test is covered by the test compositor,
so we can save few lines and use the test compositor instead.
I think it's also more readable.
This patch removes timeout from the test. We plan to add timeout
to all tests later, though.
v2.
rebased to master
Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This patch introduces a set of functions that can create a display
and clients for tests.
On server side the user can use functions:
display_create()
display_destroy()
create_client()
display_run()
display_resume()
and on client side the user can use:
client_connect()
client_disconnect()
stop_display()
The stop_display() and display_resume() are functions that serve as a barrier
and also allow the display to take some action after the display_run() was called,
because after the display is stopped, it can run arbitrary code until it calls
display_resume().
client_connect() function connects to wayland display and creates a proxy to
test_compositor global object, so it can ask for stopping the display later
using stop_display().
An example:
void
client_main()
{
/* or client can use wl_display_connect(NULL)
* and do all the stuff manually */
struct client *c = client_connect();
/* do some stuff, ... */
/* stop the display so that it can
* do some other stuff */
stop_display(c, 1);
/* ... */
client_disconnect(c);
}
TEST(dummy_tst)
{
struct display *d = display_create();
/* set up the display */
wl_global_create(d->wl_display, ...);
/* ... */
create_client(d, client_main);
display_run();
/* if we are here, the display has been stopped
* and we can do some code, i. e. create another global or so */
wl_global_create(d->wl_display, ...);
/* ... */
display_resume(d); /* resume display and clients */
display_destroy(d);
}
v2:
added/changed message in few asserts that were not clear
fixed codying style issues and typo
client_create_with_name: fixed a condition in an assert
get_socket_name: use also pid
check_error: fix errno -> err
[Pekka Paalanen: added test-compositor.h to SOURCES, added
WL_HIDE_DEPRECATED to get rid of deprecated defs and lots of warnings,
fixed one unchecked return value from write().]
Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
display_thread variable is unused since
3c7e8bfbb4
Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Earlier, the wl_display_dispatch_pending were setting number of thread
that can dispatch events. This behaviour was removed later,
so now these lines are redundant.
Related commits:
385fe30e8b78cfa967683c7e8bfbb4
Signed-off-by: Marek Chalupa <mchqwerty@gmail.com>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>