aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/main/cpp/blaze.cc
Commit message (Collapse)AuthorAge
* fix declaration of Pipe variableGravatar Thiago Farina2016-12-14
| | | | | | | | | | | While at it fix a typo of "receive" and fix some other documentation comments. -- Change-Id: Ifb7df972200627730114d6cf751033c0d5e3bc46 Reviewed-on: https://cr.bazel.build/7710 PiperOrigin-RevId: 142015037 MOS_MIGRATED_REVID=142015037
* Record correct exit code for uncaught exceptions in async threads.Gravatar Chloe Calvarin2016-12-13
| | | | | | | | | | Async threads are divorced from the server's error-reporting mechanism. In the event of a server shutdown originating in an async-thread, write the exit code to a file that can be read by the client. -- PiperOrigin-RevId: 141920284 MOS_MIGRATED_REVID=141920284
* Description redacted.Gravatar Julio Merino2016-12-09
| | | | | | -- PiperOrigin-RevId: 141483567 MOS_MIGRATED_REVID=141483567
* move MakeDirectories() into file_platform.hGravatar Thiago Farina2016-12-07
| | | | | | | | | | | | | | This way we can remove the dependency on blaze_util (which is Bazel's client specific) from singlejar. This work was made possible by commit 49970e0136d0: ("Bazel client: platform-specific {Read,Write}File"). -- Change-Id: I6e95fb9119a271e4d48cbe2eefc1d5354ee188aa Reviewed-on: https://cr.bazel.build/7650 PiperOrigin-RevId: 141294165 MOS_MIGRATED_REVID=141294165
* Bazel client: make it compile with MSVCGravatar Laszlo Csomor2016-11-28
| | | | | | | | | | | | | | | | | | | | | | | | | Final modifications to the Bazel client code so we can compile //src/main/cpp/...:all using MSVC. Yay! We still have some dependencies that don't compile with MSVC, namely Ijar, build-runfiles, process-wrapper, and process-tools. Still, this change is a huge success, because now we can add regression tests to prevent people from introducing breaking changes to the client that would break Windows/MSVC compilation. It's important to point out that we can only build this library for now, most functions in file_windows.cc and blaze_util_windows.cc have an empty body (they just call `pdie`). See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=140348351
* 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
* Bazel client: platform-dependent signal handlingGravatar Laszlo Csomor2016-11-24
| | | | | | | | | | Move the signal handling code from blaze.cc into blaze_util_<platform>. See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=140134781
* Bazel client: MakeCanonical into file_<platform>Gravatar Laszlo Csomor2016-11-24
| | | | | | | | | | | | Move MakeCanonical into platform-specific files. Also change the signature of blaze.cc:CheckBinaryPath to return the binary path instead of mutating `globals`. See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=140128173
* Bazel client: depend less on <unistd.h>Gravatar Laszlo Csomor2016-11-24
| | | | | | | | | | | | | | | | | We moved most of the functionality (e.g. _exit, SetupStreams) into blaze_util_<platform> or changed to alternative functions (fwrite + stderr instead of write + STDERR_HANDLE). This change brings us closer to compiling blaze.cc with MSVC. We still have to move signal handlers out of blaze.cc as well as code dealing with the server PID. See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=140123945
* Bazel client: delete and don't use the server.pidGravatar Laszlo Csomor2016-11-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Upon startup the Bazel client checks if there's already a running server process and if so then connects to it. We achieve this by checking if there's a symlink in the server directory called served.pid, pointing to /proc/<server_pid>. If so, we read the symlink's target and extract the PID; otherwise we check if there's a file in the server's directory (server.pid.txt) that contains the PID and read it from there. Since the PID file is always there, we don't need the symlink, plus on Windows we don't support symlinks anyway, which is the real motivation for this change. Just ignoring the PID symlink is not enough, we need to actively delete it so that switching between Bazel versions (one that writes a PID symlink and one that doesn't) won't result in having a symlink and PID file with different PIDs and clients trying to kill the wrong server process / not killing one that they should. See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=140117287
* Adds logging functionality to the bazel client, which will be activated in a ↵Gravatar Chloe Calvarin2016-11-23
| | | | | | | later change. -- MOS_MIGRATED_REVID=139951184
* Bazel client: reduce dependency on POSIX APIGravatar Laszlo Csomor2016-11-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We can now compile blaze_util_windows.cc with MSVC, yay! (when building //src:bazel --cpu=x64_windows_msvc -k). There are a lot of #ifdef's and TODOs so this is a modest victory for now. In this change: - change blaze::MakeDirectories to return bool instead of int, since that's how it was used anyway, and to expect the permission mask as unsigned int instead of mode_t, since the former is good enough and compatible with mode_t on POSIX while mode_t is not defined on Windows - move blaze::MakeDirectories into blaze_util_<platform> - implement envvar-handling in blaze_util_<platform> and use it everywhere See https://github.com/bazelbuild/bazel/issues/2107 -- MOS_MIGRATED_REVID=139887503
* Bazel client: create a wrapper around Unix pipesGravatar Laszlo Csomor2016-11-18
| | | | | | | | | This allows implementing pipe-handling in a platform-specific way. Windows also supports pipes but through its own API. -- MOS_MIGRATED_REVID=139564316
* Bazel client: reduce dependency on <unistd.h>Gravatar Laszlo Csomor2016-11-18
| | | | | | | | | | | | | | | | | | In this change: - rename WriteFileToStreamOrDie to WriteFileToStderrOrDie (since we only ever used it for stderr) - replace open/write/read/close operations with blaze_util::ReadFile/WriteFile - wrap ToString(getpid()) in a utility function - move SyncFile to file_<platform> -- MOS_MIGRATED_REVID=139560397
* Bazel client: no longer needs <utime.h>Gravatar Laszlo Csomor2016-11-17
| | | | | | | | | | | | Also remove a lot of unused header files. The only remaining header file not available on Windows is <unistd.h>, but cutting that dependency will be more complicated because we use read/write and similar I/O functions from it. -- MOS_MIGRATED_REVID=139439791
* Bazel client: no more `stat` usageGravatar Laszlo Csomor2016-11-17
| | | | | -- MOS_MIGRATED_REVID=139436876
* Windows: respect --output_user_rootGravatar Laszlo Csomor2016-11-16
| | | | | | | Fixes https://github.com/bazelbuild/bazel/issues/2096 -- MOS_MIGRATED_REVID=139322001
* Bazel client: platform-dependent GetHashedBaseDirGravatar Laszlo Csomor2016-11-16
| | | | | | | | | | Move the hashed base directory computation logic into blaze_util_<platform>.cc in order to clean up the call site and move platform-dependent code out the client's main file. -- MOS_MIGRATED_REVID=139319487
* Bazel client: implement directory tree walkingGravatar Laszlo Csomor2016-11-16
| | | | | | | | | | | | | | | | | | | | | | This change: - merges the //src/{main,test}/cpp:file and //src/{main,test}/cpp:file_platform libraries because "file" and "file_platform" need each other and this makes logical sense anyway - implements a function in file_<platform> to run a custom function on every child of a directory - implements a function in file.cc to recursively traverse a directory tree, based on the previosly mentioned function - removes the corresponding logic from the Bazel client to make it more portable -- MOS_MIGRATED_REVID=139309562
* Refactor the logic that is used to retry client timeouts a bit so that the ↵Gravatar Lukacs Berki2016-11-15
| | | | | | | attempts take into account the fact that failed connection attempts can take a long time. -- MOS_MIGRATED_REVID=139199883
* Bazel client: wrap some POSIX functionsGravatar Laszlo Csomor2016-11-10
| | | | | | | | | | | | | | This change: - starts using blaze_util::CanAccess and blaze_util::PathExists instead of access(2) - implements and starts using blaze_util::GetCwd instead of getcwd(2) - implements and starts using blaze_util::ChangeDirectory instead of chdir(2) - adds tests for the new wrapper methods -- MOS_MIGRATED_REVID=138750297
* Add two startup options:Gravatar Lukacs Berki2016-11-08
| | | | | | | | - --client_debug that turns out debug logging from the client - --connect_timeout_secs that controls the timeout of the initial Ping() RPC from the client to the server -- MOS_MIGRATED_REVID=138491791
* 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
* Description redacted.Gravatar Luis Fernando Pino Duque2016-11-02
| | | | | -- MOS_MIGRATED_REVID=137944374
* remove other AF_UNIX referencesGravatar Thiago Farina2016-11-02
| | | | | | | | | | | Now this time in the client documentation, since they are not true anymore as the gRPC mechanism is always the default and there is no other mechanism to choose. -- Change-Id: I59d2cf9276764c32b9b28bf5dc2c0ff6777cec40 Reviewed-on: https://bazel-review.googlesource.com/#/c/7031/ MOS_MIGRATED_REVID=137925682
* remove references to "server.socket" fileGravatar Thiago Farina2016-10-31
| | | | | | | | | | | | The C++ client now talks to the Java server through protobuf messages using the RPC mechanism provided by grpc, so this AF_UNIX socket file is not used anymore for the communication between them since commit a3c4833dc24b: ("Remove support for using AF_UNIX..."). -- Change-Id: Ic71e4c65ebb6bb2e661128635c2440007feaf5f6 Reviewed-on: https://bazel-review.googlesource.com/#/c/7030/ MOS_MIGRATED_REVID=137679905
* extract a function to return the embedded binaries root directoryGravatar Thiago Farina2016-10-28
| | | | | | | | | | This allow us to keep this logic in one place and add a documentation for what it means (making it more in sync with its Java counterpart). -- Change-Id: I20ecfa6ea2cd3129a2f7a920c3bffe532f664a90 Reviewed-on: https://bazel-review.googlesource.com/#/c/6990/ MOS_MIGRATED_REVID=137504319
* Clarify how startup options are conveyed between the client and the server.Gravatar Lukacs Berki2016-10-27
| | | | | -- MOS_MIGRATED_REVID=137266505
* Ignore the environment variable "http_proxy" so that it doesn't interfere ↵Gravatar Lukacs Berki2016-10-25
| | | | | | | with the gRPC-based communication between the Bazel client and server. -- MOS_MIGRATED_REVID=137138408
* cpp: remove unused functions after AF_UNIX refactoringGravatar Thiago Farina2016-10-24
| | | | | | | | | | With the removal of AF_UNIX code by commit a3c4833dc24b: ("Remove support for using AF_UNIX...") these function were left unused. -- Change-Id: I84b03bb7e168c22969d7fd1f35decccbc4a54b52 Reviewed-on: https://bazel-review.googlesource.com/#/c/6790/ MOS_MIGRATED_REVID=137002014
* cpp: header hygienizationGravatar Thiago Farina2016-10-18
| | | | | | | | | | | * remove "using std::" declarations from header files * add missing "std::" to some string declarations at some header files * add "using std::string;" to some source files where necessary -- Change-Id: Ib64f62b5add499d6171fa922227194ac992fa542 Reviewed-on: https://bazel-review.googlesource.com/#/c/6630/ MOS_MIGRATED_REVID=136355671
* Remove support for using AF_UNIX to communicate between the Bazel cient and ↵Gravatar Lukacs Berki2016-10-07
| | | | | | | | | the Bazel server. RELNOTES[INC]: --command_port=-1 to use AF_UNIX for client/server communications is not supported anymore. -- MOS_MIGRATED_REVID=135355673
* cpp: refactoring blaze_globals.hGravatar Thiago Farina2016-10-07
| | | | | | | | | | | * drop "blaze_" prefix (like it was done with statup_options.h) * add a constructor to initalize the data members * rename the header file to global_variables.h to match the struct in there. -- Change-Id: I8c9f89f5d07c9a064bf1999c7bfb6d617d72818a Reviewed-on: https://bazel-review.googlesource.com/6370 MOS_MIGRATED_REVID=135342354
* --Gravatar Googler2016-09-27
| | | | MOS_MIGRATED_REVID=134334656
* Remove a comment that says we can remove some obsolete code.Gravatar Lukacs Berki2016-09-21
| | | | | | | | | Spurred by Thiago's change in the area, I figured I'll try removing the PID symlink, but then I realized that this won't work, because the code currently gives precedence to the symlink, which means that if a server that writes both is replaced with a server that only writes the text file, the contents of the text file will not be read. Also note that in Bazel, long jumps between server versions are much more possible than internally, so the cleanup is just not worth the risk, which is sad. -- MOS_MIGRATED_REVID=133820484
* Use nanosleep(2) instead of poll(2) to sleep.Gravatar Chongyu Zhu2016-09-21
| | | | | | | | | | | | | Starting with macOS Sierra developer beta 4, the behavior of poll(2) was changed, such that poll(2) will return immediately regardless the timeout if there is no file descriptor. This fixes #1767. And, this should be a better solution for Homebrew/homebrew-core#5041. Closes #1803. -- Reviewed-on: https://github.com/bazelbuild/bazel/pull/1803 MOS_MIGRATED_REVID=133816294
* cpp: convert ServerPidFile() and ServerPidSymlink() into constantsGravatar Thiago Farina2016-09-21
| | | | | | | | | | | These two functions have no logic inside it, they just return a string, and a string that does not change, so they might be better expressed as real C/C++ constants. This might as well generate some better (and less) code anyway. -- Change-Id: I78673c537c17c2665a74c5778e45a4d41a5f7b50 Reviewed-on: https://bazel-review.googlesource.com/#/c/6114 MOS_MIGRATED_REVID=133805201
* Description redacted.Gravatar Laurent Le Brun2016-09-21
| | | | | -- MOS_MIGRATED_REVID=133693782
* Allow configuring writing of command.logGravatar Michajlo Matijkiw2016-09-19
| | | | | | | | Sometimes, especially in the case of a lot of output, one may not want to write everything twice. -- MOS_MIGRATED_REVID=133388416
* Roll-forward of the startup options refactoring.Gravatar Julio Merino2016-09-15
| | | | | | | | | | | | | | | This CL is a verbatim reproduction of the following CLs, modulo adjustments to cope with changes at HEAD: * commit 4a45d92130a6b1306a3840d006df165b8040a6cf: Use inheritance to support site-specific options. * commit dfb2c73eda3d2dd8787ea9b2d0a03b49dfa2acc5: Inject the product name via the per-product main.cc files. * unknown commit: Remove the internal/external startup_options duality. The cause that triggered the rollbacks was fixed separately in commit 69a8d7205287bedf3a6140ec9327e2fad1758c22 as prepartory work for this roll-forward, so things should work now. -- MOS_MIGRATED_REVID=133139218
* 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
* Rollback of startup options changes.Gravatar Greg Estren2016-09-13
| | | | | -- MOS_MIGRATED_REVID=132940326
* 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
* Use inheritance to support site-specific options.Gravatar Julio Merino2016-09-09
| | | | | | | | | | | | | | | | | | Rename BlazeStartupOptions to StartupOptions and turn the latter into a class that can be subclassed to implement site-specific options behavior. This lends itself to easier customization for the site-specific versions, especially if there is more than one, and gets rid of the strange build-time parameterization of the old blaze_startup_options*.cc files. Note that this change introduces various TODOs. This is intentional. This change is quite complex as it is and I want to focus it on reshuffling the class structure without actually touching the internals. The latter can be done in subsequent, more targetted changes that are easier to review and understand. -- MOS_MIGRATED_REVID=132555032
* 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
* Increase the deadline for cancellation request and add some extra logging in ↵Gravatar Lukacs Berki2016-08-31
| | | | | | | case the request fails. -- MOS_MIGRATED_REVID=131804959
* Move the workspace-related functions out of blaze_startup_options.Gravatar Julio Merino2016-08-29
| | | | | | | | | | This change introduces a new workspace_layout module that collects all the static methods previously contained in the BlazeStartupOptions class. These methods are not part of the options so it doesn't make sense for them to be there. -- MOS_MIGRATED_REVID=131576959
* 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
* Rollback of commit f107debac45ddf5859b1eb963379769b5815b18f. Also includes ↵Gravatar Janak Ramakrishnan2016-08-12
| | | | | | | | | the logical rollback of commit 67ad82a319ff8959e69e774e7c15d3af904ec23d. RELNOTES[INC]: Bazel supports Unix domain sockets for communication between its client and server again, temporarily, while we diagnose a memory leak. -- MOS_MIGRATED_REVID=130027009