summaryrefslogtreecommitdiff
path: root/lib/tevent/tevent_poll.c
AgeCommit message (Collapse)AuthorFilesLines
2013-04-04tevent: Only set poll_ev->delete=false if it was trueVolker Lendecke1-1/+1
Might not be noticable, but I thought it would be an obvious tiny optimization. Possibly the compiler already does this. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Thu Apr 4 18:32:39 CEST 2013 on sn-devel-104
2013-03-01tevent: optimize adding new zero timer eventsStefan Metzmacher1-2/+2
Such events were used before we had immediate events. It's likely that there're a lot of this events and we need to add new ones in fifo order. The tricky part is that tevent_common_add_timer() should not use the optimization as it's used by broken Samba versions, which don't use tevent_common_loop_timer_delay() in source3/lib/events.c. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-03-01tevent: use DLIST_DEMOTE() before calling on fde handler after select() and ↵Stefan Metzmacher1-0/+1
poll() This makes sure we don't preferr events which are at the beginning of the list. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-03-01tevent: revalidate fde->flags after poll()Stefan Metzmacher1-0/+6
This is important to avoid races between threads if the poll_mt backend is used. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-03-01tevent: ignore POLLNVAL from poll() and disable the eventStefan Metzmacher1-1/+44
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-03-01tevent: traverse the ev->fd_event list instead of the poll_ev->fds arrayStefan Metzmacher1-26/+5
That has the same complexity but simplifies the code. It also seems to fix a real problem, which was found by the following test failure in Samba's autobuild, while removing the epoll support from the "standard" backend. [402/1555 in 19m8s] samba3.raw.composite(plugin_s4_dc) smbtorture 4.1.0pre1-DEVELOPERBUILD Using seed 1361531675 Testing savefile Testing parallel fetchfile with 10 ops waiting for completion maximum runtime exceeded for smbtorture - terminating UNEXPECTED(error): samba3.raw.composite.fetchfile (subunit.RemotedTestCase)(plugin_s4_dc) REASON: _StringException: _StringException: was started but never finished! UNEXPECTED(error): samba3.raw.composite.fetchfile(plugin_s4_dc) (subunit.RemotedTestCase) REASON: was started but never finished! Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-03-01tevent: maintain a list of disabled events in the poll backendStefan Metzmacher1-7/+48
We need to avoid passing pollfd.events == 0, to poll(), as it will report POLLERR and POLLHUP events, but our caller does not expect the event handler to be called. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-03-01tevent: merge poll_fresh_fde_destructor() into poll_event_fd_destructor()Stefan Metzmacher1-18/+6
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-03-01tevent: use tevent_poll_event_add_fd_internal() in poll_event_add_fd()Stefan Metzmacher1-2/+1
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-03-01tevent: make sure we cleanup the array passed to poll() after deleting an eventStefan Metzmacher1-0/+30
If we don't cleanup the array passed to poll after an event was deleted, we may pass a bad file descriptor to poll(). This was found by the following test failure in Samba's autobuild, while removing the epoll support from the "standard" backend. [48/1555 in 4m37s] samba3.smbtorture_s3.plain(s3dc).LOCK4 UNEXPECTED(failure): samba3.smbtorture_s3.plain(s3dc).LOCK4.smbtorture(s3dc) REASON: _StringException: _StringException: using seed 1361530718 host=127.0.0.2 share=tmp user=metze myname=sn-devel-104 Running LOCK4 starting locktest4 Failed to create file: NT_STATUS_INVALID_HANDLE finished locktest4 TEST LOCK4 FAILED! LOCK4 took 190.492 secs Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-03-01tevent: don't skip a fd event if the previous one was deleted during poll()Stefan Metzmacher1-2/+9
In a threaded environment it can happen that an tevent_fd is talloc_free'ed while the main thread sleeps in the poll() syscall. In such a case poll_event_fd_destructor() would set poll_ev->fdes[i] = NULL. We then skip the removed event, but before we also skipped the one that was located at the end of the array. We moved it to possition 'i', but the next loop uses 'i=i+1'. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-03-01tevent: remember the errno from select(), poll() and epoll_wait()Stefan Metzmacher1-1/+3
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-02-14tevent: Add a private function tevent_poll_event_add_fd_internal().Jeremy Allison1-0/+16
Not yet used, but will be called by the "standard" fallback from epoll -> poll backends. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2013-02-03tevent_poll: add poll_event_loop_wait()Stefan Metzmacher1-2/+31
We can't use tevent_common_loop_wait() because new fd events will be added to the poll_ev->fresh list instead of ev->fd_events. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Sun Feb 3 06:40:09 CET 2013 on sn-devel-104
2013-02-02tevent_poll: fix the usage of tevent_re_initialise()Stefan Metzmacher1-0/+8
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-02-02tevent_poll: call tevent_common_fd_destructor() from poll_fresh_fde_destructor()Stefan Metzmacher1-2/+3
We need to trigger the fde->close_fn(). Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-02-02tevent_poll: Avoid a crash in poll_event_set_fd_flagsVolker Lendecke1-2/+8
The event context might have been freed before the fde Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-02-02tevent_poll: Avoid a crash in poll_fresh_fde_destructorVolker Lendecke1-2/+9
The event context might have been freed before the fde Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-02-02tevent_poll: NULL out fde->event_ctx for "fresh" poll fdesVolker Lendecke1-0/+8
This is done in tevent_common_context_destructor for the non-fresh fdes already Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-02-02tevent_poll: Use the poll_event_context_destructor alwaysVolker Lendecke1-5/+12
This is in preparation for the next patch to NULL out the event_ctx pointers in the poll_ev->fresh list Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-02-02tevent_poll: Re-order routinesVolker Lendecke1-16/+16
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-02-02tevent_poll: Fix a crash in the poll backendVolker Lendecke1-4/+15
If tevent_add_fd is immediately followed by tevent_fd_set_flags, the poll backend crashes. This was introduced when the poll backend was prepared for the multi-threaded python extension. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-01-31tevent: Fix a comment typoVolker Lendecke1-1/+1
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ira Cooper <ira@samba.org> Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com> Autobuild-User(master): Richard Sharpe <sharpe@samba.org> Autobuild-Date(master): Thu Jan 31 17:52:39 CET 2013 on sn-devel-104
2012-08-16lib/tevent: Add a thread-safe tevent backendVolker Lendecke1-3/+158
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2012-08-16tevent_poll: Decouple poll_ev->fds handling from adding/removing fdsVolker Lendecke1-72/+135
Step 1 in a python backend for multiple threads Signed-off-by: Stefan Metzmacher <metze@samba.org>
2012-06-08lib/tevent: Add trace point callbackMartin Schwenke1-0/+2
Set/get a single callback function to be invoked at various trace points. Define "before wait" and "after wait" trace points - more trace points can be added later if required. CTDB wants this to log long waits and events. Pair-programmed-with: Amitay Isaacs <amitay@gmail.com> Signed-off-by: Martin Schwenke <martin@meltin.net> Signed-off-by: Stefan Metzmacher <metze@samba.org>
2012-06-08lib/tevent: In poll_event_context, add a pointer back to the tevent_contextMartin Schwenke1-0/+4
This makes it consistent with the other backends. Signed-off-by: Martin Schwenke <martin@meltin.net> Signed-off-by: Stefan Metzmacher <metze@samba.org>
2012-04-09tevent: Fix a typoVolker Lendecke1-1/+1
2011-07-28tevent: Slightly simplify poll_event_loop_pollVolker Lendecke1-33/+38
No real code change. Do an early return instead of an if-statement, avoiding one level of indentation.
2011-06-03Fix the poll() backend to correctly respond to POLLHUP|POLLERR returns on a ↵Jeremy Allison1-1/+13
fd selected for TEVENT_FD_WRITE only. Don't trigger the write handler and remove the POLLOUT flag for this fd. Report errors on TEVENT_FD_READ requests only. Metze please check ! Jeremy. Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Fri Jun 3 22:53:52 CEST 2011 on sn-devel-104
2011-03-10tevent/poll: use fde->additional_flags to hold the array indexStefan Metzmacher1-17/+6
metze
2011-02-28Fix "cast from pointer to integer of different size" warnings on a 64-bit ↵Jeremy Allison1-7/+7
machine.
2011-02-28tevent: Add a poll backendVolker Lendecke1-0/+306