summaryrefslogtreecommitdiff
path: root/src/basic/rlimit-util.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: use new RET_NERRNO() helper at various placesLennart Poettering2021-11-161-4/+2
|
* tree-wide: do not use (void) asprintfZbigniew Jędrzejewski-Szmek2021-07-091-9/+9
| | | | | | | | | | | | | | | asprintf(3) says that the pointer is "undefined" after a failed call. In the current glibc implementation it is just NULL. In principle the call could return a valid pointer with bad contents or something. We have two styles of error handling: in a majority of cases we would check the return value, but sometimes we used (void) and relied on the pointer not being set. In practice both styles should be equivalent, but gcc doesn't like the second one with -Wunused-result. (Though only sometimes. E.g. on my F34 box I don't get the same warnings as in CI, even though the compiler version is very similar and the compilation options are the same…). It's also nice to be consistent in our code base. So let's always use the first style of error checking.
* rlimit-util: log when falling back setting limitPierre Dubouilh2021-02-151-0/+2
|
* treewide: tighten variable scope in loops (#18372)Susant Sahani2021-01-271-2/+2
| | | | Also use _cleanup_free_ in one more place.
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* tree-wide: drop missing.hYu Watanabe2019-10-311-2/+1
|
* move src/shared/rlimit-util.[ch] → src/basic/Lennart Poettering2018-12-011-0/+410
| | | | | | This is really basic stuff and in a follow-up commit will use it all across the codebase, including in process-util.[ch] which is in src/basic/. Hence let's move it back to src/basic/ itself.
* Move various files that don't need to be in basic/ to shared/Zbigniew Jędrzejewski-Szmek2018-11-201-391/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This doesn't have much effect on the final build, because we link libbasic.a into libsystemd-shared.so, so in the end, all the object built from basic/ end up in libsystemd-shared. And when the static library is linked into binaries, any objects that are included in it but are not used are trimmed. Hence, the size of output artifacts doesn't change: $ du -sb /var/tmp/inst* 54181861 /var/tmp/inst1 (old) 54207441 /var/tmp/inst1s (old split-usr) 54182477 /var/tmp/inst2 (new) 54208041 /var/tmp/inst2s (new split-usr) (The negligible change in size is because libsystemd-shared.so is bigger by a few hundred bytes. I guess it's because symbols are named differently or something like that.) The effect is on the build process, in particular partial builds. This change effectively moves the requirements on some build steps toward the leaves of the dependency tree. Two effects: - when building items that do not depend on libsystemd-shared, we build less stuff for libbasic.a (which wouldn't be used anyway, so it's a net win). - when building items that do depend on libshared, we reduce libbasic.a as a synchronization point, possibly allowing better parallelism. Method: 1. copy list of .h files from src/basic/meson.build to /tmp/basic 2. $ for i in $(grep '.h$' /tmp/basic); do echo $i; git --no-pager grep "include \"$i\"" src/basic/ 'src/lib*' 'src/nss-*' 'src/journal/sd-journal.c' |grep -v "${i%.h}.c";echo ;done | less
* rlimit-util: don't call setrlimit() needlessly if it wouldn't change anythingLennart Poettering2018-10-161-2/+9
| | | | Just a tiny tweak to avoid generating an error if there's no need to.
* core: add a new call for bumping RLIMIT_NOFILE to "high" valuesLennart Poettering2018-10-161-0/+22
| | | | | | | | | | | | | | | | | | | | Following discussions with some kernel folks at All Systems Go! it appears that file descriptors are not really as expensive as they used to be (both memory and performance-wise) and it should thus be OK to allow programs (including unprivileged ones) to have more of them without ill effects. Unfortunately we can't just raise the RLIMIT_NOFILE soft limit globally for all processes, as select() and friends can't handle fds >= 1024, and thus unexpecting programs might fail if they accidently get an fd outside of that range. We can however raise the hard limit, so that programs that need a lot of fds can opt-in into getting fds beyond the 1024 boundary, simply by bumping the soft limit to the now higher hard limit. This is useful for all our client code that accesses the journal, as the journal merging logic might need a lot of fds. Let's add a unified function for bumping the limit in a robust way.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* rlimit-util: tweak setrlimit_closest() a bitLennart Poettering2018-05-171-0/+5
| | | | | | | POSIX doesn't declare too clearly how RLIM_INFINITY is set. Let's hence filter it out explicitly early on, just as safety precaution should it be defined weirdly on some arch, for example negative or below the maximum value of the rlim_t type.
* rlimit-util: introduce setrlimit_closest_all()Lennart Poettering2018-05-171-0/+26
| | | | This new call applies all configured resource limits in one.
* rlimit-util: add a common destructor call for arrays of struct rlimitLennart Poettering2018-05-171-0/+10
|
* rlimit-util: rework rlimit_{from|to}_string() to work without "Limit" prefixLennart Poettering2018-05-171-16/+32
| | | | | let's make the call more generic, so that we can also easily use it for parsing "RLIMIT_xyz" style constants.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* rlimit: don't assume getrlimit() always succeedsLennart Poettering2017-09-221-1/+2
| | | | | | In times of seccomp it might very well fail, and given that we return failures from this function anyway, let's also propagate getrlimit() failures, just to be safe.
* Rename formats-util.h to format-util.hZbigniew Jędrzejewski-Szmek2016-11-071-1/+1
| | | | | | We don't have plural in the name of any other -util files and this inconsistency trips me up every time I try to type this file name from memory. "formats-util" is even hard to pronounce.
* core: make parsing of RLIMIT_NICE aware of actual nice levelsLennart Poettering2016-04-291-1/+51
|
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* basic: add new rlimit_format() callLennart Poettering2016-02-011-0/+24
| | | | This formats a struct rlimit the way rlimit_parse() expects it.
* core: move parsing of rlimits into rlimit-util.[ch]Lennart Poettering2016-02-011-0/+176
| | | | This way we can reuse it for parsing rlimit settings in "systemctl set-property" and related commands.
* basic: re-sort includesThomas Hindoe Paaboel Andersen2015-12-011-1/+1
| | | | | My previous patch to only include what we use accidentially placed the added inlcudes in non-sorted order.
* basic: include only what we useThomas Hindoe Paaboel Andersen2015-11-301-1/+4
| | | | | This is a cleaned up result of running iwyu but without forward declarations on src/basic.
* util-lib: move string table stuff into its own string-table.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split out resource limits related calls into rlimit-util.[ch]Lennart Poettering2015-10-271-0/+69