{"action":"created","issue":{"url":"https://api.github.com/repos/systemd/systemd/issues/327","labels_url":"https://api.github.com/repos/systemd/systemd/issues/327/labels{/name}","comments_url":"https://api.github.com/repos/systemd/systemd/issues/327/comments","events_url":"https://api.github.com/repos/systemd/systemd/issues/327/events","html_url":"https://github.com/systemd/systemd/issues/327","id":90329231,"number":327,"title":"Document that sd_unref() does not necessarily free a \"default\" bus, even if no part of the program explicitly refs it, due to queued messages","user":{"login":"utezduyar","id":8062069,"avatar_url":"https://avatars.githubusercontent.com/u/8062069?v=3","gravatar_id":"","url":"https://api.github.com/users/utezduyar","html_url":"https://github.com/utezduyar","followers_url":"https://api.github.com/users/utezduyar/followers","following_url":"https://api.github.com/users/utezduyar/following{/other_user}","gists_url":"https://api.github.com/users/utezduyar/gists{/gist_id}","starred_url":"https://api.github.com/users/utezduyar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/utezduyar/subscriptions","organizations_url":"https://api.github.com/users/utezduyar/orgs","repos_url":"https://api.github.com/users/utezduyar/repos","events_url":"https://api.github.com/users/utezduyar/events{/privacy}","received_events_url":"https://api.github.com/users/utezduyar/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/systemd/systemd/labels/documentation","name":"documentation","color":"bfe5bf"},{"url":"https://api.github.com/repos/systemd/systemd/labels/sd-bus","name":"sd-bus","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-06-23T08:58:24Z","updated_at":"2015-07-04T11:47:21Z","closed_at":null,"body":"I stumbled on a memory leakage while integrating gmain with sd-bus but I think the problem can happen without gmain. The problem is due to the fact that we do not know if sd-bus is busy when we are disconnecting from the sd-event. \r\n\r\n```\r\nsd_bus_default_system(&bus) // After this call, ref count is 2\r\nsd_event_default(&event)\r\nsd_bus_attach_event(bus, event, SD_EVENT_PRIORITY_NORMAL);\r\nsd_bus_detach_event(bus);\r\nsd_bus_unref (bus); // Ref count for bus got stuck at 1 due to unsent message\r\n```\r\n\r\nOne propose I have is calling a callback function when we are about to cleanup the sd-bus. In fact maybe similar callback function when we are about to clean up sd-event so we can propagate the cleanup to the higher level callers like ```g_source_destroy```.\r\n\r\nAm I missing something?\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/systemd/systemd/issues/comments/118503354","html_url":"https://github.com/systemd/systemd/issues/327#issuecomment-118503354","issue_url":"https://api.github.com/repos/systemd/systemd/issues/327","id":118503354,"user":{"login":"utezduyar","id":8062069,"avatar_url":"https://avatars.githubusercontent.com/u/8062069?v=3","gravatar_id":"","url":"https://api.github.com/users/utezduyar","html_url":"https://github.com/utezduyar","followers_url":"https://api.github.com/users/utezduyar/followers","following_url":"https://api.github.com/users/utezduyar/following{/other_user}","gists_url":"https://api.github.com/users/utezduyar/gists{/gist_id}","starred_url":"https://api.github.com/users/utezduyar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/utezduyar/subscriptions","organizations_url":"https://api.github.com/users/utezduyar/orgs","repos_url":"https://api.github.com/users/utezduyar/repos","events_url":"https://api.github.com/users/utezduyar/events{/privacy}","received_events_url":"https://api.github.com/users/utezduyar/received_events","type":"User","site_admin":false},"created_at":"2015-07-04T11:47:21Z","updated_at":"2015-07-04T11:47:21Z","body":"I don't really agree that applications are not allowed to use the API to get the default connection. It could be that application is a gdbus applicaiton linking to a sd-bus library. Then all the sudden, bunch of applications need to be changed to pass the default connection. \r\n\r\nIt is of course Ok, if the library opens its own connection and makes sure to clean up after itself but that means we will have per library dbus connections. Isn't it more expensive that way?\r\n\r\nI am not saying we should do the same but if we look at gdbus, they have an API to give you the default bus, ```g_bus_get_sync``` without any restriction weather libraries can use it or not."}}