Changeset 3479 in kBuild
- Timestamp:
- Sep 21, 2020 10:59:41 AM (4 years ago)
- Location:
- trunk/src/kmk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kmk/main.c
r3432 r3479 4388 4388 { 4389 4389 need_2nd_error = 1; 4390 need_2nd_error_output = job_slots_used > 24391 && out == NULL4390 need_2nd_error_output = job_slots_used >= 2 4391 && out != NULL 4392 4392 && out != &make_sync; 4393 if (need_2nd_error_output) 4394 output_metered = 0; 4393 4395 } 4394 4396 #endif /* KMK */ … … 4470 4472 { 4471 4473 out->dont_truncate = 0; 4472 if (need_2nd_error_output) 4474 fprintf(stderr, "output_metered=%d\n", output_metered); 4475 if (need_2nd_error_output && output_metered > 20) 4473 4476 output_dump (out); 4477 else 4478 output_reset (out); 4474 4479 output_close (out); 4475 4480 } … … 4480 4485 4481 4486 #ifdef KMK 4482 void die (int status)4487 void die (int status) 4483 4488 { 4484 4489 die_with_job_output (status, NULL); -
trunk/src/kmk/output.c
r3432 r3479 58 58 #else 59 59 # define STREAM_OK(_s) 1 60 #endif 61 62 63 #if defined(KMK) && !defined(NO_OUTPUT_SYNC) 64 /* Non-negative if we're counting output lines. 65 66 This is used by die_with_job_output to decide whether the initial build 67 error needs to be repeated because there was too much output from parallel 68 jobs between it and the actual make termination. */ 69 int output_metered = -1; 70 71 static void meter_output_block (char const *buffer, size_t len) 72 { 73 while (len > 0) 74 { 75 char *nl = (char *)memchr (buffer, '\n', len); 76 size_t linelen; 77 if (nl) 78 { 79 linelen = nl - buffer + 1; 80 output_metered++; 81 } 82 else 83 linelen = len; 84 output_metered += linelen / 132; 85 86 /* advance */ 87 buffer += linelen; 88 len -= linelen; 89 } 90 } 60 91 #endif 61 92 … … 78 109 static int combined_output = -1; 79 110 111 /* Helper for membuf_reset and output_reset */ 112 static membuf_reset (struct output *out) 113 { 114 struct output_segment *seg; 115 while ((seg = out->out.head_seg)) 116 { 117 out->out.head_seg = seg->next; 118 free (seg); 119 } 120 out->out.tail_seg = NULL; 121 out->out.tail_run = NULL; 122 out->out.head_run = NULL; 123 out->out.left = 0; 124 out->out.total = 0; 125 126 while ((seg = out->err.head_seg)) 127 { 128 out->err.head_seg = seg->next; 129 free (seg); 130 } 131 out->err.tail_seg = NULL; 132 out->err.tail_run = NULL; 133 out->err.head_run = NULL; 134 out->err.left = 0; 135 out->err.total = 0; 136 137 out->seqno = 0; 138 } 139 140 /* Used by die_with_job_output to suppress output when it shouldn't be repeated. */ 141 void output_reset (struct output *out) 142 { 143 if (out && (out->out.total || out->err.total)) 144 membuf_reset (out); 145 } 146 80 147 /* Internal worker for output_dump and membuf_dump_most. */ 81 148 static void membuf_dump (struct output *out) … … 86 153 struct output_run *err_run; 87 154 struct output_run *out_run; 88 struct output_segment *seg;89 155 FILE *prevdst; 90 156 … … 130 196 fflush(prevdst); 131 197 prevdst = dst; 198 #ifdef KMK 199 if (output_metered < 0) 200 { /* likely */ } 201 else 202 meter_output_block (src, len); 203 #endif 132 204 # if 0 /* for debugging */ 133 205 while (len > 0) … … 179 251 180 252 /* Free the segments and reset the state. */ 181 while ((seg = out->out.head_seg)) 182 { 183 out->out.head_seg = seg->next; 184 free (seg); 185 } 186 out->out.tail_seg = NULL; 187 out->out.tail_run = NULL; 188 out->out.head_run = NULL; 189 out->out.left = 0; 190 out->out.total = 0; 191 192 while ((seg = out->err.head_seg)) 193 { 194 out->err.head_seg = seg->next; 195 free (seg); 196 } 197 out->err.tail_seg = NULL; 198 out->err.tail_run = NULL; 199 out->err.head_run = NULL; 200 out->err.left = 0; 201 out->err.total = 0; 202 203 out->seqno = 0; 253 membuf_reset (out); 204 254 } 205 255 else … … 756 806 if (len <= 0) 757 807 break; 808 #ifdef KMK 809 if (output_metered < 0) 810 { /* likely */ } 811 else 812 meter_output_block (buffer, len); 813 #endif 758 814 if (fwrite (buffer, len, 1, to) < 1) 759 815 { … … 953 1009 #endif 954 1010 } 1011 1012 # if defined(KMK) && !defined(CONFIG_WITH_OUTPUT_IN_MEMORY) 1013 /* Used by die_with_job_output to suppress output when it shouldn't be repeated. */ 1014 void output_reset (struct output *out) 1015 { 1016 if (out) 1017 { 1018 if (out->out != OUTPUT_NONE) 1019 { 1020 int e; 1021 lseek (out->out, 0, SEEK_SET); 1022 EINTRLOOP (e, ftruncate (out->out, 0)); 1023 } 1024 if (out->err != OUTPUT_NONE && out->err != out->out) 1025 { 1026 int e; 1027 lseek (out->err, 0, SEEK_SET); 1028 EINTRLOOP (e, ftruncate (out->err, 0)); 1029 } 1030 } 1031 } 1032 # endif 955 1033 #endif /* NO_OUTPUT_SYNC */ 956 1034 -
trunk/src/kmk/output.h
r3432 r3479 67 67 extern struct output *output_context; 68 68 extern unsigned int stdio_traced; 69 #if defined(KMK) && !defined(NO_OUTPUT_SYNC) 70 extern int output_metered; 71 #endif 69 72 70 73 #define OUTPUT_SET(_new) do{ output_context = (_new)->syncout ? (_new) : NULL; }while(0) … … 96 99 /* Dump any child output content to stdout, and reset it. */ 97 100 void output_dump (struct output *out); 101 # ifdef KMK 102 void output_reset (struct output *out); 103 # endif 98 104 #endif 99 105
Note:
See TracChangeset
for help on using the changeset viewer.