Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/trace2
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2021-12-11 01:35:08 +0300
committerJunio C Hamano <gitster@pobox.com>2021-12-11 01:35:08 +0300
commit9b0a970ace0316662697cd9db326bcfb48e36838 (patch)
treee8794d747ddf11732516c84f39589fdfc30fe79a /trace2
parent2d5b70de2d285ed938877c0d9f869ab062037a3b (diff)
parent538ac746048fab0ed32b972e34eaabb9fb3f15b9 (diff)
Merge branch 'js/trace2-avoid-recursive-errors'
trace2 error code path fix. * js/trace2-avoid-recursive-errors: trace2: disable tr2_dst before warning on write errors
Diffstat (limited to 'trace2')
-rw-r--r--trace2/tr2_dst.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/trace2/tr2_dst.c b/trace2/tr2_dst.c
index bda283e7f4..8a21dd2972 100644
--- a/trace2/tr2_dst.c
+++ b/trace2/tr2_dst.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "sigchain.h"
#include "trace2/tr2_dst.h"
#include "trace2/tr2_sid.h"
#include "trace2/tr2_sysenv.h"
@@ -360,6 +361,7 @@ int tr2_dst_trace_want(struct tr2_dst *dst)
void tr2_dst_write_line(struct tr2_dst *dst, struct strbuf *buf_line)
{
int fd = tr2_dst_get_trace_fd(dst);
+ ssize_t bytes;
strbuf_complete_line(buf_line); /* ensure final NL on buffer */
@@ -378,12 +380,15 @@ void tr2_dst_write_line(struct tr2_dst *dst, struct strbuf *buf_line)
*
* If we get an IO error, just close the trace dst.
*/
- if (write(fd, buf_line->buf, buf_line->len) >= 0)
+ sigchain_push(SIGPIPE, SIG_IGN);
+ bytes = write(fd, buf_line->buf, buf_line->len);
+ sigchain_pop(SIGPIPE);
+ if (bytes >= 0)
return;
+ tr2_dst_trace_disable(dst);
if (tr2_dst_want_warning())
warning("unable to write trace to '%s': %s",
tr2_sysenv_display_name(dst->sysenv_var),
strerror(errno));
- tr2_dst_trace_disable(dst);
}