Message ID | 20220428121033.1609620-3-muhammad_hamza@mentor.com |
---|---|
State | Accepted |
Headers | show |
Series | [1/3,meta-swupdate,v1,1/3] swupdate-usb: update service to use mount points dynamically | expand |
On 28.04.22 14:10, Muhammad Hamza wrote: > swupdate service launches a shell script which is responsible for > launcing swupdate core. Default service type considers that unit > is started right after main process is forked, and dependent services > can be launched right away, however it take some time for swupdate > core to initialize. This causes swupdate-client, launched by > swupdate-usb service, to end up in a race condition if swupdate-usb > service is launched right after swupdate service as service manager > considers that swupdate unit is fully running, whereas swupdate core > has not completely initialized yet. This results in immature launcing of > swupdate-client and it fails with "swupdate_async_start returns -1" > because host socket are not initialized yet in swupdate core for > the client to connect to. > When service type is set to "exec" service manager considers that a > service unit is started after the main process binary is executed > making sure that dependent services are not launched till core is > initialized. swupdate.sh uses exec to launch swupdate core this makes > sure that swupdate.sh is considered executed only once swupdate core > is running. > This commits sets service type to "exec" and makes use of the way > swupdate.sh executes swupdate core using exec command to make sure > that swupdate-client and core do not end up in race condition. > > Signed-off-by: Muhammad Hamza <muhammad_hamza@mentor.com> > --- > recipes-support/swupdate/swupdate/swupdate.service | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/recipes-support/swupdate/swupdate/swupdate.service b/recipes-support/swupdate/swupdate/swupdate.service > index 7f36619..c0253aa 100644 > --- a/recipes-support/swupdate/swupdate/swupdate.service > +++ b/recipes-support/swupdate/swupdate/swupdate.service > @@ -4,6 +4,7 @@ Documentation=https://github.com/sbabic/swupdate > Documentation=https://sbabic.github.io/swupdate > > [Service] > +Type=exec > ExecStart=@LIBDIR@/swupdate/swupdate.sh > KillMode=mixed > Acked-by: Stefano Babic <sbabic@denx.de> Best regards, Stefano Babic
On Thu, Apr 28, 2022 at 6:11 AM Muhammad Hamza <muhammad_hamza@mentor.com> wrote: > > swupdate service launches a shell script which is responsible for > launcing swupdate core. Default service type considers that unit > is started right after main process is forked, and dependent services > can be launched right away, however it take some time for swupdate > core to initialize. This causes swupdate-client, launched by > swupdate-usb service, to end up in a race condition if swupdate-usb > service is launched right after swupdate service as service manager > considers that swupdate unit is fully running, whereas swupdate core > has not completely initialized yet. This results in immature launcing of > swupdate-client and it fails with "swupdate_async_start returns -1" > because host socket are not initialized yet in swupdate core for > the client to connect to. > When service type is set to "exec" service manager considers that a > service unit is started after the main process binary is executed > making sure that dependent services are not launched till core is > initialized. swupdate.sh uses exec to launch swupdate core this makes > sure that swupdate.sh is considered executed only once swupdate core > is running. > This commits sets service type to "exec" and makes use of the way > swupdate.sh executes swupdate core using exec command to make sure > that swupdate-client and core do not end up in race condition. > > Signed-off-by: Muhammad Hamza <muhammad_hamza@mentor.com> > --- > recipes-support/swupdate/swupdate/swupdate.service | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/recipes-support/swupdate/swupdate/swupdate.service b/recipes-support/swupdate/swupdate/swupdate.service > index 7f36619..c0253aa 100644 > --- a/recipes-support/swupdate/swupdate/swupdate.service > +++ b/recipes-support/swupdate/swupdate/swupdate.service > @@ -4,6 +4,7 @@ Documentation=https://github.com/sbabic/swupdate > Documentation=https://sbabic.github.io/swupdate > > [Service] > +Type=exec Should actually be this I think: Type=notify Since we implement notify support here: https://github.com/sbabic/swupdate/blob/a10214e88eba43ae0382c84d9f0d10cf5d623e2a/core/swupdate.c#L927 > ExecStart=@LIBDIR@/swupdate/swupdate.sh > KillMode=mixed > > -- > 2.25.1 > > -- > You received this message because you are subscribed to the Google Groups "swupdate" group. > To unsubscribe from this group and stop receiving emails from it, send an email to swupdate+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/swupdate/20220428121033.1609620-3-muhammad_hamza%40mentor.com.
Hi James, On 06.06.22 03:53, James Hilliard wrote: > On Thu, Apr 28, 2022 at 6:11 AM Muhammad Hamza > <muhammad_hamza@mentor.com> wrote: >> >> swupdate service launches a shell script which is responsible for >> launcing swupdate core. Default service type considers that unit >> is started right after main process is forked, and dependent services >> can be launched right away, however it take some time for swupdate >> core to initialize. This causes swupdate-client, launched by >> swupdate-usb service, to end up in a race condition if swupdate-usb >> service is launched right after swupdate service as service manager >> considers that swupdate unit is fully running, whereas swupdate core >> has not completely initialized yet. This results in immature launcing of >> swupdate-client and it fails with "swupdate_async_start returns -1" >> because host socket are not initialized yet in swupdate core for >> the client to connect to. >> When service type is set to "exec" service manager considers that a >> service unit is started after the main process binary is executed >> making sure that dependent services are not launched till core is >> initialized. swupdate.sh uses exec to launch swupdate core this makes >> sure that swupdate.sh is considered executed only once swupdate core >> is running. >> This commits sets service type to "exec" and makes use of the way >> swupdate.sh executes swupdate core using exec command to make sure >> that swupdate-client and core do not end up in race condition. >> >> Signed-off-by: Muhammad Hamza <muhammad_hamza@mentor.com> >> --- >> recipes-support/swupdate/swupdate/swupdate.service | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/recipes-support/swupdate/swupdate/swupdate.service b/recipes-support/swupdate/swupdate/swupdate.service >> index 7f36619..c0253aa 100644 >> --- a/recipes-support/swupdate/swupdate/swupdate.service >> +++ b/recipes-support/swupdate/swupdate/swupdate.service >> @@ -4,6 +4,7 @@ Documentation=https://github.com/sbabic/swupdate >> Documentation=https://sbabic.github.io/swupdate >> >> [Service] >> +Type=exec > Should actually be this I think: > Type=notify > > Since we implement notify support here: > https://github.com/sbabic/swupdate/blob/a10214e88eba43ae0382c84d9f0d10cf5d623e2a/core/swupdate.c#L927 You're right - notify is the right type here. @Muhammad ? Best regards, Stefano >> ExecStart=@LIBDIR@/swupdate/swupdate.sh >> KillMode=mixed >> >> -- >> 2.25.1 >> >> -- >> You received this message because you are subscribed to the Google Groups "swupdate" group. >> To unsubscribe from this group and stop receiving emails from it, send an email to swupdate+unsubscribe@googlegroups.com. >> To view this discussion on the web visit https://groups.google.com/d/msgid/swupdate/20220428121033.1609620-3-muhammad_hamza%40mentor.com. >
Hello, Yes, you're right, I have been away for few days, will send updated patch soon. Regards, Hamza -----Original Message----- From: Stefano Babic <sbabic@denx.de> Sent: Monday, June 6, 2022 12:25 PM To: James Hilliard <james.hilliard1@gmail.com>; Hamza, Muhammad <Muhammad_Hamza@mentor.com> Cc: swupdate <swupdate@googlegroups.com> Subject: Re: [swupdate] [PATCH 3/3] [meta-swupdate] [v1,3/3] swupdate: Set service type to exec Hi James, On 06.06.22 03:53, James Hilliard wrote: > On Thu, Apr 28, 2022 at 6:11 AM Muhammad Hamza > <muhammad_hamza@mentor.com> wrote: >> >> swupdate service launches a shell script which is responsible for >> launcing swupdate core. Default service type considers that unit is >> started right after main process is forked, and dependent services >> can be launched right away, however it take some time for swupdate >> core to initialize. This causes swupdate-client, launched by >> swupdate-usb service, to end up in a race condition if swupdate-usb >> service is launched right after swupdate service as service manager >> considers that swupdate unit is fully running, whereas swupdate core >> has not completely initialized yet. This results in immature launcing >> of swupdate-client and it fails with "swupdate_async_start returns -1" >> because host socket are not initialized yet in swupdate core for the >> client to connect to. >> When service type is set to "exec" service manager considers that a >> service unit is started after the main process binary is executed >> making sure that dependent services are not launched till core is >> initialized. swupdate.sh uses exec to launch swupdate core this makes >> sure that swupdate.sh is considered executed only once swupdate core >> is running. >> This commits sets service type to "exec" and makes use of the way >> swupdate.sh executes swupdate core using exec command to make sure >> that swupdate-client and core do not end up in race condition. >> >> Signed-off-by: Muhammad Hamza <muhammad_hamza@mentor.com> >> --- >> recipes-support/swupdate/swupdate/swupdate.service | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/recipes-support/swupdate/swupdate/swupdate.service >> b/recipes-support/swupdate/swupdate/swupdate.service >> index 7f36619..c0253aa 100644 >> --- a/recipes-support/swupdate/swupdate/swupdate.service >> +++ b/recipes-support/swupdate/swupdate/swupdate.service >> @@ -4,6 +4,7 @@ Documentation=https://github.com/sbabic/swupdate >> Documentation=https://sbabic.github.io/swupdate >> >> [Service] >> +Type=exec > Should actually be this I think: > Type=notify > > Since we implement notify support here: > https://github.com/sbabic/swupdate/blob/a10214e88eba43ae0382c84d9f0d10 > cf5d623e2a/core/swupdate.c#L927 You're right - notify is the right type here. @Muhammad ? Best regards, Stefano >> ExecStart=@LIBDIR@/swupdate/swupdate.sh >> KillMode=mixed >> >> -- >> 2.25.1 >> >> -- >> You received this message because you are subscribed to the Google Groups "swupdate" group. >> To unsubscribe from this group and stop receiving emails from it, send an email to swupdate+unsubscribe@googlegroups.com. >> To view this discussion on the web visit https://groups.google.com/d/msgid/swupdate/20220428121033.1609620-3-muhammad_hamza%40mentor.com. >
diff --git a/recipes-support/swupdate/swupdate/swupdate.service b/recipes-support/swupdate/swupdate/swupdate.service index 7f36619..c0253aa 100644 --- a/recipes-support/swupdate/swupdate/swupdate.service +++ b/recipes-support/swupdate/swupdate/swupdate.service @@ -4,6 +4,7 @@ Documentation=https://github.com/sbabic/swupdate Documentation=https://sbabic.github.io/swupdate [Service] +Type=exec ExecStart=@LIBDIR@/swupdate/swupdate.sh KillMode=mixed
swupdate service launches a shell script which is responsible for launcing swupdate core. Default service type considers that unit is started right after main process is forked, and dependent services can be launched right away, however it take some time for swupdate core to initialize. This causes swupdate-client, launched by swupdate-usb service, to end up in a race condition if swupdate-usb service is launched right after swupdate service as service manager considers that swupdate unit is fully running, whereas swupdate core has not completely initialized yet. This results in immature launcing of swupdate-client and it fails with "swupdate_async_start returns -1" because host socket are not initialized yet in swupdate core for the client to connect to. When service type is set to "exec" service manager considers that a service unit is started after the main process binary is executed making sure that dependent services are not launched till core is initialized. swupdate.sh uses exec to launch swupdate core this makes sure that swupdate.sh is considered executed only once swupdate core is running. This commits sets service type to "exec" and makes use of the way swupdate.sh executes swupdate core using exec command to make sure that swupdate-client and core do not end up in race condition. Signed-off-by: Muhammad Hamza <muhammad_hamza@mentor.com> --- recipes-support/swupdate/swupdate/swupdate.service | 1 + 1 file changed, 1 insertion(+)