Opened 2 years ago

Last modified 2 years ago

#17949 new bug

launch_daemon messing with BRoster's add sig handling

Reported by: humdinger Owned by: axeld
Priority: normal Milestone: Unscheduled
Component: Servers/launch_daemon Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

This is hrev56449.

Something weird seems to be going on with the launch daemon. I saw it when working on Clipdinger (see short ML thread). It turned out not being one of my usual stupid coding mistakes as it also happens when whittling it down to the most simple app, see attached TestApp.
The TestApp does nothing but react to a B_ABOUT_REQUESTED message to show its AboutWindow.

This works as expected:

  • Start TestApp
  • In Terminal: hey application/x-vnd.humdinger-testapp _ABR -> shows the AboutWindow
  • Quit/kill TestApp and restart it
  • Do the hey-command above again -> still works

Now, copy the file TestApp_userlaunch into /system/non-packaged/data/user_launch and reboot. This will auto-start TestApp.

Do the above again. It still works, until quitting/killing and restarting the TestApp. Then the message-sending 'hey' command gets stuck when creating the BMessenger to send the B_ABOUT_REQUESTED message.

I attached a debug report when killing 'hey' with ProcessController, if that is any help.

Change History (4)

by humdinger, 2 years ago

Attachment: TestApp.zip added

The TestApp

by humdinger, 2 years ago

the hey debug report

comment:1 by axeld, 2 years ago

The test app waits for launch_daemon to resolve the signature, which it apparently never does.

comment:2 by humdinger, 2 years ago

FWIW, I 'fixed' the issue for Clipdinger by creating the BMessenger with sig + team ID. The diff:

-    BMessenger messenger(kApplicationSignature);
-    if (messenger.IsValid())
-            messenger.SendMessage(new BMessage(ACTIVATE));
-    else    // In case we're not running (crashed?)
-            be_roster->Launch(kApplicationSignature, new BMessage(ACTIVATE));
-    break;
+    team_id team;
+    team = be_roster->TeamFor(kApplicationSignature);
+    if (team < 0) {
+            be_roster->Launch(kApplicationSignature);
+            while (be_roster->TeamFor(kApplicationSignature) < 0)
+                    snooze(100000);
+    }
+    team = be_roster->TeamFor(kApplicationSignature);
+    BMessenger messenger(kApplicationSignature, team);
+    if (messenger.IsValid()) {
+            BMessage message(ACTIVATE);
+            messenger.SendMessage(&message);
+    }
Note: See TracTickets for help on using tickets.