1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
Commit Graph

66 Commits

Author SHA1 Message Date
Stefan Metzmacher
020032e114 s3:lib/events: Fix a bug in run_poll_events().
Ignore fd events without EVENT_FD_READ or EVENT_FD_WRITE also in
run_events_poll(). They are ignore when building the array
for the syscall in event_add_to_poll_args(), so we need to
ignore them run_events_poll() too.

metze

Signed-off-by: Andreas Schneider <asn@samba.org>

Autobuild-User: Stefan Metzmacher <metze@samba.org>
Autobuild-Date: Tue Aug  9 10:11:54 CEST 2011 on sn-devel-104
2011-08-09 10:11:54 +02:00
Andrew Bartlett
c599d075cb s3-lib Move event_add_idle() to source3/lib/events.c
This allows libauth not to depend on smbd_base.

Andrew Bartlett
2011-07-04 18:53:59 +10:00
Andrew Bartlett
ad0a07c531 s3-talloc Change TALLOC_ZERO_P() to talloc_zero()
Using the standard macro makes it easier to move code into common, as
TALLOC_ZERO_P isn't standard talloc.
2011-06-09 12:40:08 +02:00
Andrew Bartlett
73b377432c s3-talloc Change TALLOC_REALLOC_ARRAY() to talloc_realloc()
Using the standard macro makes it easier to move code into common, as
TALLOC_REALLOC_ARRAY isn't standard talloc.

Andrew Bartlett
2011-06-09 12:40:08 +02:00
Jeremy Allison
3c9b3b2bef Add the same fix to the S3 event backend as the previous commit added to the tevent poll backend.
Metze please check !

Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Sat Jun  4 00:27:37 CEST 2011 on sn-devel-104
2011-06-04 00:27:37 +02:00
Volker Lendecke
2ab34a5736 Revert "s3: Mark sockets in error state writable"
This reverts commit 5f6f719564.

Autobuild-User: Volker Lendecke <vlendec@samba.org>
Autobuild-Date: Wed Jun  1 14:56:25 CEST 2011 on sn-devel-104
2011-06-01 14:56:25 +02:00
Volker Lendecke
5f6f719564 s3: Mark sockets in error state writable
Without this patch, when a socket only has a write event pending, we will never
detect an error condition. I've seen winbind doing

12:19:13.659964 gettimeofday({1306837153, 659984}, NULL) = 0 <0.000016>
12:19:13.660109 poll([{fd=35, events=POLLOUT}, {fd=32, events=POLLIN|POLLHUP}], 2, 9996) = 1 ([{fd=35, revents=POLLERR|POLLHUP}]) <0.000015>
12:19:13.660253 gettimeofday({1306837153, 660269}, NULL) = 0 <0.000013>
12:19:13.660298 poll([{fd=35, events=POLLOUT}, {fd=32, events=POLLIN|POLLHUP}], 2, 9996) = 1 ([{fd=35, revents=POLLERR|POLLHUP}]) <0.000015>

for a while when trying to connect to a DC when the socket had died already.

Volker

Autobuild-User: Volker Lendecke <vlendec@samba.org>
Autobuild-Date: Tue May 31 20:59:10 CEST 2011 on sn-devel-104
2011-05-31 20:59:10 +02:00
Andrew Tridgell
628fcd111a s3-events: tevent_internal.h is not a public header
We need to use the "foo.h" form instead of the <foo.h> form for
headers that are not installed publicly. Otherwise when an external
version of tevent is used we won't find the header and the build will
fail.

Note that this creates a structure dependency between the
tevent structures in the external library and the headers in our
source tree. That is not ideal, but is currently OK as the waf build
will only use the external library if it is at least the same version
as the internal tree, which means it will actually be the same
version, as we release the external version from our tree.

We should come up with a better solution, but for now this allows
openchange to build again.

Autobuild-User: Andrew Tridgell <tridge@samba.org>
Autobuild-Date: Tue May 10 16:06:40 CEST 2011 on sn-devel-104
2011-05-10 16:06:40 +02:00
Volker Lendecke
0958695022 s3: Fix timeout calculation in event_add_to_poll_args
In the initial phase nmbd does not yet have timed events. This led to nmbd
not correctly registering its names in make test and certainly everywhere
else.

Autobuild-User: Volker Lendecke <vlendec@samba.org>
Autobuild-Date: Mon Apr 11 14:35:45 CEST 2011 on sn-devel-104
2011-04-11 14:35:45 +02:00
Volker Lendecke
cf7d331511 s3: Remove select-based s3 event backend 2011-02-28 16:40:19 +01:00
Volker Lendecke
ea5e1c5ecb s3: Use poll for the event loop 2011-02-28 16:40:19 +01:00
Stefan Metzmacher
ad10289ebc s3:lib/events: use DLIST_DEMOTE() for fd events
This makes sure that fd events doesn't dry out,
because a fd with a lower number is busy.

metze

Autobuild-User: Stefan Metzmacher <metze@samba.org>
Autobuild-Date: Mon Jan 31 16:59:44 CET 2011 on sn-devel-104
2011-01-31 16:59:44 +01:00
Stefan Metzmacher
1f2be10ebf s3:lib/events: don't loop over fd events is select gave -1
metze
2011-01-31 16:16:09 +01:00
Stefan Metzmacher
19d3779274 Revert "s3:events: Call all ready fd event handlers on each iteration of the main loop"
This reverts commit 455fccf86b.

I'll add a more generic fix for this problem.

metze
2011-01-31 16:16:09 +01:00
Volker Lendecke
509dd57d68 Revert "s3: Fix an infinite loop"
This reverts commit 61f7d7cdec.

Autobuild-User: Volker Lendecke <vlendec@samba.org>
Autobuild-Date: Mon Jan 24 10:10:43 CET 2011 on sn-devel-104
2011-01-24 10:10:43 +01:00
Volker Lendecke
61f7d7cdec s3: Fix an infinite loop
If select returns EBADF (which should NEVER happen), then we loop infinitely
because the select masks seem all active.

I've been given an strace where smbd floods syslog with inotify-related
error messages. The strace shows that select returns EBADF, and we're calling
the inotify event callback. It then complains there's no data on the inotify
fd.

Metze, please check!

We might need to fix this in 3.4 and 3.5 as well. And we need to find the
deeper reason where we close a file descriptor and don't tell the events
system about it.

Volker

Autobuild-User: Volker Lendecke <vlendec@samba.org>
Autobuild-Date: Sun Jan 23 10:05:39 CET 2011 on sn-devel-104
2011-01-23 10:05:39 +01:00
Jeremy Allison
30d29e64cb All calls to event_add_to_select_args() call GetTimeOfDay() and
pass this in as the &now parameter. Push this call inside of
event_add_to_select_args() to the correct point so it doesn't
get called unless needed.

Jeremy.

Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Thu Dec 23 01:08:11 CET 2010 on sn-devel-104
2010-12-23 01:08:11 +01:00
Steven Danneman
455fccf86b s3:events: Call all ready fd event handlers on each iteration of the main loop
Previously, only one fd handler was being called per main message loop
in all smbd child processes.

In the case where multiple fds are available for reading the fd
corresponding to the event closest to the beginning of the event list
would be run.  Obviously this is arbitrary and could cause unfairness.

Usually, the first event fd is the network socket, meaning heavy load
of client requests can starve out other fd events such as oplock
or notify upcalls from the kernel.

In this patch, I have changed the behavior of run_events() to unset
any fd that it has already called a handler function, as well
as decrement the number of fds that were returned from select().
This allows the caller of run_events() to iterate it, until all
available fds have been handled.

I then changed the main loop in smbd child processes to iterate
run_events().  This way, all available fds are handled on each wake
of select, while still checking for timed or signalled events between
each handler function call.  I also added an explicit check for
EINTR from select(), which previously was masked by the fact that
run_events() would handle any signal event before the return code
was checked.

This required a signature change to run_events() but all other callers
should have no change in their behavior.  I also fixed a bug in
run_events() where it could be called with a selrtn value of -1,
doing unecessary looping through the fd_event list when no fds were
available.

Also, remove the temporary echo handler hack, as all fds should be
treated fairly now.
2010-10-01 13:31:33 -07:00
Günther Deschner
b38d0542e1 samba: share select wrappers.
Guenther
2010-10-01 22:30:22 +02:00
Andrew Tridgell
772839640e s3-event: switch s3 to using tevent_re_initialise()
This correctly initialises the event backend, and checks for errors

(thanks to Metze for suggesting this)
2010-03-26 22:07:50 +11:00
Volker Lendecke
6c00a3db24 s3: Remove some unused code 2010-03-14 17:42:49 +01:00
Andrew Tridgell
5dbf175c75 s3-events: make the old timed events compatible with tevent
tevent ensures that a timed event is only called once. The old events
code relied on the called handler removing the event itself. If the
handler removed the event after calling a function which invoked the
event loop then the timed event could loop forever.

This change makes the two timed event systems more compatible, by
allowing the handler to free the te if it wants to, but ensuring it is
off the linked list of events before the handler is called, and
ensuring it is freed even if the handler doesn't free it.
2010-02-05 22:17:54 -08:00
Volker Lendecke
d8556bbf13 Quieten events and tldap debug messages 2009-07-10 22:01:56 +02:00
Volker Lendecke
834fc3786e s3-events: Not only timed, also immediate events generate a timeout return 2009-05-17 11:45:22 +02:00
Volker Lendecke
ad91ef7f96 s3-events: If immediate requests are pending, the timeout is 0 2009-05-16 19:22:03 +02:00
Stefan Metzmacher
6c290586e4 s3:events: add support for immediate events
metze
2009-03-17 19:59:07 +01:00
Stefan Metzmacher
d27be1d5fa s3:events: make use of tevent_common_loop_wait()
metze
2009-03-17 19:58:58 +01:00
Stefan Metzmacher
bd0f14c1d7 s3:events: pass __location__ to event_loop_*()
metze
2009-03-12 12:12:40 +01:00
Jeremy Allison
4b2955aa7d Fix "ignore return" warning.
Jeremy.
2009-03-03 08:50:35 -08:00
Stefan Metzmacher
543db0f94a s3:events: map TEVENT_DEBUG_TRACE to debug level 10
metze
2009-02-25 15:05:49 +01:00
Volker Lendecke
4c7296cc0c Avoid valgrind errors
In event handlers, we might destroy other events that are pending in the lists.
We can only run one event safely per select call.

Yes, I've seen these valgrind errors :-)

Jeremy, with ccdd921e61 you had checked in the change to run multiple events.
Do you remember why it was necessary and could not be solved in a different
way?

Volker
2009-01-28 16:18:16 +01:00
Stefan Metzmacher
f9dcd3d2b7 s3:events: always run_events() before sys_select()
We might have pending signal events not only timed events.

metze
2009-01-22 12:37:28 +01:00
Stefan Metzmacher
8d203d3cab s3:events: add support for signal events
metze
2009-01-20 00:41:09 +01:00
Stefan Metzmacher
d524e5f417 s3:events: debug sys_select() errors
metze
2009-01-09 08:45:40 +01:00
Stefan Metzmacher
def5e8e889 s3:events: install a tevent debug handler that calls DEBUG()
metze
2009-01-09 08:45:40 +01:00
Stefan Metzmacher
991b294c41 s3:events: use more tevent_common_* functions
metze
2009-01-05 22:44:55 +01:00
Stefan Metzmacher
303c57ef78 s3:events: register as tevent backend
metze
2009-01-05 15:07:36 +01:00
Stefan Metzmacher
83ff9d3bcd s3:events: get rid of the stupid set_event_dispatch_time() function
metze
2009-01-05 15:07:35 +01:00
Stefan Metzmacher
f1aa4457c3 s3:events: get rid of the stupid cancel_named_event() function
metze
2009-01-05 15:07:35 +01:00
Stefan Metzmacher
c34d5f445a s3:events: change event_add_timed() prototype to match samba4
metze
2009-01-05 15:07:35 +01:00
Stefan Metzmacher
077d5cff71 s3:events: remove unused stuff
metze
2009-01-05 15:07:34 +01:00
Bo Yang
022e2f8199 clean event context after child is forked.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
2009-01-05 15:07:31 +01:00
Jelmer Vernooij
cb78d4593b Cope with changed signature of http_timestring(). 2008-10-11 23:57:44 +02:00
Volker Lendecke
12ee6b832c Make events robust against their event_context being freed
(This used to be commit 3d4e7b29c2)
2008-08-10 18:40:47 +02:00
Volker Lendecke
5b8259c112 Fix max_fd calculation in event_loop_once
For some bugs I really wonder how they can go undetected for so long.

Fix a bug reported by Mathias Dietz. No samba bugzilla entry, but still 100%
needed for 3-2-stable.

Volker
(cherry picked from commit 82c994dabc)
(This used to be commit 91c73e093a)
2008-06-11 18:58:26 +02:00
Michael Adam
87c15f5a57 lib/events: use mem_context given to event_context_init().
Michael
(This used to be commit f872a1f442)
2008-05-28 01:10:55 +02:00
Volker Lendecke
fe4930b7fa Enable multiple fd events on a single file descriptor
Now we can have multiple events listen on a single fd. The order in which they
are called is naturally not defined, meaning that it is only deterministic if
exactly one event is readable or writeable.
(This used to be commit 61503f822b)
2008-04-14 13:13:47 +02:00
Jeremy Allison
30191d1a57 RIP BOOL. Convert BOOL -> bool. I found a few interesting
bugs in various places whilst doing this (places that assumed
BOOL == int). I also need to fix the Samba4 pidl generation
(next checkin).
Jeremy.
(This used to be commit f35a266b3c)
2007-10-18 17:40:25 -07:00
Günther Deschner
c6fab06902 r25257: When dumping eventlist, display full timestring.
Guenther
(This used to be commit 38eca60913)
2007-10-10 12:30:55 -05:00
Andrew Tridgell
5e54558c6d r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text
(This used to be commit b0132e94fc)
2007-10-10 12:28:22 -05:00