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

Fix datarace while update a channel.lastEventID #30

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Commits on Jul 5, 2021

  1. Add unit test for multiple senders to one channel.

    The usage pattern: Imagine  we have a client which subsribed to multiple topics
    inside one connection. It track changes of specific items state by their ID
    as example.
    
    The test is passing in general case. But run it with race detection option and
    it fails due data race condition detected.
    
    ==================
    WARNING: DATA RACE
    Write at 0x00c0000120d8 by goroutine 39:
      github.com/alexandrevicenzi/go-sse.(*Channel).SendMessage()
          /Users/iscander/projects/go-sse/channel.go:26 +0x8c
      github.com/alexandrevicenzi/go-sse.(*Server).SendMessage()
          /Users/iscander/projects/go-sse/sse.go:116 +0x21b
      github.com/alexandrevicenzi/go-sse.TestMultipleTopics.func2()
          /Users/iscander/projects/go-sse/sse_test.go:135 +0xce
    
    Previous write at 0x00c0000120d8 by goroutine 38:
      github.com/alexandrevicenzi/go-sse.(*Channel).SendMessage()
          /Users/iscander/projects/go-sse/channel.go:26 +0x8c
      github.com/alexandrevicenzi/go-sse.(*Server).SendMessage()
          /Users/iscander/projects/go-sse/sse.go:116 +0x21b
      github.com/alexandrevicenzi/go-sse.TestMultipleTopics.func2()
          /Users/iscander/projects/go-sse/sse_test.go:135 +0xce
    
    Goroutine 39 (running) created at:
      github.com/alexandrevicenzi/go-sse.TestMultipleTopics()
          /Users/iscander/projects/go-sse/sse_test.go:132 +0x735
      testing.tRunner()
          /usr/local/Cellar/go/1.16.3/libexec/src/testing/testing.go:1193 +0x202
    
    Goroutine 38 (running) created at:
      github.com/alexandrevicenzi/go-sse.TestMultipleTopics()
          /Users/iscander/projects/go-sse/sse_test.go:132 +0x735
      testing.tRunner()
          /usr/local/Cellar/go/1.16.3/libexec/src/testing/testing.go:1193 +0x202
    iscander committed Jul 5, 2021
    Configuration menu
    Copy the full SHA
    562d884 View commit details
    Browse the repository at this point in the history
  2. Fix datarace while update a channel.lastEventID

    Protect the option by wrappring into a mutex. The datarace is gone.
    It closes alexandrevicenzi#18
    iscander committed Jul 5, 2021
    Configuration menu
    Copy the full SHA
    58741aa View commit details
    Browse the repository at this point in the history

Commits on Aug 2, 2021

  1. Change go.mod reference

    iscander committed Aug 2, 2021
    Configuration menu
    Copy the full SHA
    7022cc2 View commit details
    Browse the repository at this point in the history