< prev index next >

src/hotspot/share/jfr/recorder/repository/jfrChunkWriter.cpp

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -45,22 +45,20 @@
   assert(_chunkstate == NULL, "invariant");
   _chunkstate = new JfrChunkState();
   return _chunkstate != NULL;
 }
 
-static fio_fd open_existing(const char* path) {
-  return os::open(path, O_RDWR, S_IREAD | S_IWRITE);
-}
-
-static fio_fd open_chunk(const char* path) {
+static fio_fd open_chunk(const char* path, bool vm_error) {
   assert(JfrStream_lock->owned_by_self(), "invariant");
-  return path != NULL ? open_existing(path) : invalid_fd;
+  int flags = vm_error ? (O_CREAT | O_WRONLY) : O_RDWR;
+  const int mode = S_IREAD | S_IWRITE;
+  return path != NULL ? os::open(path, flags, mode) : invalid_fd;
 }
 
-bool JfrChunkWriter::open() {
+bool JfrChunkWriter::open(bool vm_error) {
   assert(_chunkstate != NULL, "invariant");
-  JfrChunkWriterBase::reset(open_chunk(_chunkstate->path()));
+  JfrChunkWriterBase::reset(open_chunk(_chunkstate->path(), vm_error));
   const bool is_open = this->has_valid_fd();
   if (is_open) {
     this->bytes("FLR", MAGIC_LEN);
     this->be_write((u2)JFR_VERSION_MAJOR);
     this->be_write((u2)JFR_VERSION_MINOR);
< prev index next >