summaryrefslogtreecommitdiffstats
path: root/src/event-loop.c
Commit message (Collapse)AuthorAgeFilesLines
* event-loop: fix returning the destroy-signal listenerDavid Herrmann2013-01-241-1/+1
| | | | | | | We need to actually return the destroy-listener, otherwise the return value is undefined. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
* Add a destroy signal to the wl_event_loop objectJason Ekstrand2013-01-151-0/+21
|
* Move ARRAY_LENGTH out of public headersKristian Høgsberg2012-10-191-0/+1
| | | | | | | | Exporting unprefixed symbols is a pretty bad idea so don't do that. Instea of redefining it WL_ARRAY_LENGTH, we just move the define to our private header. The scanner generates code that uses ARRAY_LENGTH, but we can just make it count the number elements and emit an integer constant instead.
* Change filedescriptor API to be thread safeKristian Høgsberg2012-10-101-0/+4
| | | | | | | | | | | | | | | | | | | | | The update callback for the file descriptors was always a bit awkward and un-intuitive. The idea was that whenever the protocol code needed to write data to the fd it would call the 'update' function. This function would adjust the mainloop so that it polls for POLLOUT on the fd so we can eventually flush the data to the socket. The problem is that in multi-threaded applications, any thread can issue a request, which writes data to the output buffer and thus triggers the update callback. Thus, we'll be calling out with the display mutex held and may call from any thread. The solution is to eliminate the udpate callback and just require that the application or server flushes all connection buffers before blocking. This turns out to be a simpler API, although we now require clients to deal with EAGAIN and non-blocking writes. It also saves a few syscalls, since the socket will be writable most of the time and most writes will complete, so we avoid changing epoll to poll for POLLOUT, then write and then change it back for each write.
* event-loop: export wl_event_loop_dispatch_idle()David Herrmann2012-09-121-3/+3
| | | | | | | | | | | | | | | | | | | | When integrating the wayland event-loop into another event-loop, we currently have no chance of checking whether there are pending idle sources that have to be called. This patch exports the "dispatch_idle_sources()" call so other event loops can call this before going to sleep. This is what wl_event_loop_dispatch() currently does so we simply allow external event-loops to do the same now. To avoid breaking existing applications, we keep the call to dispatch_idle_sources() in wl_event_loop_dispatch() for now. However, if we want we can remove this later and require every application to call this manually. This needs to be discussed, but the overhead is negligible so we will probably leave it as it is. This finally allows to fully integrate the wayland-server API into existing event-loops without any nasty workarounds. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
* event-loop: remove dead codeDavid Herrmann2012-09-101-2/+2
| | | | | | | There is really no need to increment "n" if we never read the value. The do-while() loop overwrites the value before it is read the first time. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
* event-loop: Delete fd from epoll when removing event sourceKristian Høgsberg2012-05-081-2/+6
| | | | | | | Closing an fd will remove it from the epoll set only if it hasn't been dup'ed. In other words, the fd is only removed from epoll when all file descriptors referring to the open file has been close. We now dup fd for fd sources, so we need to use EPOLL_CTL_DEL directly now.
* event-loop: Consolidate code for setting up new sourcesKristian Høgsberg2012-05-081-98/+44
|
* event-loop: fix conditional checkingTiago Vignatti2012-05-081-1/+1
| | | | | | | | | Introduced in: commit 80f4f0d5127ebc8d5e35969a29691cf61a79997d Author: Jonas Ådahl <jadahl@gmail.com> Date: Wed Mar 21 10:31:24 2012 +0100 Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
* os: wrap epoll_createPekka Paalanen2012-04-251-1/+2
| | | | | | | | | Some system C libraries do not have epoll_create1() nor EPOLL_CLOEXEC, provide a fallback. Add tests for the wrapper. Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
* event-loop: Use two-step destruction of event loop sources.Jonas Ådahl2012-03-211-50/+49
| | | | | | | | | | | | Instead of directly freeing an event source upon removal put it in a queue later handled by the event loop; either after a dispatch or upon event loop destruction. This is necessary to avoid already queued up event sources to be freed during some other dispatch callback, causing segmentation faults when the event loop later tries to handle an event from the freed source. Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
* event-loop: always do the post-dispatch checkAnder Conselvan de Oliveira2012-03-201-1/+2
| | | | | The post-dispatch check on wl_event_loop_dispatch() was not being run if epoll_wait returned 0 events, making the check unreliable.
* Fix WL_EVENT_WRITEABLE typoKristian Høgsberg2011-12-281-3/+3
|
* event-loop: Fix idle handler dispatch corner caseKristian Høgsberg2011-10-291-2/+4
| | | | | | | | | When the last idle handler queues another idle handler, we fail to dispatch that last handler. The wl_list_for_each_safe loop looks up the next pointer before running the handler, and at that point it points to the head of the list and the loop terminates. Instead, just loop until the list is empty.
* event-loop: Quiet a few warningsKristian Høgsberg2011-08-121-2/+10
| | | | There's no good error recovery possible in these cases though.
* Rename source subdir from wayland to srcKristian Høgsberg2011-08-121-0/+465