1 /* |
1 /* |
2 * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
215 jio_snprintf(buf, buflen, UINTX_FORMAT, log->thread_id()); |
215 jio_snprintf(buf, buflen, UINTX_FORMAT, log->thread_id()); |
216 file->print_raw(buf); |
216 file->print_raw(buf); |
217 file->print_raw_cr("'>"); |
217 file->print_raw_cr("'>"); |
218 |
218 |
219 size_t nr; // number read into buf from partial log |
219 size_t nr; // number read into buf from partial log |
|
220 // In case of unsuccessful completion, read returns -1. |
|
221 ssize_t bytes_read; |
220 // Copy data up to the end of the last <event> element: |
222 // Copy data up to the end of the last <event> element: |
221 julong to_read = log->_file_end; |
223 julong to_read = log->_file_end; |
222 while (to_read > 0) { |
224 while (to_read > 0) { |
223 if (to_read < (julong)buflen) |
225 if (to_read < (julong)buflen) |
224 nr = (size_t)to_read; |
226 nr = (size_t)to_read; |
225 else nr = buflen; |
227 else nr = buflen; |
226 nr = read(partial_fd, buf, (int)nr); |
228 bytes_read = read(partial_fd, buf, (int)nr); |
227 if (nr <= 0) break; |
229 if (bytes_read <= 0) break; |
|
230 nr = bytes_read; |
228 to_read -= (julong)nr; |
231 to_read -= (julong)nr; |
229 file->write(buf, nr); |
232 file->write(buf, nr); |
230 } |
233 } |
231 |
234 |
232 // Copy any remaining data inside a quote: |
235 // Copy any remaining data inside a quote: |
233 bool saw_slop = false; |
236 bool saw_slop = false; |
234 int end_cdata = 0; // state machine [0..2] watching for too many "]]" |
237 int end_cdata = 0; // state machine [0..2] watching for too many "]]" |
235 while ((nr = read(partial_fd, buf, buflen-1)) > 0) { |
238 while ((bytes_read = read(partial_fd, buf, buflen-1)) > 0) { |
|
239 nr = bytes_read; |
236 buf[buflen-1] = '\0'; |
240 buf[buflen-1] = '\0'; |
237 if (!saw_slop) { |
241 if (!saw_slop) { |
238 file->print_raw_cr("<fragment>"); |
242 file->print_raw_cr("<fragment>"); |
239 file->print_raw_cr("<![CDATA["); |
243 file->print_raw_cr("<![CDATA["); |
240 saw_slop = true; |
244 saw_slop = true; |