File tree Expand file tree Collapse file tree 3 files changed +7
-14
lines changed Expand file tree Collapse file tree 3 files changed +7
-14
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ pub use self::net::*;
10
10
11
11
mod log;
12
12
pub use self :: log:: * ;
13
+
13
14
/// Logical offset in an the binary log stream
14
15
///
15
16
/// Clients use this offset directly to traverse the log and
Original file line number Diff line number Diff line change @@ -234,12 +234,7 @@ impl WriteLoopInner {
234
234
( next_segment_start_log_offset, new_segment)
235
235
} ;
236
236
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) ;
243
238
244
239
// It would be tempting to just return the `new_segment` as the segment we need. But that would be
245
240
// a mistake - this entry might theoretically be so far ahead, that it needs even more segments opened.
Original file line number Diff line number Diff line change 1
- use crate :: ioutil:: { pwrite_all, vec_extend_to_at_least } ;
1
+ use crate :: ioutil:: pwrite_all;
2
2
use std:: {
3
3
fmt,
4
4
fs:: OpenOptions ,
@@ -190,26 +190,23 @@ pub struct OpenSegment {
190
190
}
191
191
192
192
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 ] ;
195
195
196
196
let header = SegmentFileHeader {
197
197
version : 1 ,
198
198
log_offset,
199
199
ff_end : ( ) ,
200
200
} ;
201
201
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" ) ;
205
203
206
204
let res = pwrite_all ( self . fd . as_raw_fd ( ) , 0 , & buf[ ..SegmentFileHeader :: BYTE_SIZE ] ) ;
207
205
208
206
if let Err ( e) = res {
207
+ // We can't really tolerate errors when writting to log
209
208
panic ! ( "IO Error when writting log: {}, crashing immediately" , e) ;
210
209
}
211
-
212
- buf
213
210
}
214
211
}
215
212
You can’t perform that action at this time.
0 commit comments