Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DefaultFuture#doReceived should call done.signalAll instead of done.signal #3678

Closed
kexianjun opened this issue Mar 16, 2019 · 4 comments · Fixed by #3681
Closed

DefaultFuture#doReceived should call done.signalAll instead of done.signal #3678

kexianjun opened this issue Mar 16, 2019 · 4 comments · Fixed by #3681

Comments

@kexianjun
Copy link
Member

in the method of org.apache.dubbo.remoting.exchange.support.DefaultFuture#doReceived, I think we should call done.signalAll() instead of done.signal() ,and it's unnecessary to check done != null because it's always true

private void doReceived(Response res) {
        lock.lock();
        try {
            response = res;
            if (done != null) {
                done.signal();
            }
        } finally {
            lock.unlock();
        }
        if (callback != null) {
            invokeCallback(callback);
        }
    }
@kexianjun kexianjun changed the title DefaultFuture#doReceived should call done.signalAll instead of done.signalAll DefaultFuture#doReceived should call done.signalAll instead of done.signal Mar 16, 2019
@tswstarplanet
Copy link
Contributor

Sounds good! signall can avoid dead lock better

@kexianjun
Copy link
Member Author

Sounds good! signall can avoid dead lock better

yes, using signal can cause threads to block until a timeout in some scenarios

@xueshanyinyan
Copy link

阅读2.6.2版本的源码,觉得这个优化没必要吧,条件变量的等待队列里就一个线程,signal足够了,当然换成signalAll是没啥问题。是实际投入使用中出现了这样的问题吗?是什么样的问题呢?现在的版本已经使用CompletableFuture异步转同步了呢。

@LeroyPine
Copy link

为什么 signal 或导致线程阻塞呢? DefaultFuture 不是和线程一一对应的。 不存在多线程竞争的关系吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants