felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guillaume Nodet (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FELIX-4190) The framework should not hold any lock while calling ServiceFactory#unget
Date Mon, 24 Feb 2014 14:05:19 GMT

    [ https://issues.apache.org/jira/browse/FELIX-4190?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13910322#comment-13910322
] 

Guillaume Nodet commented on FELIX-4190:
----------------------------------------

So I come back to my earlier proposal which is to duplicate the loop at the end after having
invalidted the registration.
I.e. 

{code}
        // Now forcibly unget the service object for all stubborn clients.
        Bundle[] clients = getUsingBundles(reg.getReference());
        for (int i = 0; (clients != null) && (i < clients.length); i++)
        {
            while (ungetService(clients[i], reg.getReference()))
                ; // Keep removing until it is no longer possible
        }
        ((ServiceRegistrationImpl) reg).invalidate();
        for (int i = 0; (clients != null) && (i < clients.length); i++)
        {
            while (ungetService(clients[i], reg.getReference()))
                ; // Keep removing until it is no longer possible
        }
{code}

The call to getUsingBundles does not need to be synchronized, as the method itself synchronizes
on this.
At this point, no new bundles can acquire a service reference, so we can keep the list of
bundles and iterator on it safely.
Then, we do a first pass on ungetService which should remove most of the references, except
if a bundle is re-acquiring the service.
We then invalidate the registration, which will prevent any further call to getService.
We iterate another time on the bundles in case a bundle has acquired the service during the
first loop.


> The framework should not hold any lock while calling ServiceFactory#unget
> -------------------------------------------------------------------------
>
>                 Key: FELIX-4190
>                 URL: https://issues.apache.org/jira/browse/FELIX-4190
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>            Reporter: Guillaume Nodet
>            Assignee: Guillaume Nodet
>             Fix For: framework-4.4.0
>
>




--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Mime
View raw message