bitbake: lib/bb/build: handle incomplete message fragments in log FIFO
It's possible that the logging FIFO doesn't do a complete read (or the sender a complete write) with the result that an incomplete message is read in bitbake. This used to result in silently truncated lines but since 42d727 now also results in a warning as the start of the rest of the message isn't a valid logging command. Solve this by storing incoming bytes in a bytearray() across reads, and parsing complete messages from that. [ YOCTO #9999 ] (Bitbake rev: 508112793ee7ace613f07695222997309a2ca58f) Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
9411e33b88
commit
1393b23f51
|
@ -385,39 +385,44 @@ exit $ret
|
||||||
else:
|
else:
|
||||||
bb.warn('%s: invalid task progress varflag value "%s", ignoring' % (func, progress))
|
bb.warn('%s: invalid task progress varflag value "%s", ignoring' % (func, progress))
|
||||||
|
|
||||||
|
fifobuffer = bytearray()
|
||||||
def readfifo(data):
|
def readfifo(data):
|
||||||
lines = data.split(b'\0')
|
nonlocal fifobuffer
|
||||||
for line in lines:
|
fifobuffer.extend(data)
|
||||||
# Just skip empty commands
|
while fifobuffer:
|
||||||
if not line:
|
message, token, nextmsg = fifobuffer.partition(b"\00")
|
||||||
continue
|
if token:
|
||||||
splitval = line.split(b' ', 1)
|
splitval = message.split(b' ', 1)
|
||||||
cmd = splitval[0].decode("utf-8")
|
cmd = splitval[0].decode("utf-8")
|
||||||
if len(splitval) > 1:
|
if len(splitval) > 1:
|
||||||
value = splitval[1].decode("utf-8")
|
value = splitval[1].decode("utf-8")
|
||||||
|
else:
|
||||||
|
value = ''
|
||||||
|
if cmd == 'bbplain':
|
||||||
|
bb.plain(value)
|
||||||
|
elif cmd == 'bbnote':
|
||||||
|
bb.note(value)
|
||||||
|
elif cmd == 'bbwarn':
|
||||||
|
bb.warn(value)
|
||||||
|
elif cmd == 'bberror':
|
||||||
|
bb.error(value)
|
||||||
|
elif cmd == 'bbfatal':
|
||||||
|
# The caller will call exit themselves, so bb.error() is
|
||||||
|
# what we want here rather than bb.fatal()
|
||||||
|
bb.error(value)
|
||||||
|
elif cmd == 'bbfatal_log':
|
||||||
|
bb.error(value, forcelog=True)
|
||||||
|
elif cmd == 'bbdebug':
|
||||||
|
splitval = value.split(' ', 1)
|
||||||
|
level = int(splitval[0])
|
||||||
|
value = splitval[1]
|
||||||
|
bb.debug(level, value)
|
||||||
|
else:
|
||||||
|
bb.warn("Unrecognised command '%s' on FIFO" % cmd)
|
||||||
|
fifobuffer = nextmsg
|
||||||
else:
|
else:
|
||||||
value = ''
|
break
|
||||||
if cmd == 'bbplain':
|
|
||||||
bb.plain(value)
|
|
||||||
elif cmd == 'bbnote':
|
|
||||||
bb.note(value)
|
|
||||||
elif cmd == 'bbwarn':
|
|
||||||
bb.warn(value)
|
|
||||||
elif cmd == 'bberror':
|
|
||||||
bb.error(value)
|
|
||||||
elif cmd == 'bbfatal':
|
|
||||||
# The caller will call exit themselves, so bb.error() is
|
|
||||||
# what we want here rather than bb.fatal()
|
|
||||||
bb.error(value)
|
|
||||||
elif cmd == 'bbfatal_log':
|
|
||||||
bb.error(value, forcelog=True)
|
|
||||||
elif cmd == 'bbdebug':
|
|
||||||
splitval = value.split(' ', 1)
|
|
||||||
level = int(splitval[0])
|
|
||||||
value = splitval[1]
|
|
||||||
bb.debug(level, value)
|
|
||||||
else:
|
|
||||||
bb.warn("Unrecognised command '%s' on FIFO" % cmd)
|
|
||||||
tempdir = d.getVar('T', True)
|
tempdir = d.getVar('T', True)
|
||||||
fifopath = os.path.join(tempdir, 'fifo.%s' % os.getpid())
|
fifopath = os.path.join(tempdir, 'fifo.%s' % os.getpid())
|
||||||
if os.path.exists(fifopath):
|
if os.path.exists(fifopath):
|
||||||
|
|
Loading…
Reference in New Issue