summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* scanner: Downgrade non-increasing version error to warning1.4.93Kristian Høgsberg2014-05-121-1/+1
| | | | | | | | | | | Commit 99a72777f96f63e4e25dc528bb37115424adac59 introduced a new error for when the 'since' version decreases. It also reset the version for messages without a version to 1. Versioning semantics in the spec files was a little under-specified and we don't want to break projects caught in this grey zone. This commits replaces previous configure.ac as the 1.4.93 tag and the final 1.5 RC.
* scanner: Generate macros for getting the 'since' version of an eventJonas Ådahl2014-05-091-0/+13
| | | | | | | | | | | This could be useful for compositors who need to be able to not send events if the client bound a version lower than the newest provided. Event version numbers are exposed as [INTERFACE_NAME]_[EVENT_NAME]_SINCE_VERSION for example wl_output.scale will have the version macro WL_OUTPUT_SCALE_SINCE_VERSION. Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
* scanner: Also fail when an implicitly versioned message is out of orderJonas Ådahl2014-05-091-4/+6
| | | | | | | Fail if a message with version implicitly set to 1 (i.e. not specified) comes after a message with since-version > 1. Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
* doc: Added API documentation for wl_display_create function.Srivardhan Hebbar2014-05-091-0/+9
| | | | Signed-off-by: Srivardhan Hebbar <sri.hebbar@samsung.com>
* server: fix potential memleak and NULL derefU. Artie Eoff2014-05-061-1/+2
| | | | | | | | | | | | | | | | | | 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>
* scanner: check wl_array_add resultU. Artie Eoff2014-05-061-1/+1
| | | | Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
* Avoid printing to stderrKristian Høgsberg2014-04-302-15/+9
| | | | | | | 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
* Use non-blocking timerfd to prevent blocking when updating timer event sourcesAndrew Wedgbury2014-04-251-2/+3
| | | | | | | | | | | | | | | | | 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.
* connection: fix a format string typo in error messageGiulio Camuffo2014-04-251-1/+1
|
* connection: Don't write past the end of the connection bufferAnder Conselvan de Oliveira2014-04-211-8/+17
| | | | | | | | | | | 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
* shm: Disallow shrinking shm poolsKristian Høgsberg2014-04-071-2/+8
| | | | | | | 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
* scanner: Only output each forward declaration onceKristian Høgsberg2014-04-031-8/+28
| | | | | Just sort the types and only print unique type names. We avoid using the GCC pragma.
* Add WL_PRINTF attribute and annotate wl_log_func_tKristian Høgsberg2014-04-031-1/+8
|
* client: Delay EPIPE handling so we get a chance to handle error eventsKristian Høgsberg2014-03-261-2/+5
|
* server: Kill some unnecessary logsJasper St. Pierre2014-03-251-4/+0
| | | | | | 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.
* build: Move src/Makefile.am into toplevel Makefile.amKristian Høgsberg2014-03-071-72/+0
|
* connection: Use wl_log to report errorsJasper St. Pierre2014-02-181-18/+18
| | | | | | | 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.
* scanner: Add GCC pragmas to disable -Wredundant-declsJasper St. Pierre2014-02-181-1/+3
| | | | | | | | | 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.
* wayland-client: Set a proper errnoJasper St. Pierre2014-02-181-3/+3
| | | | | | 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.
* client: Queue display events on private queue and always dispatchKristian Høgsberg2014-02-071-4/+21
| | | | | | | | | | | | | | 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.
* client: Rename display->queue to default_queueKristian Høgsberg2014-02-071-8/+9
| | | | We'll add a new queue next, so rename the default queue first.
* Make default log handler print to stderrKristian Høgsberg2014-02-071-2/+4
| | | | | 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.
* Rename wl_debug to debug_server/clientJason Ekstrand2014-02-052-10/+10
| | | | Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
* Don't deref the sample pointer in the wl_container_of macroNeil Roberts2014-02-053-19/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* client: Include poll.h instead of sys/poll.hJonas 'Sortie' Termansen2014-01-171-1/+1
| | | | POSIX mandates the poll.h header as the standard location of poll(2).
* add_shm_format: check wl_array_add return value before derefU. Artie Eoff2014-01-152-5/+11
| | | | | | | | In wl_display_add_shm_format(), check the return value from wl_array_add() before dereferencing it and assigning it a value. Return the resulting pointer back to the caller. Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
* shm: assert sigbus_data is not NULL before member accessU. Artie Eoff2014-01-151-1/+1
| | | | Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
* Fix buffer overflow when serializing a closure object1.3.92chi ding2014-01-091-8/+83
| | | | | | | | | Here is the JIRA page of this issue https://bugs.tizen.org/jira/browse/TIVI-1889 Change-Id: I773a6d2d8f6fd02ff10c92450db1fa8a69544219 Signed-off-by: Chi Ding <chi.ding@mobica.com> Closes: https://bugs.freedesktop.org/show_bug.cgi?id=65186
* scanner: set errno=0 before strtolAdrian Negreanu2013-12-171-0/+1
| | | | | | | | | | | | POSIX says to set errno=0 before calling strtol since the return value alne cannot tell a failure. on ubuntu armel I get: ../src/wayland-scanner client-header < ../../protocol/wayland.xml > wayland-client-protocol.h <stdin>:1188: error: invalid integer (2) Signed-off-by: Adrian Negreanu <adrian.m.negreanu@intel.com>
* client: Handle EINTR in wl_display_dispatch_queue()Kristian Høgsberg2013-12-091-1/+5
| | | | | | Restart the poll() if we take a signal. This is easily triggered in an application that ends up blocking in eglSwapBuffers(), and causes EGL to fail to allocate a back buffer.
* doc: Fix spelling of parametersJonas Ådahl2013-12-091-2/+2
| | | | Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
* doc: Remove incorrect docmentationJonas Ådahl2013-12-091-11/+0
| | | | | | | The documentation was about wl_client_get_object(), not about wl_resource_get_client(). Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
* client: Make wl_proxy_set_queue() with NULL revert to default queueNeil Roberts2013-12-041-1/+4
| | | | | | | | | | | | | | This will be useful in order to implement the EGL_WL_create_wayland_buffer_from_image extension. The buffers created within Mesa's Wayland platform are created using the the wl_drm object as a proxy factory which means they will be set to use Mesa's internal event queue. However, these buffers will be owned by the client application so they ideally need to use the default event loop. This function provides a way to set the proxy's event queue back to the default. krh: Edited from Neils original patch to just use wl_proxy_set_queue() with a NULL argument instead of introducing a new function.
* Add -pthread to AM_CFLAGS to do the right thing when using threadsKristian Høgsberg2013-11-231-1/+1
| | | | https://bugs.freedesktop.org/show_bug.cgi?id=71633
* connection: Error out if file descriptor was not receivedLubomir Rintel2013-11-211-0/+9
| | | | | | | | Otherwise the tail of fds_in buffer would just shift beyond the beginning. That confuses the actual request handler and results in a crash further on due to corrupted tail. Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
* wayland-server: Improve error messages for bad globalsJasper St. Pierre2013-11-191-3/+7
| | | | | | A bug in Weston's toytoolkit gave me an hour of debugging headaches. Improve the error messages that we send if a client requests an invalid global, either by name or by version.
* client: Introduce functions to allocate and marshal proxies atomicallyKristian Høgsberg2013-11-154-75/+189
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The server requires clients to only allocate one ID ahead of the previously highest ID in order to keep the ID range tight. Failure to do so will make the server close the client connection. However, the way we allocate new IDs is racy. The generated code looks like: new_proxy = wl_proxy_create(...); wl_proxy_marshal(proxy, ... new_proxy, ...); If two threads do this at the same time, there's a chance that thread A will allocate a proxy, then get pre-empted by thread B which then allocates a proxy and then passes it to wl_proxy_marshal(). The ID for thread As proxy will be one higher that the currently highest ID, but the ID for thread Bs proxy will be two higher. But since thread B prempted thread A before it could send its new ID, B will send its new ID first, the server will see the ID from thread Bs proxy first, and will reject it. We fix this by introducing wl_proxy_marshal_constructor(). This function is identical to wl_proxy_marshal(), except that it will allocate a wl_proxy for NEW_ID arguments and send it, all under the display mutex. By introducing a new function, we maintain backwards compatibility with older code from the generator, and make sure that the new generated code has an explicit dependency on a new enough libwayland-client.so. A virtual Wayland merit badge goes to Kalle Vahlman, who tracked this down and analyzed the issue. Reported-by: Kalle Vahlman <kalle.vahlman@movial.com>
* shm: Avoid file descriptor leak upon unsuccessful mmapLubomir Rintel2013-11-151-1/+1
| | | | | | | It would be possible to make the compositor leak file descriptors by passing descriptors of open unmmapable files to it, such as /dev/null. Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
* Add documentation for wl_shm_buffer_begin/end_accessNeil Roberts2013-11-151-0/+64
| | | | | It's not obvious that these functions are needed so it would be good to have some documentation for them.
* scanner: Add location to elements so we can give better errors/warningsKristian Høgsberg2013-11-151-7/+25
|
* scanner: Make fail() function use va_list and elaborate a few errorsKristian Høgsberg2013-11-151-7/+14
|
* scanner: Introduce struct location for tracking source locationsKristian Høgsberg2013-11-151-20/+26
|
* scanner: Warn about requests with more than one new-id and don't generate stubsKristian Høgsberg2013-11-151-0/+14
| | | | | | | The generated code only support one new-id per request, since the stubs return the new proxy. It's still possible to send requests with multiple new-id arguments, but it must be done with wl_proxy_marshal_array_constructor().
* server: Start documenting the server side APIKristian Høgsberg2013-11-131-0/+130
| | | | This is now public, stable API, so it seems prudent to actually document it.
* server: Add API to protect access to an SHM bufferNeil Roberts2013-11-132-0/+137
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Linux will let you mmap a region of a file that is larger than the size of the file. If you then try to read from that region the process will get a SIGBUS signal. Currently the clients can use this to crash a compositor because it can create a pool and lie about the size of the file which will cause the compositor to try and read past the end of it. The compositor can't simply check the size of the file to verify that it is big enough because then there is a race condition where the client may truncate the file after the check is performed. This patch adds the following two public functions in the server API which can be used wrap access to an SHM buffer: void wl_shm_buffer_begin_access(struct wl_shm_buffer *buffer); void wl_shm_buffer_end_access(struct wl_shm_buffer *buffer); The first time wl_shm_buffer_begin_access is called a signal handler for SIGBUS will be installed. If the signal is caught then the buffer for the current pool is remapped to an anonymous private buffer at the same address which allows the compositor to continue without crashing. The end_access function will then post an error to the buffer resource. The current pool is stored as part of some thread-local storage so that multiple threads can safely independently access separate buffers. Eventually we may want to add some more API so that compositors can hook into the signal handler or replace it entirely if they also want to do some SIGBUS handling.
* wayland: Be consistent about #include-guard namesKristian Høgsberg2013-10-213-6/+6
| | | | | | | We had a mix of inconsistent names, some of which were non-conformant. Standardize on all-uppercase-and-underscore naming convention. https://bugs.freedesktop.org/show_bug.cgi?id=70679
* scanner: Handle unrecognized invocation modeKristian Høgsberg2013-10-071-1/+3
| | | | | Print usage if we don't recognize the invocation mode. Also fixes uninitialized variable warning.
* client: Fix handling display->reader_count if poll failsNeil Roberts2013-09-251-1/+3
| | | | | | | | | | In wl_display_dispatch_queue, if poll fails then it would previously return immediately and leak a reference in display->reader_count. Then if the application ignores the error and tries to read again it will block forever. This can happen for example if the poll fails with EINTR which the application might consider to be a recoverable error. This patch makes it cancel the read so the reader_count will be decremented when poll fails.
* Export the Wayland protocol XML fileJason Ekstrand2013-09-212-0/+4
| | | | Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
* client: fix an inconsistency in documentationChang Liu2013-09-211-1/+1
| | | | | The errno is set to EAGAIN when there are undispatched events, according to L1066 of wayland-client.c.