Message ID | 75af98ed9992aad08e6fadc64d1985a165529828.1642663574.git.liezhi.yang@windriver.com |
---|---|
State | New |
Headers | show |
Series | [1/1] bitbake-worker: Check BB_TASK_NETWORK before disable network for task | expand |
> -----Original Message----- > From: bitbake-devel@lists.openembedded.org <bitbake-devel@lists.openembedded.org> On Behalf Of Robert Yang > Sent: den 20 januari 2022 08:27 > To: bitbake-devel@lists.openembedded.org > Cc: quaresma.jose@gmail.com > Subject: [bitbake-devel] [PATCH 1/1] bitbake-worker: Check BB_TASK_NETWORK before disable network for task > > The NIS user can't work when task's network is disabled, so check > BB_TASK_NETWORK before disable it, the conf files can set BB_TASK_NETWORK. > > Signed-off-by: Robert Yang <liezhi.yang@windriver.com> > --- > bitbake/bin/bitbake-worker | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker > index 3aaf3c2444b..3d7a781d35c 100755 > --- a/bitbake/bin/bitbake-worker > +++ b/bitbake/bin/bitbake-worker > @@ -261,7 +261,8 @@ def fork_off_task(cfg, data, databuilder, workerdata, > fn, task, taskname, taskha > > bb.utils.set_process_name("%s:%s" % (the_data.getVar("PN"), taskname.replace("do_", ""))) > > - if not the_data.getVarFlag(taskname, 'network', False): > + bb_task_network = bb.utils.to_boolean(the_data.getVar('BB_TASK_NETWORK'), False) Why use False to getVar() above? > + if not (bb_task_network or the_data.getVarFlag(taskname, 'network', False)): I can't speak for others, but I find "not (foo or bar)" a lot harder to parse than "not foo and not bar". > logger.debug("Attempting to disable network") > bb.utils.disable_network(uid, gid) > > -- > 2.31.1 //Peter
Hi Peter, On 1/20/22 9:50 PM, Peter Kjellerstedt wrote: >> -----Original Message----- >> From: bitbake-devel@lists.openembedded.org <bitbake-devel@lists.openembedded.org> On Behalf Of Robert Yang >> Sent: den 20 januari 2022 08:27 >> To: bitbake-devel@lists.openembedded.org >> Cc: quaresma.jose@gmail.com >> Subject: [bitbake-devel] [PATCH 1/1] bitbake-worker: Check BB_TASK_NETWORK before disable network for task >> >> The NIS user can't work when task's network is disabled, so check >> BB_TASK_NETWORK before disable it, the conf files can set BB_TASK_NETWORK. >> >> Signed-off-by: Robert Yang <liezhi.yang@windriver.com> >> --- >> bitbake/bin/bitbake-worker | 3 ++- >> 1 file changed, 2 insertions(+), 1 deletion(-) >> >> diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker >> index 3aaf3c2444b..3d7a781d35c 100755 >> --- a/bitbake/bin/bitbake-worker >> +++ b/bitbake/bin/bitbake-worker >> @@ -261,7 +261,8 @@ def fork_off_task(cfg, data, databuilder, workerdata, >> fn, task, taskname, taskha >> >> bb.utils.set_process_name("%s:%s" % (the_data.getVar("PN"), taskname.replace("do_", ""))) >> >> - if not the_data.getVarFlag(taskname, 'network', False): >> + bb_task_network = bb.utils.to_boolean(the_data.getVar('BB_TASK_NETWORK'), False) > > Why use False to getVar() above? The False is for bb.utils.to_boolean(), not getVar(), the getVar has only one argument: the_data.getVar('BB_TASK_NETWORK') > >> + if not (bb_task_network or the_data.getVarFlag(taskname, 'network', False)): > > I can't speak for others, but I find "not (foo or bar)" a lot harder to > parse than "not foo and not bar". Technically, the "not (foo or bar)" is slightly faster than "not foo and not bar" since the latter one requires more logical evaluates. // Robert > >> logger.debug("Attempting to disable network") >> bb.utils.disable_network(uid, gid) >> >> -- >> 2.31.1 > > //Peter >
> -----Original Message----- > From: Robert Yang <liezhi.yang@windriver.com> > Sent: den 21 januari 2022 04:15 > To: Peter Kjellerstedt <peter.kjellerstedt@axis.com>; bitbake- > devel@lists.openembedded.org > Cc: quaresma.jose@gmail.com > Subject: Re: [bitbake-devel] [PATCH 1/1] bitbake-worker: Check > BB_TASK_NETWORK before disable network for task > > Hi Peter, > > On 1/20/22 9:50 PM, Peter Kjellerstedt wrote: > >> -----Original Message----- > >> From: bitbake-devel@lists.openembedded.org <bitbake- > devel@lists.openembedded.org> On Behalf Of Robert Yang > >> Sent: den 20 januari 2022 08:27 > >> To: bitbake-devel@lists.openembedded.org > >> Cc: quaresma.jose@gmail.com > >> Subject: [bitbake-devel] [PATCH 1/1] bitbake-worker: Check > BB_TASK_NETWORK before disable network for task > >> > >> The NIS user can't work when task's network is disabled, so check > >> BB_TASK_NETWORK before disable it, the conf files can set > BB_TASK_NETWORK. > >> > >> Signed-off-by: Robert Yang <liezhi.yang@windriver.com> > >> --- > >> bitbake/bin/bitbake-worker | 3 ++- > >> 1 file changed, 2 insertions(+), 1 deletion(-) > >> > >> diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker > >> index 3aaf3c2444b..3d7a781d35c 100755 > >> --- a/bitbake/bin/bitbake-worker > >> +++ b/bitbake/bin/bitbake-worker > >> @@ -261,7 +261,8 @@ def fork_off_task(cfg, data, databuilder, > workerdata, > >> fn, task, taskname, taskha > >> > >> bb.utils.set_process_name("%s:%s" % > (the_data.getVar("PN"), taskname.replace("do_", ""))) > >> > >> - if not the_data.getVarFlag(taskname, 'network', > False): > >> + bb_task_network = > bb.utils.to_boolean(the_data.getVar('BB_TASK_NETWORK'), False) > > > > Why use False to getVar() above? > > The False is for bb.utils.to_boolean(), not getVar(), the getVar has only > one argument: > > the_data.getVar('BB_TASK_NETWORK') Duh, of course. I guess I need new glasses... > > > >> + if not (bb_task_network or > the_data.getVarFlag(taskname, 'network', False)): > > > > I can't speak for others, but I find "not (foo or bar)" a lot harder to > > parse than "not foo and not bar". > > Technically, the "not (foo or bar)" is slightly faster than "not foo and > not bar" since the latter one requires more logical evaluates. Somehow, I think you will find it hard to actually measure that time difference... ;) I tried, and in my testing the time to execute either statement was 0.07-0.12 μs, i.e., it was impossible to declare either as faster than the other. > // Robert > > > > >> logger.debug("Attempting to disable network") > >> bb.utils.disable_network(uid, gid) > >> > >> -- > >> 2.31.1 > > > > //Peter //Peter
diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker index 3aaf3c2444b..3d7a781d35c 100755 --- a/bitbake/bin/bitbake-worker +++ b/bitbake/bin/bitbake-worker @@ -261,7 +261,8 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, taskha bb.utils.set_process_name("%s:%s" % (the_data.getVar("PN"), taskname.replace("do_", ""))) - if not the_data.getVarFlag(taskname, 'network', False): + bb_task_network = bb.utils.to_boolean(the_data.getVar('BB_TASK_NETWORK'), False) + if not (bb_task_network or the_data.getVarFlag(taskname, 'network', False)): logger.debug("Attempting to disable network") bb.utils.disable_network(uid, gid)
The NIS user can't work when task's network is disabled, so check BB_TASK_NETWORK before disable it, the conf files can set BB_TASK_NETWORK. Signed-off-by: Robert Yang <liezhi.yang@windriver.com> --- bitbake/bin/bitbake-worker | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)