lib/fluent/plugin/in_tail.rb in fluentd-1.2.1 vs lib/fluent/plugin/in_tail.rb in fluentd-1.2.2
- old
+ new
@@ -860,11 +860,11 @@
@file.write "\t"
seek = @file.pos
@file.write "0000000000000000\t0000000000000000\n"
@last_pos = @file.pos
- @map[path] = FilePositionEntry.new(@file, seek)
+ @map[path] = FilePositionEntry.new(@file, seek, 0, 0)
end
def self.parse(file)
compact(file)
@@ -872,12 +872,14 @@
file.pos = 0
file.each_line {|line|
m = /^([^\t]+)\t([0-9a-fA-F]+)\t([0-9a-fA-F]+)/.match(line)
next unless m
path = m[1]
+ pos = m[2].to_i(16)
+ ino = m[3].to_i(16)
seek = file.pos - line.bytesize + path.bytesize + 1
- map[path] = FilePositionEntry.new(file, seek)
+ map[path] = FilePositionEntry.new(file, seek, pos, ino)
}
new(file, map, file.pos)
end
# Clean up unwatched file entries
@@ -906,39 +908,35 @@
INO_OFFSET = 17
INO_SIZE = 16
LN_OFFSET = 33
SIZE = 34
- def initialize(file, seek)
+ def initialize(file, seek, pos, inode)
@file = file
@seek = seek
- @pos = nil
+ @pos = pos
+ @inode = inode
end
def update(ino, pos)
@file.pos = @seek
@file.write "%016x\t%016x" % [pos, ino]
@pos = pos
+ @inode = ino
end
def update_pos(pos)
@file.pos = @seek
@file.write "%016x" % pos
@pos = pos
end
def read_inode
- @file.pos = @seek + INO_OFFSET
- raw = @file.read(16)
- raw ? raw.to_i(16) : 0
+ @inode
end
def read_pos
- @pos ||= begin
- @file.pos = @seek
- raw = @file.read(16)
- raw ? raw.to_i(16) : 0
- end
+ @pos
end
end
class MemoryPositionEntry
def initialize