Skip to content

Commit 8e2935d

Browse files
committed
chore: minor cleanup
1 parent 49775df commit 8e2935d

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

api/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ pub use self::net::*;
1010

1111
mod log;
1212
pub use self::log::*;
13+
1314
/// Logical offset in an the binary log stream
1415
///
1516
/// Clients use this offset directly to traverse the log and

loglogd/src/node/segment_writer.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,7 @@ impl WriteLoopInner {
234234
(next_segment_start_log_offset, new_segment)
235235
};
236236

237-
self.shared.put_entry_buffer(
238-
new_segment.write_file_header(
239-
new_segment_start_log_offset,
240-
self.shared.pop_entry_buffer(),
241-
),
242-
);
237+
new_segment.write_file_header(new_segment_start_log_offset);
243238

244239
// It would be tempting to just return the `new_segment` as the segment we need. But that would be
245240
// a mistake - this entry might theoretically be so far ahead, that it needs even more segments opened.

loglogd/src/segment.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::ioutil::{pwrite_all, vec_extend_to_at_least};
1+
use crate::ioutil::pwrite_all;
22
use std::{
33
fmt,
44
fs::OpenOptions,
@@ -190,26 +190,23 @@ pub struct OpenSegment {
190190
}
191191

192192
impl OpenSegment {
193-
pub fn write_file_header(&self, log_offset: LogOffset, mut buf: Vec<u8>) -> Vec<u8> {
194-
vec_extend_to_at_least(&mut buf, SegmentFileHeader::BYTE_SIZE);
193+
pub fn write_file_header(&self, log_offset: LogOffset) {
194+
let buf = [0u8; SegmentFileHeader::BYTE_SIZE];
195195

196196
let header = SegmentFileHeader {
197197
version: 1,
198198
log_offset,
199199
ff_end: (),
200200
};
201201

202-
header
203-
.write(&mut Cursor::new(&mut buf))
204-
.expect("can't fail");
202+
header.write(&mut Cursor::new(buf)).expect("can't fail");
205203

206204
let res = pwrite_all(self.fd.as_raw_fd(), 0, &buf[..SegmentFileHeader::BYTE_SIZE]);
207205

208206
if let Err(e) = res {
207+
// We can't really tolerate errors when writting to log
209208
panic!("IO Error when writting log: {}, crashing immediately", e);
210209
}
211-
212-
buf
213210
}
214211
}
215212

0 commit comments

Comments
 (0)