Commit Graph

1518 Commits

Author SHA1 Message Date
Jonas Ådahl
6b66034268 doc: Remove deprecated doxygen tag
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-05-09 14:29:36 -07:00
Jonas Ådahl
591f5ee3b1 event-loop-test: Remove unused variable
Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
2014-05-09 14:29:27 -07:00
Srivardhan Hebbar
cde83a24b3 doc: Added API documentation for wl_display_create function.
Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com>
2014-05-09 12:44:32 -07:00
U. Artie Eoff
0f23b73a06 server: fix potential memleak and NULL deref
If for some reason that errno is neither value (ENOMEM or
EINVAL), then prior to this patch, there would be a NULL
deref in wl_closure_lookup(...) at the "else if" conditional
when closure == NULL. Also, closure might not be NULL but still
fall into the block due to the wl_closure_lookup < 0 condition...
in that case, we need to destroy the closure to avoid a memory
leak.

Currently, wl_connection_demarshal only sets errno to ENOMEM
or EINVAL... we've already checked for ENOMEM so remove check
for EINVAL (just assume it).  Also, call wl_closure_destroy(...)
unconditionally in the "else if" block (assume it can handle
NULL closure, too, which it does right now).

Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-05-06 15:00:31 -07:00
U. Artie Eoff
b41ded812d connection-test: check malloc result
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-05-06 14:59:33 -07:00
U. Artie Eoff
7a17b05187 scanner: check wl_array_add result
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
2014-05-06 14:57:35 -07:00
Kristian Høgsberg
4a4523fa92 configure.ac: Bump version to 1.4.92 2014-05-01 13:44:09 -07:00
Kristian Høgsberg
88f3bd84c8 Avoid printing to stderr
Use wl_log in the last few places where we print to stderr.  Remove
logging in a couple of places where we properly return an error code.

https://bugs.freedesktop.org/show_bug.cgi?id=73339
2014-04-30 12:18:52 -07:00
Andrew Wedgbury
3e962728bf Use non-blocking timerfd to prevent blocking when updating timer event sources
This implements a simple fix for the blocking problem that occurs when
updating a timer event source after the timer expires, but before its
callback is dispatched. This can happen when another event happens during the
same epoll wakeup as the timer event, and causes the read() call in
wl_event_source_timer_dispatch() to block for the updated duration of the
timer.

We never want this read() call to block, so I believe it makes sense for the
timerfd to be non-blocking, and we simply ignore the case where the read fails
with EAGAIN. We still report all other errors as before, and still ignore the
actual value read from the socket.

With this change, the event_loop_timer_updates unit test case I submitted
previously now passes, and weston appears to work as before.
2014-04-25 14:38:22 -07:00
Andrew Wedgbury
74df22befe test: Add test showing blocking problem when updating timers
I've noticed a blocking problem in Wayland's event-loop code when updating
timer event sources. The problem occurs if you update the timer at a point
after is has expired, but before it has been dispatched, i.e. from an event
callback that happens during the same epoll wakeup.

When the timer is subsequently dispatched, wl_event_source_timer_dispatch
blocks for the duration of the new timeout in its call to read() from the
timer fd (which is the expected behaviour according to the man page for
timerfd_settime).

This isn't too uncommon a scenario - for example, a socket with an associated
timeout timer. You'd typically want to update the timer when reading from the
socket. This is how I noticed the issue, since I was setting a timeout of
1 minute, and saw my server blocking for this duration!

The following patch adds a (currently failing) test case to Wayland's
event-loop-test.c. It demonstrates the problem using two timers, which are
set to expire at the same time. The first timer to receive its expiry
callback updates the other timer with a much larger timeout, which then
causes the test to block for this timeout before calling the second timer's
callback.

As for a fix, I'm not so sure (which is why I thought I'd post the failing
test case first to show what I mean). I notice that it doesn't actually do
anything with the value read from the timerfd socket, which gives the number
of times the timer expired since the last read, or when the timer was last
updated (which blocks if the timer hasn't yet expired). I believe this value
should always read as 1 anyway, since we don't use periodic timers.

A simple fix would be to use the TFD_NONBLOCK option when creating the
timerfd, ensuring that the read call won't block. We'd then have to ignore
the case when the read returns EAGAIN.
2014-04-25 14:08:31 -07:00
Giulio Camuffo
5535757a40 connection: fix a format string typo in error message 2014-04-25 13:28:19 -07:00
Ander Conselvan de Oliveira
bfc93649cb connection: Don't write past the end of the connection buffer
If a message was too big to fit in the connection buffer, the code
in wl_buffer_put would just write past the end of it.

I haven't seen any real world use case that would trigger this bug, but
it was possible to trigger it by sending a long enough string to the
wl_data_source.offer request.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=69267
2014-04-21 14:51:42 -07:00
Kristian Høgsberg
5e2cfd2a0a configure.ac: Bump version to 1.4.91 2014-04-07 16:08:42 -07:00
Kristian Høgsberg
24cdbe3d69 shm: Disallow shrinking shm pools
Unused shm space will be automatically reclaimed if unused or can be
explicitly returned by using fallocate FALLOC_FL_PUNCH_HOLE.

https://bugs.freedesktop.org/show_bug.cgi?id=74632
2014-04-07 16:01:25 -07:00
Kristian Høgsberg
c1aa1291a1 scanner: Only output each forward declaration once
Just sort the types and only print unique type names.  We avoid using
the GCC pragma.
2014-04-03 15:58:06 -07:00
Kristian Høgsberg
00703ad2bc Add WL_PRINTF attribute and annotate wl_log_func_t 2014-04-03 14:18:45 -07:00
Rui Matos
2142c03a8b protocol: Document how clients are supposed to get the xkb keycode
This encodes what everyone is doing and avoids other implementers
having to guess.
2014-04-01 16:47:04 -07:00
Hardening
256324773f Add error handling for wl_cursors
This patch adds some error management in wayland cursors

Reviewed-by: Bryce Harrington <b.harrington@samsung.com>
2014-04-01 16:47:04 -07:00
Kristian Høgsberg
051f3838de client: Delay EPIPE handling so we get a chance to handle error events 2014-03-26 13:28:27 -07:00
Jasper St. Pierre
1bf13ae918 server: Kill some unnecessary logs
In order to set a logging function all the time, the output we get
needs to be useful. Logging about trivial things like the socket
we're using and when clients disconnect doesn't realy help anyone.
2014-03-25 09:50:09 -07:00
Bryce W. Harrington
3adcf6f11b tests: Fix build of noinst fixed-benchmark test
Solves this build error:

  tests/fixed-benchmark.o: In function `benchmark':
  ./wayland/tests/fixed-benchmark.c:82: undefined reference to `clock_gettime'
  ./wayland/tests/fixed-benchmark.c:84: undefined reference to `clock_gettime'

Signed-off-by: Bryce Harrington <b.harrington@samsung.com>
2014-03-11 09:20:27 -07:00
Pekka Paalanen
2c319d341b protocol: try to clarify frame callback semantics
"the callback event will arrive after the next output refresh" is wrong,
if you interpret "output refresh" as framebuffer flip or the moment when
the new pixels turn into light the first time. Weston has probably never
worked this way.

Weston triggers the frame callbacks when it submits repainting commands
to the GPU, which is before the framebuffer flip.

Strike the incorrect claim, and the rest of the paragraph which no
longer offers useful information.

As a replacement, expand on the "throttling and driving animations"
characteristic. The main purpose is to let clients animate at the
display refresh rate, while avoiding drawing frames that will never be
presented.

The new claim is that the server should give some time between
triggering frame callbacks and repainting itself, for clients to draw
and commit. This is somewhat intimate with the repaint scheduling
algorithm a compositor uses, but hopefully the right intention.

Another point of this update is to imply, that frame callbacks should
not be used to count compositor repaint cycles nor monitor refresh
cycles. It has never been guaranteed to work. Removing the mention of
frame callback without an attach hopefully discourages such use.

v2: Don't just remove a paragraph, but add useful information about the
request's intent.

v3: Specify the order of posting frame callbacks.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Cc: Axel Davy <axel.davy@ens.fr>
Cc: Jason Ekstrand <jason@jlekstrand.net>
2014-03-11 09:09:55 -07:00
Pekka Paalanen
9cfffffe07 update .gitignore
Makes 'git status' clean again after a successful 'make distcheck'.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-03-10 13:11:09 -07:00
Pekka Paalanen
52a531b4df build: hide doxygen commands with AM_V_GEN
I suppose the purpose was to print just one GEN line for each doxygen
rule being executed, not print the doxygen command.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-03-10 13:11:02 -07:00
Pekka Paalanen
538ee6bed6 doc: do not rebuild man pages if they are up to date
The doxygen.man make target was not a real file that was generated,
therefore the man page rule was ran on every make invocation. Replace it
with a real file that is produced by the man page rule.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-03-10 13:10:28 -07:00
Pekka Paalanen
d533839735 build: depend on generated protocol headers
Fixes the build failure where the protocol headers were not generated at
all before compiling src/.libs/libwayland_server_la-wayland-server.o.

The failure was reproducable by starting fresh with 'git clean -dxf' and
not having any wayland headers installed system-wide.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-03-10 13:10:10 -07:00
Kristian Høgsberg
be75659ad1 build: Include protocol/ so we pick up generated headers 2014-03-07 16:02:19 -08:00
Kristian Høgsberg
1e716d6fcf build: Generated protocol files live in protocol/ now
Fix up the references in include_HEADERS.
2014-03-07 14:02:32 -08:00
Kristian Høgsberg
bb41c57446 build: Consolidate scanner build rules 2014-03-07 12:00:13 -08:00
Kristian Høgsberg
7ecb102409 build: Move tests/Makefile.am into toplevel Makefile.am 2014-03-07 12:00:06 -08:00
Kristian Høgsberg
4c163b9b00 build: Move src/Makefile.am into toplevel Makefile.am 2014-03-07 11:50:59 -08:00
Kristian Høgsberg
267b28887d build: Move cursor Makefile.am into toplevel Makefile.am 2014-03-06 23:15:02 -08:00
Kristian Høgsberg
bb5344ee6d build: Move protocol/ Makefile.am into toplevel Makefile.am
A small step towards non-recursive build system for wayland too.
2014-02-18 14:55:09 -08:00
Kristian Høgsberg
6292fe2af6 build: Stop using xmllint to validate protocol files
Same reason as commit cd31275f28b0a04d2ec5426dc81e875197b47e52 from weston:

    The scanner needs to be good enough.  If it crashes or fails to report
    invalid input, that needs to get fixed.
2014-02-18 14:52:02 -08:00
Jasper St. Pierre
52a77fca57 connection: Use wl_log to report errors
In some cases, like Xwayland, stdout and stderr are redirected to
/dev/null, losing us valuable information, while wl_log can be
overridden, allowing us to send it to a log file instead. This
can help debugging immensely.
2014-02-18 14:45:45 -08:00
Jasper St. Pierre
859b3e41f5 scanner: Add GCC pragmas to disable -Wredundant-decls
The code very intentionally emits a lot of redundant declarations
to simplify the scanner code. Somebody building with -Wredundant-decls
would have compile errors, so emit special pragmas to turn those
warnings off.

These pragmas should be ignored outside of gcc/clang.
2014-02-18 14:28:08 -08:00
Jasper St. Pierre
ac188e9e44 wayland-client: Set a proper errno
errno is supposed to be positive, not negative. It seems that
everything else that calls display_fatal_error() calls it with
a positive error code, so do it here as well.
2014-02-18 13:39:59 -08:00
Pekka Paalanen
f8b37449b2 protocol: when buffer transform and scale change
Clarify when the pending and current buffer transform and scale values
change, and what exactly happens on commit.

This matches what Weston currently does.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2014-02-09 21:08:47 -08:00
Kristian Høgsberg
b9eebce0aa client: Queue display events on private queue and always dispatch
The wl_display events (error and delete_id) need to be handled even
if the default queue doesn't get dispatched for a while.  For example,
a busy EGL rendering loop hits wl_display.sync every eglSwapBuffers()
and we need to process the delete_id events to maintain the object ID
data structure.

As it is, that doesn't happen, but with this change we special case
wl_display events.  We put them on a custom, private queue and when
dispatching events, we always dispatch display_queue events first.
The wl_display proxy should still be the default_queue, so that objects
created from wl_display requests get assigned to that.
2014-02-07 16:50:50 -08:00
Kristian Høgsberg
a9eb563fb7 client: Rename display->queue to default_queue
We'll add a new queue next, so rename the default queue first.
2014-02-07 16:00:21 -08:00
Kristian Høgsberg
a7524ed0d4 Make default log handler print to stderr
On the client side we log fatal errors before we exit.  If a client doesn't
set a log handler, it's hard to figure out what goes wrong.
2014-02-07 15:57:07 -08:00
Jason Ekstrand
8fd2520d80 Rename wl_debug to debug_server/client
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
2014-02-05 20:54:33 -08:00
Neil Roberts
a18e34417b Don't deref the sample pointer in the wl_container_of macro
The previous implementation of the wl_container_of macro was
dereferencing the sample pointer in order to get an address of the
member to calculate the offset. Ideally this shouldn't cause any
problems because the dereference doesn't actually cause the address to
be read from so it shouldn't matter if the pointer is uninitialised.
However this is probably technically invalid and could cause undefined
behavior. Clang appears to take advantage of this undefined behavior
and doesn't bother doing the subtraction. It also gives a warning when
it does this.

The documentation for wl_container_of implies that it should only be
given an initialised pointer and if that is done then there is no
problem with clang. However this is quite easy to forget and doesn't
cause any problems or warnings with gcc so it's quite easy to
accidentally break clang.

To fix the problem this changes the macro to use pointer -
offsetof(__typeof__(sample), member) so that it doesn't need to deref
the sample pointer. This does however require that the __typeof__
operator is supported by the compiler. In practice we probably only
care about gcc and clang and both of these happily support the
operator.

The previous implementation was also using __typeof__ but it had a
fallback path avoiding it when the operator isn't available. The
fallback effectively has undefined behaviour and it is targetting
unknown compilers so it is probably not a good idea to leave it in.
Instead, this patch just removes it. If someone finds a compiler that
doesn't have __typeof__ but does work with the old implementation then
maybe they could add it back in as a special case.

This patch removes the initialisation anywhere where the sample
pointer was being unitialised before using wl_container_of. The
documentation for the macro has also been updated to specify that this
is OK.
2014-02-05 17:21:43 -08:00
Jasper St. Pierre
bab7f46d83 protocol: Fix build
"data" is the name of the void* argument in the implementation.
While we probably shouldn't use such an easily-collidable name,
just rename the callback's argument to callback_data for now.
2014-01-31 13:35:07 -08:00
Jasper St. Pierre
338dbd7619 protocol: Fix documentation for the parameter of wl_callback
The parameter here is an opaque integer, rather than the event serial.
The "frame" callback uses this to pass the current time of day in
milliseconds.
2014-01-31 13:10:12 -08:00
Jasper St. Pierre
91974dad1c protocol: Fix the name of the registry argument
A simple copy-paste typo.
2014-01-31 13:10:12 -08:00
Kristian Høgsberg
4b4cd00621 configure.ac: Bump version to 1.4 2014-01-23 20:50:27 -08:00
Kristian Høgsberg
3b8a1c7fed resources-test: Don't send invalid event
Even if nothing receives the even, the arguments still need to be valid.
The test is sending out event 0 from the wl_display interface, which is
the error event.  This requires arg 0 to be a valid object and arg 2 to
be a non-null string.  The test just leaves that undefined, causing
intermittent test failures.

As it is, the resource destroy test doesn't need to send an event to
validate the various resource destroy hooks, so we can just remove the
call to wl_resource_post_event() alltogether.

Thanks to Matt Turner <mattst88@gmail.com> for pointing out the failure.
2014-01-20 15:07:55 -08:00
Jonas Ådahl
47bbc6bb9c protocol: Clarify semantics of wl_subsurface.set_position
Make it clear that multiple requests before commit are allowed and how it
is handled.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
2014-01-19 22:43:13 -08:00
Jonas Ådahl
b5fb898e92 protocol: Clarify semantics of sub-surface placement requests
Clarify some semantics of wl_subsurface.place_below and
wl_subsurface.place_below that were not specified.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Jasper St. Pierre <jstpierre@mecheye.net>
2014-01-19 22:42:44 -08:00