summaryrefslogtreecommitdiffstats
path: root/lib/workqueue.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* lib, zebra: Add ability to tell thread system to ignore late timersDonald Sharp2022-01-201-2/+3
| | | | | | | Add a thread_ignore_late_timer(struct thread *thread) function that allows thread.c to ignore when timers are late to the party. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* *: require semicolon after DEFINE_MTYPE & coDavid Lamparter2021-03-171-3/+3
| | | | | | | | | | | | | | | | | Back when I put this together in 2015, ISO C11 was still reasonably new and we couldn't require it just yet. Without ISO C11, there is no "good" way (only bad hacks) to require a semicolon after a macro that ends with a function definition. And if you added one anyway, you'd get "spurious semicolon" warnings on some compilers... With C11, `_Static_assert()` at the end of a macro will make it so that the semicolon is properly required, consumed, and not warned about. Consistently requiring semicolons after "file-level" macros matches Linux kernel coding style and helps some editors against mis-syntax'ing these macros. Signed-off-by: David Lamparter <equinox@diac24.net>
* lib: Remove #if 0 codeDonald Sharp2021-01-281-5/+0
| | | | | | | Just some more dead code that has been sitting unused for a very long time. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* * : update signature of thread_cancel apiMark Stapp2020-10-231-2/+2
| | | | | | | | Change thread_cancel to take a ** to an event, NULL-check before dereferencing, and NULL the caller's pointer. Update many callers to use the new signature. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* lib: Fix workqueue error function callbackStephen Worley2019-04-181-1/+1
| | | | | | | | After exceeding the max retry number for a thread, we were passing the data rather than the work_queue_item struct. Signed-off-by: Stephen Worley <sworley@cumulusnetworks.com>
* lib: STAILQ_FOREACH_SAFE never gives a null elemQuentin Young2019-02-261-1/+1
| | | | | | So don't check it Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* libs: remove useless static work_queue_free helperMark Stapp2019-02-071-10/+4
| | | | | | | Collapse the old static free function into the actual public function that was using it (and the only user of it.) Signed-off-by: Mark Stapp <mjs@voltanet.io>
* libs: remove deprecated workqueue apiMark Stapp2019-02-061-1/+4
| | | | | | Remove deprecated api from workqueue module. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* libs: support timeout for workqueue retriesMark Stapp2018-12-131-7/+22
| | | | | | | | | Support an optional timeout/delay for use when a workqueue determines that it is blocked, instead of retrying immediately. Also, schedule as an 'event' instead of a 'timer' when using a zero timeout value. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* *: ALLOC calls cannot failDonald Sharp2018-08-111-7/+1
| | | | | | | | There is no need to check for failure of a ALLOC call as that any failure to do so will result in a assert happening. So we can safely remove all of this code. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* bgpd lib ospfd pimd ripngd: null chk (PVS-Studio)F. Aragon2018-07-031-1/+2
| | | | Signed-off-by: F. Aragon <paco@voltanet.io>
* bgpd, lib, zebra: Switch to work_queue_free_and_nullDonald Sharp2018-03-091-1/+7
| | | | | | | | | The work_queue_free function free'd up the wq pointer but did not set it too NULL. This of course causes situations where we may use the work_queue after it is freed. Let's modify the work_queue to set the pointer for you. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: conform with COMMUNITY.md formatting rules, via 'make indent'Lou Berger2018-03-061-3/+4
| | | | Signed-off-by: Lou Berger <lberger@labn.net>
* lib: Free workqueue memory leak on freeDonald Sharp2017-10-111-16/+22
| | | | | | | | | | | When free'ing the workqueue if you have items on the workqueue you should free the memory associated with it. Additionally move the work_queue_item_remove function to allow for static to be awesome Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: use clang's 'ForEachMacros' format style optionRenato Westphal2017-09-151-1/+1
| | | | | | | | | | | | | This fixes the broken indentation of several foreach loops throughout the code. From clang's documentation[1]: ForEachMacros: A vector of macros that should be interpreted as foreach loops instead of as function calls. [1] http://clang.llvm.org/docs/ClangFormatStyleOptions.html Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: cleanup the work queue implementationJorge Boncompte2017-08-171-31/+23
| | | | | | | | Convert the work queue implementation to not use the generic linked list to mantain the item list and use instead a simple queue from queue.h that does not allocate memory for each node. Signed-off-by: Jorge Boncompte <jbonor@gmail.com>
* *: reindentreindent-master-afterwhitespace / reindent2017-07-171-301/+272
| | | | | | indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: fix GCC 7 switch/case fallthrough warningsDavid Lamparter2017-07-141-9/+9
| | | | | | Need a comment on these. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: ditch vty_outln(), part 1 of 2David Lamparter2017-07-131-5/+5
| | | | Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: use vty_outlnQuentin Young2017-06-291-11/+8
| | | | | | Saves 400 lines Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: remove THREAD_BACKGROUNDQuentin Young2017-06-081-2/+2
| | | | | | | it's just an alias for a millisecond timer used in exactly nine places and serves only to complicate Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: make consistent & update GPLv2 file headersDavid Lamparter2017-05-151-4/+3
| | | | | | | | | | | The FSF's address changed, and we had a mixture of comment styles for the GPL file header. (The style with * at the beginning won out with 580 to 141 in existing files.) Note: I've intentionally left intact other "variations" of the copyright header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: update thread_add_* callsQuentin Young2017-05-091-2/+3
| | | | | | | | | | | | Pass pointer to pointer instead of assigning by return value. See previous commit message. To ensure that the behavior stays functionally correct, any assignments with the result of a thread_add* function have been transformed to set the pointer to null before passing it. These can be removed wherever the pointer is known to already be null. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: remove THREAD_ON macros, add nullity checkQuentin Young2017-05-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | The way thread.c is written, a caller who wishes to be able to cancel a thread or avoid scheduling it twice must keep a reference to the thread. Typically this is done with a long lived pointer whose value is checked for null in order to know if the thread is currently scheduled. The check-and-schedule idiom is so common that several wrapper macros in thread.h existed solely to provide it. This patch removes those macros and adds a new parameter to all thread_add_* functions which is a pointer to the struct thread * to store the result of a scheduling call. If the value passed is non-null, the thread will only be scheduled if the value is null. This helps with consistency. A Coccinelle spatch has been used to transform code of the form: if (t == NULL) t = thread_add_* (...) to the form thread_add_* (..., &t) The THREAD_ON macros have also been transformed to the underlying thread.c calls. Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
* *: make DEFUN installations file-localDavid Lamparter2016-12-011-0/+6
| | | | | | | | | | | | | | This moves all install_element calls into the file where the DEFUNs are located. This fixes several small related bugs: - ospf6d wasn't installing a "no interface FOO" command - zebra had a useless copy of "interface FOO" - pimd's copy of "interface FOO" was not setting qobj_index, which means "description LINE" commands would fail with an error The next commit will do the actual act of making "foo_cmd" static. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* *: split & distribute memtypes and stop (re|ab)using lib/ MTYPEsDavid Lamparter2016-09-191-0/+4
| | | | | | | | | | | | | | | | | | | This is a rather large mechanical commit that splits up the memory types defined in lib/memtypes.c and distributes them into *_memory.[ch] files in the individual daemons. The zebra change is slightly annoying because there is no nice place to put the #include "zebra_memory.h" statement. bgpd, ospf6d, isisd and some tests were reusing MTYPEs defined in the library for its own use. This is bad practice and would break when the memtype are made static. Acked-by: Vincent JARDIN <vincent.jardin@6wind.com> Acked-by: Donald Sharp <sharpd@cumulusnetworks.com> [CF: rebased for cmaster-next] Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Signed-off-by: Christian Franke <chris@opensourcerouting.org>
* isisd, lib, vtysh: Allow extract.pl to fully workDonald Sharp2016-09-171-5/+5
| | | | | | | | | The regular expression for finding DEFUN/ALIAS in extract.pl looks for "DEFUN (" or "ALIAS (" if the *.c file does not have this then it will just silently ignore the cli. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* *: make sure zebra.h is always included firstDavid Lamparter2016-06-091-1/+1
| | | | | | | | | zebra.h pulls in config.h, which results in fiddling with things like __FILE_OFFSET_BITS. It must always be included first, in order to set flags that influence the compiler via <features.h>. Signed-off-by: David Lamparter <equinox@opensourcerouting.org> (cherry picked from commit 821df2cf18e5978cc7ab532a8695444380d08270)
* lib/workqueue: Add trivial work_queue_is_scheduled helperPaul Jakma2016-06-031-0/+6
| | | | (cherry picked from commit 13c2a3db503fde67f647fa58fd4e1077517ebb5c)
* Fix most compiler warnings in default GCC build.Paul Jakma2016-05-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix lots of warnings. Some const and type-pun breaks strict-aliasing warnings left but much reduced. * bgp_advertise.h: (struct bgp_advertise_fifo) is functionally identical to (struct fifo), so just use that. Makes it clearer the beginning of (struct bgp_advertise) is compatible with with (struct fifo), which seems to be enough for gcc. Add a BGP_ADV_FIFO_HEAD macro to contain the right cast to try shut up type-punning breaks strict aliasing warnings. * bgp_packet.c: Use BGP_ADV_FIFO_HEAD. (bgp_route_refresh_receive) fix an interesting logic error in (!ok || (ret != BLAH)) where ret is only well-defined if ok. * bgp_vty.c: Peer commands should use bgp_vty_return to set their return. * jhash.{c,h}: Can take const on * args without adding issues & fix warnings. * libospf.h: LSA sequence numbers use the unsigned range of values, and constants need to be set to unsigned, or it causes warnings in ospf6d. * md5.h: signedness of caddr_t is implementation specific, change to an explicit (uint_8 *), fix sign/unsigned comparison warnings. * vty.c: (vty_log_fixed) const on level is well-intentioned, but not going to fly given iov_base. * workqueue.c: ALL_LIST_ELEMENTS_RO tests for null pointer, which is always true for address of static variable. Correct but pointless warning in this case, but use a 2nd pointer to shut it up. * ospf6_route.h: Add a comment about the use of (struct prefix) to stuff 2 different 32 bit IDs into in (struct ospf6_route), and the resulting type-pun strict-alias breakage warnings this causes. Need to use 2 different fields to fix that warning? general: * remove unused variables, other than a few cases where they serve a sufficiently useful documentary purpose (e.g. for code that needs fixing), or they're required dummies. In those cases, try mark them as unused. * Remove dead code that can't be reached. * Quite a few 'no ...' forms of vty commands take arguments, but do not check the argument matches the command being negated. E.g., should 'distance X <prefix>' succeed if previously 'distance Y <prefix>' was set? Or should it be required that the distance match the previously configured distance for the prefix? Ultimately, probably better to be strict about this. However, changing from slack to strict might expose problems in command aliases and tools. * Fix uninitialised use of variables. * Fix sign/unsigned comparison warnings by making signedness of types consistent. * Mark functions as static where their use is restricted to the same compilation unit. * Add required headers * Move constants defined in headers into code. * remove dead, unused functions that have no debug purpose. (cherry picked from commit 7aa9dcef80b2ce50ecaa77653d87c8b84e009c49) Conflicts: bgpd/bgp_advertise.h bgpd/bgp_mplsvpn.c bgpd/bgp_nexthop.c bgpd/bgp_packet.c bgpd/bgp_route.c bgpd/bgp_routemap.c bgpd/bgp_vty.c lib/command.c lib/if.c lib/jhash.c lib/workqueue.c ospf6d/ospf6_lsa.c ospf6d/ospf6_neighbor.h ospf6d/ospf6_spf.c ospf6d/ospf6_top.c ospfd/ospf_api.c zebra/router-id.c zebra/rt_netlink.c zebra/rt_netlink.h
* lib: lib-warnings.patchDonald Sharp2015-05-201-4/+8
| | | | | | Remove compile warnings for the lib directory Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com> Reviewed-by:
* Some small enhancements to thread and workqueue libraries in zebra:Donald Sharp2015-05-201-11/+26
| | | | | | | | | | - Allow work queues to specify the yield duration for corresponding background thread - Support using specified yield duration in thread yielding - During work queue processing, if using a single list element with a meta-queue (like done in Zebra), do not exit after each element is processed, instead update the next-node upon a WQ_REQUEUE so that the WQ processing continues and is terminated by the yield logic. - Enhance work queue debug output
* general: remove inline qualifiers and move in-header functions to objectsPaul Jakma2012-01-061-1/+1
| | | | | | * (general) Move functions in headers into files, to be compiled into shared object files. Remove inline qualifier from functions. Let the compiler do the work.
* lib: Make workqueue more conservative about ramping upPaul Jakma2010-12-081-8/+9
| | | | | | * workqueue.c: (work_queue_run) Err more on the side of keeping granularity down, by being more conservative about increasing it. Also, fix mispelling.
* [bgp] Fix crash on SIGHUP, deref of freed workqueuesSteve Hill2009-06-021-0/+3
| | | | | | | * lib/workqueue.c: free-ing workqueues had never been tested obviously, queue's thread was not being stopped * bgpd/bgpd.c: null out freed workqueues, to prevent acting on freed workqueues
* + initial edition of meta-queue for RIB updates processing (bug #431)Denis Ovsienko2008-06-021-14/+2
|
* + fixed bug #418 (changing address on an existing interface doesn't cause ↵Denis Ovsienko2007-11-121-5/+19
| | | | existing static routes to be revalidated)
* [lib] Trivial: fix line lengths of a comment in workqueu.cPaul Jakma2006-03-301-2/+3
| | | | | | 2006-03-30 Paul Jakma <paul.jakma@sun.com> * workqueue.c: (work_queue_run) fix line length of comment
* [lib/workqueue] remove the useless 'delay' factor.paul2006-02-021-25/+12
| | | | | | | | | | | | | | 2006-02-02 Paul Jakma <paul.jakma@sun.com> * workqueue.h: (struct work_queue) Remove the delay field. It served no purpose and just introduced bad behaviour. Should be excised before its allowed to escape into 1.0. This removes need for the 'flood' and runs_since_clear fields. * workqueue.c: (general) excise delay factor between queue runs, hence the 'flood' crap too.. See above. * bgp_route.c: (bgp_{clear_node,process}_queue_init) delay field is removed from workqueue spec.
* [workqueue] Update workqueue users callbacks to additional argumentspaul2005-11-141-2/+2
| | | | | | | | | | | | | | 2005-11-14 Paul Jakma <paul.jakma@sun.com> * (general) pass struct work-queue to callback functions. * workqueue.h: (struct work_queue) move the state flag variables to end. Add an opaque pointer to spec, for user-data global to the queue. Pass reference to work_queue to all callbacks. * workqueue.c: (work_queue_item_remove) pass ref to workqueue to user callbacks. (work_queue_run) ditto.
* 2005-11-14 Paul Jakma <paul.jakma@sun.com>paul2005-11-141-11/+27
| | | | | | | | | | | | | | | | | | | | | * (general) Add state to detect queue floods. There's no sense trying to be sparing of CPU resources, if the queue is flooding and using ever more memory resources. we should just get on with clearing the queue. The sense of delay and hold were wrong way around, fix. * workqueue.h: (struct work_queue) Add status bitfield. Add 'flood' integer to workqueue spec. Add runs_since_clear counter to workqueue. * workqueue.c: (work_queue_new) set defaults for delay, hold and flood. (work_queue_add) initial schedule should use delay, not hold. (show_work_queues) Print flood field, conserve whitespace. (work_queue_unplug) use delay, not hold. (work_queue_run) consecutive runs should be seperated by hold time, not delay. Keep track of number of consecutive runs, go into 'overdrive' if queue is being flooded, we can't avoid making heavy use of resources, better to use CPU than ever more RAM.
* 2005-05-23 Paul Jakma <paul@dishone.st>paul2005-05-231-18/+65
| | | | | | | | | | | | | | | | | | | | | | | | * workqueue.h: Add a WQ_QUEUE_BLOCKED item_status return code, to allow a queue function to indicate the queue is not ready/blocked - rather than any problem with the item at hand. Add a notion of being able to 'plug' and 'unplug' a queue. Add helpers to plug/unplug a queue. Add a completion callback, to be called when a queue is emptied. * workqueue.c: (work_queue_new) remove useless list_free. (work_queue_schedule) new internal helper function to schedule queue, if appropriate. (work_queue_add) use work_queue_schedule (show_work_queues) Print 'P' if queue is plugged. (work_queue_plug) new API function, plug a queue - ie prevent it from 'drained' / processed / scheduled. (work_queue_unplug) unplug a queue, allowing it to be drained / scheduled / processed again. (work_queue_run) Add support for WQ_QUEUE_BLOCKED. Add comment for RETRY_NOW case. Make hysteris more aggresive in ramping up granularity, improves performance significantly. Add support for calling completion callback when queue is emptied, possibly useful for knowing when to unplug a queue.
* 2005-04-27 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs2005-04-271-3/+0
| | | | * workqueue.c (show_work_queues): Remove unused gettimeofday call.
* 2005-04-27 Paul Jakma <paul.jakma@sun.com>paul2005-04-271-10/+9
| | | | | | | | | | * workqueue.h: (struct work_queue_item) change retry_count to ran, its a count of number item has been run. * workqueue.c: (show_work_queues) Fix formating of slightly bugfix: fix SIGFPE if wq->runs is 0. (work_queue_run) retry logic was slightly wrong. cycles.best is 0 initialy, granularity is 1, so update best if cycles >= granularity, not just >.
* 2005-04-25 Paul Jakma <paul.jakma@sun.com>paul2005-04-251-0/+329
* workqueue.{c,h}: Helper API for setting up and running queues via background threads. * command.c: install the 'show workqueues' command * memtypes.c: Add work queue mtypes, and a rib-queue type for a zebra rib work queue. * memtypes.h: Updated to match memtypes.c * Makefile.am: Add new workqueue files to build.