aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/cpp/blaze_util_linux.cc
Commit message (Collapse)AuthorAge
* Ensure that shutdown commands end the server process before completionGravatar mschaller2017-07-12
| | | | | | | | | | | | | | | | | | | | This change ensures that the server process is terminated before the client process terminates, when evaluating a command that shuts down the server. When completing such a command, the server communicates to the client that the server will terminate itself by setting a termination_expected bit in the final RunResponse message. The client then waits up to 60s for the server process to actually terminate. If it does not, then the client SIGKILLs the server. Also makes the gRPC server stop accepting new commands before the shutdown command completes. Drive-by fix to comments on Search{Un,Null}aryOption. RELNOTES: Commands that shut down the server (like "shutdown") now ensure that the server process has terminated before the client process terminates. PiperOrigin-RevId: 161537480
* Raise the maximum number of processes and open files to their maximum.Gravatar jmmv2017-07-11
| | | | | | | | | | | | | | | | | | | Under macOS, the default soft resource limits for open files and concurrent processes are pretty low, but their corresponding hard defaults are reasonable. Because the soft limits are low, Bazel sometimes fails during large builds -- not because of Bazel itself, but because the executed actions do "too much work" or because the --jobs setting was high enough to cause all parallel tasks to exceed the limits. Instead of trying to fix the actions themselves, start by trying to raise the system limits as a best-effort operation. And, given that this code is fairly portable, try to do it on all POSIX systems and not just macOS. Note that, for non-macOS systems, this might still not do what's promised in all circumstances because I'm currently only implementing GetExplicitSystemLimit on macOS. RELNOTES: None. PiperOrigin-RevId: 161401482
* cleanup {get,set,unset}env() functions callsGravatar Thiago Farina2017-07-05
| | | | | | | | Instead, let's reuse the cross-platform {Get,Set,Unset}Env() functions when possible. Change-Id: I40b4ff09c66fe238d5b3d70e49f91705cea64b0c PiperOrigin-RevId: 160870850
* Update ExecuteDaemon() on POSIX systems so that the client writes the PID ↵Gravatar lberki2017-05-10
| | | | | | | | | file and not the server. This is so that the server does as few things as possible before exec() (preferably, nothing) so that we don't accidentally call malloc() which would make it possible to deadlock if the server spawned multiple threads before ExecuteDaemon(). RELNOTES: None. PiperOrigin-RevId: 155603273
* cpp: add PrintWarning() function to errors.hGravatar Thiago Farina2017-05-09
| | | | | | | | | It provides a single and clean way to output warning messages, and replaces the fprintf(stderr, "Warning: ...\n") or fprintf(stderr, "WARNING: ...\n") calls. Change-Id: I2f8a8f659085b9e57a08b5208a8b8f683a7cd72c PiperOrigin-RevId: 155386233
* Bazel client: simplify {Read,Write}File semanticsGravatar Laszlo Csomor2017-03-01
| | | | | | | | | | | | | | | | Introduce a platform-specific file handle type (HANDLE on Windows, int on Linux/Darwin/FreeBSD) so we can get rid of the read_func and write_func functions, since they are always the same everywhere. Also include file_platform.h in file.h, since they are logically the same file (file_platform.h is just the platform-specific part of file.h). -- PiperOrigin-RevId: 148892736 MOS_MIGRATED_REVID=148892736
* Bazel client: remove blaze_util::WhichGravatar Laszlo Csomor2016-12-21
| | | | | | | | | This is only used in blaze_util_linux so move the method there. -- PiperOrigin-RevId: 142652521 MOS_MIGRATED_REVID=142652521
* Bazel client: platform-specific {Read,Write}FileGravatar Laszlo Csomor2016-11-28
| | | | | | | | | | | | | | | | Move blaze::ReadFile and blaze::WriteFile to file.h and file_platform.h (thus into the blaze_util namespace), and update references. This allows us to implement these methods in a platform-specific way. Also move UnlinkPath. See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=140328273
* blaze_utils: fork file handling for platformsGravatar Laszlo Csomor2016-11-09
| | | | | | | | | | | | | | | | | | | This commit repurposes file_posix.cc to be the POSIX API file handling implementation, and adds file_windows.cc for the Win32 API implementations. Furthermore it introduces file_platform.h that declares the interface. Subsequent changes will replace POSIX API calls in the rest of the C++ code with these abstract methods. Motivation: our code is so littered with POSIX-isms that we need an abstraction layer if we hope to compile it with MSVC. -- MOS_MIGRATED_REVID=138615822
* C++ refactor: time getters now return millisecondsGravatar Laszlo Csomor2016-11-08
| | | | | | | | | | | | | | Previously they returned nanoseconds but all call sites converted those to milliseconds. This is not only a simplification of the semantics and renaming of the methods to make the returned units and the purpose clear, but also preparation for the Windows/MSVC implementations of these methods. -- MOS_MIGRATED_REVID=138383956
* Refactor: rename file_linux.* to file_posix.*Gravatar Laszlo Csomor2016-10-05
| | | | | | | | | | | | Subsequent commits will move methods out of src/main/cpp/blaze_util.cc and into file.h or file_<platform>.cc. Many of those methods heavily rely on the POSIX API, and we need to reimplement them against the Win32 API to compile Bazel on Windows using MSVC. -- MOS_MIGRATED_REVID=135128504
* Move blaze_util::Which to standalone library.Gravatar Laszlo Csomor2016-09-29
| | | | | | | | | | | | | | | | | | This method is only used by blaze_util_linux.cc so instead of porting it to Windows, I'm moving it to a separate library. As part of this change I'm creating separate libraries for other sources in //src/main/cpp/util as well, so their dependencies are clearly defined in the BUILD file, plus we can port them one by one. This is part of the effort of compiling Bazel on Windows with the MSVC toolchain. -- MOS_MIGRATED_REVID=134636777
* Roll back commit a34c4febbbdfba6c045598101ca9a491cfde7dd9 in favor of not ↵Gravatar Lukacs Berki2016-09-14
| | | | | | | | | verifying the identity of the process killed on interrupt. When the server dies, the client follows soon after, so this is kind of OK. -- MOS_MIGRATED_REVID=133110872
* More client fixes:Gravatar Lukacs Berki2016-09-13
| | | | | | | | - Use an explicit cast to void to tell the compiler that we are intentionally ignoring return values. - Delete the unused function GetPeerProcessId() -- MOS_MIGRATED_REVID=132970162
* Various minor fixes in the client:Gravatar Lukacs Berki2016-09-09
| | | | | | | | | - Don't call setrlimit() (it was needed to make 32-bit JVMs work with >3GB heaps) - Remove a non-functional way to tweak the Linux scheduler - Cosmetic fixes -- MOS_MIGRATED_REVID=132653426
* Do not print the "server probably died abruptly" warning message.Gravatar Lukacs Berki2016-09-08
| | | | | | | It is not really actionable and doesn't warn the user against real breakages, so there isn't much point. -- MOS_MIGRATED_REVID=132541684
* Don't use fancy STL data structures (including string) in ↵Gravatar Lukacs Berki2016-09-06
| | | | | | | KillServerProcess() so that we don't call malloc() in signal handlers. -- MOS_MIGRATED_REVID=132232499
* Be more lenient with slow-to-react servers.Gravatar Michajlo Matijkiw2016-08-16
| | | | | | | | | | | | | | | | Increase the ping timeout on connect from five to ten seconds. This gives servers which may be suffering from gc pressure or other ailments extra time to respond. On the other end, wait for orphaned servers to really die before proceeding. This prevents race conditions around the delivery of SIGKILL and the starting of the new server. This may make us fail slower when the server is having hard times, however it should give us better determinism, and these conditions should be rare. -- MOS_MIGRATED_REVID=130118918
* Mark output_base and output_user_root to not be backed up by TimeMachine on ↵Gravatar Dave MacLachlan2016-07-20
| | | | | | | | | | | Darwin. This is equivalent to what Xcode does with the directories that it generates as part its builds. fix for https://github.com/bazelbuild/bazel/issues/1514 -- MOS_MIGRATED_REVID=127927131
* Added include requirements for errno, printf, getenvGravatar Douglas Dawson2016-07-14
| | | | | | | | Closes #1419. -- Reviewed-on: https://github.com/bazelbuild/bazel/pull/1419 MOS_MIGRATED_REVID=127326203
* Only tell the user that an old server process was killed if it actually was.Gravatar Lukacs Berki2016-07-14
| | | | | -- MOS_MIGRATED_REVID=127319649
* Remove the check for the existence of the server process in the signal ↵Gravatar Lukacs Berki2016-06-21
| | | | | | | | | handler in the client. This makes Ctrl-C work on Windows somewhat: in particular, in non-batch mode and while no actions are running. -- MOS_MIGRATED_REVID=125318172
* Make the Blaze server kill the previous instance if the start time file ↵Gravatar Lukacs Berki2016-05-04
| | | | | | | | | doesn't exist. It may be an old version that doesn't know how to write them yet. -- MOS_MIGRATED_REVID=121462577
* Linux-specific: check if the stray server process we are about to kill -9 is ↵Gravatar Lukacs Berki2016-05-02
| | | | | | | | | | | actually a server process. This should be implemented for other OSes, too, but OS X seems to lack a procfs and it's not clear how to discover anything about a process based on its PID and of course, Windows is a wholly different cup of tea. More work for #930. -- MOS_MIGRATED_REVID=121262673
* add some missing errno.h and string.h includesGravatar Mostyn Bramley-Moore2015-11-11
| | | | | | -- Reviewed-on: https://github.com/bazelbuild/bazel/pull/571 MOS_MIGRATED_REVID=107471259
* Read $HOME first to determine the home directory (and when not present, fall ↵Gravatar Lukacs Berki2015-10-27
| | | | | | | | | back to getpwuid()) Also a minor compatibility fix in a sed invocation. -- MOS_MIGRATED_REVID=106291639
* Rationalize copyright headersGravatar Damien Martin-Guillerez2015-09-25
| | | | | | | | | | | The headers were modified with `find . -type f -exec 'sed' '-Ei' 's|Copyright 201([45]) Google|Copyright 201\1 The Bazel Authors|' '{}' ';'` And manual edit for not Google owned copyright. Because of the nature of ijar, I did not modified the header of file owned by Alan Donovan. The list of authors were extracted from the git log. It is missing older Google contributors that can be added on-demand. -- MOS_MIGRATED_REVID=103938715
* Use custom util instead of std::to_string.Gravatar Googler2015-07-23
| | | | | | | std::to_string is not avcaliable on mingw. -- MOS_MIGRATED_REVID=98923935
* Cleanup: port.cc should include its header file port.hGravatar Thiago Farina2015-05-18
| | | | | | | | | | | | | port.cc implements sys_ioprio_set() function, but was not including the header that declares it. Also included port.h in blaze_util_linux.cc for iwyu, since that file is using sys_ioprio_set(). -- Change-Id: Ie6130df9ed72e8125d07f72455fc53a03afedbc1 Reviewed-on: https://bazel-review.googlesource.com/#/c/1321/ MOS_MIGRATED_REVID=93868707
* Cleanup: Use the standard types from stdint.h.Gravatar Thiago Farina2015-05-05
| | | | | | | | | Now that our toolchain supports stdint.h, we don't need to provide our custom types ourselves through numbers.h. -- Change-Id: I01de083e735e5cd64bcca723b19c55b9429632b7 MOS_MIGRATED_REVID=92840495
* Cleanup: Do not include unnecessary headers in blaze_util.h.Gravatar Thiago Farina2015-04-28
| | | | | | | | | | | | The header only uses std::string, std::vector, int and char types, and thus all these headers do not need to be included there. If necessary, they should be included in the relevant source files instead. -- Change-Id: Id1849a0f427016dcf732fe6bfc673e599e8d4b14 MOS_MIGRATED_REVID=92192506
* Move blaze_exit_code.h into util/ directory.Gravatar Thiago Farina2015-04-24
| | | | | | | | This is so util/ files do not depend on anything from higer level. -- Change-Id: I522be6722851f25e79d9c2b85275856cbbd978de MOS_MIGRATED_REVID=91882837
* Header cleanups.Gravatar Han-Wen Nienhuys2015-04-22
| | | | | -- MOS_MIGRATED_REVID=91681168
* Cleanup: Build file.cc as part of util library.Gravatar Thiago Farina2015-04-14
| | | | | | | | | | | | | | | | | | | | | | Looks like in the transition it was forgotten to be moved to the new location. As an effect of this change it was discovered that file.cc had an dependency back on blaze_util.cc (from client binary for die/pdie functions). In order to fix that dependency we have had to move die/pdie functions into util library (added errors.(cc|h)) for this. Tested on Linux with the following command lines: $ ./compile.sh $ ./output/bazel build //src/main/cpp:all $ ./output/bazel build //src:bazel $ ./bootstrap_test.sh all -- Change-Id: I70fb1b6189dc5af31f816332d76efe380ef26302 MOS_MIGRATED_REVID=90987514
* Cleanup: Change is IsSharedLibrary() to take a const-reference parameter.Gravatar Thiago Farina2015-04-08
| | | | | | | | This should avoid making unnecessary string copies. -- Change-Id: I655f348ddeb3df47264a899a10d36086d2c2b596 MOS_MIGRATED_REVID=90614260
* Use getpwuid(getuid()) to determine the output root under LinuxGravatar Damien Martin-Guillerez2015-03-24
| | | | | | | | | | Also Fallback the default ouput root to /var/tmp if $HOME is not set under Linux. If $HOME environment variable was not set, Bazel would crash with a std::logic_error. Using getpwuid() make Bazel more resilient to wrong environment. -- MOS_MIGRATED_REVID=89292008
* Use OS-specific caches for output rootGravatar Kristina Chodorow2015-03-23
| | | | | -- MOS_MIGRATED_REVID=89144546
* Update from Google.Gravatar Han-Wen Nienhuys2015-02-25
-- MOE_MIGRATED_REVID=85702957