Giter Site home page Giter Site logo

SafeSendMessage BUG!! about quasar HOT 4 OPEN

AlphaCharry avatar AlphaCharry commented on May 20, 2024
SafeSendMessage BUG!!

from quasar.

Comments (4)

AlphaCharry avatar AlphaCharry commented on May 20, 2024

This exception is System.ObjectDisposedException, which usually occurs when trying to access an object that has already been disposed. In this case, the exception occurs in the System.Threading.Mutex.ReleaseMutex() method, which means you may be trying to release a mutex that has already been released. In the code you provided, _singleWriteMutex.ReleaseMutex() is called in the finally block, which means it will be executed whether or not the code in the try block throws an exception. If _singleWriteMutex is released before the finally block is executed, then when the finally block tries to release it, it will throw an ObjectDisposedException. To solve this problem, you need to ensure that _singleWriteMutex is not released before the finally block is executed. You can do this by checking if _singleWriteMutex is null or has already been released. Here is a possible solution:

try
 {
     _singleWriteMutex.WaitOne();
     using (PayloadWriter pw = new PayloadWriter(_stream, true))
     {
         OnClientWrite(message, pw.WriteMessage(message));
     }
 }
 catch (Exception)
 {
     Disconnect();
     SendCleanup(true);
 }
 finally
 {
     if (_singleWriteMutex != null && _singleWriteMutex.SafeWaitHandle.IsClosed == false)
     {
         _singleWriteMutex.ReleaseMutex();
     }
 }

from quasar.

MaxXor avatar MaxXor commented on May 20, 2024

Can you create a PR with the fix?

from quasar.

AlphaCharry avatar AlphaCharry commented on May 20, 2024

您可以使用修复程序创建 PR 吗?

What's PR?

from quasar.

MaxXor avatar MaxXor commented on May 20, 2024

A pull request: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request

from quasar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.