Commit Graph

15 Commits

Author SHA1 Message Date
Simon Ser
08bb06c164
Nuke user.lock
Split user.register into two functions, one to make sure the user is
authenticated, the other to send our current state. This allows to get
rid of data races by doing the second part in the user goroutine.

Closes: https://todo.sr.ht/~emersion/soju/22
2020-03-27 19:17:58 +01:00
Simon Ser
c0f5850e5b
Add eventDownstreamDisconnected
This should remove the need for protecting user.downstreamConns with a
mutex.
2020-03-27 17:55:03 +01:00
Simon Ser
36ab6ece09
Add eventDownstreamConnected
In a later commit, we'll be able to move part of downstreamConn.register
into the user goroutine to prevent races.

References: https://todo.sr.ht/~emersion/soju/22
2020-03-27 17:21:05 +01:00
Simon Ser
474f2889d9
Introduce a user.events channel
This allows to easily add new events, and also guarantees ordering
between different event types.
2020-03-27 16:33:19 +01:00
Simon Ser
21241c2009
Consume ring buffer for networks added on-the-fly 2020-03-25 11:28:25 +01:00
Simon Ser
293a0e8e20
Move upstreamConn.ring to network
This handles upstream disconnection and re-connection better.
2020-03-25 10:53:08 +01:00
Simon Ser
015281ed35
Add user.{add,remove}Downstream 2020-03-23 16:05:00 +01:00
Simon Ser
c511a3c895
Add network.upstream helper 2020-03-21 10:24:38 +01:00
Simon Ser
cb52f393f4
Drop messages on closed connections
This prevents this panic:

    panic: send on closed channel
    goroutine 9 [running]:
    git.sr.ht/~emersion/soju.(*upstreamConn).SendMessage(...)
            /home/simon/src/soju/upstream.go:866
    git.sr.ht/~emersion/soju.(*upstreamConn).handleMessage(0xc000084b40, 0xc000144680, 0x2, 0x0)
            /home/simon/src/soju/upstream.go:152 +0x62b
    git.sr.ht/~emersion/soju.(*user).run(0xc0000b8070)
            /home/simon/src/soju/user.go:144 +0x53d
    created by git.sr.ht/~emersion/soju.(*Server).Run
            /home/simon/src/soju/server.go:88 +0x286
2020-03-21 08:29:44 +01:00
Simon Ser
45d118dd12
Move upstreamConn.history to network 2020-03-20 22:48:17 +01:00
delthas
37eb162b75 Add create-network bouncer service command 2020-03-19 01:14:44 +01:00
delthas
37e56a01b2 Add suffixing for multi-upstream connections 2020-03-19 00:06:48 +01:00
delthas
1c41576988 schema: add Network.name 2020-03-19 00:06:48 +01:00
Simon Ser
3919ee2036
Per-user dispatcher goroutine
This allows message handlers to read upstream/downstream connection
information without causing any race condition.

References: https://todo.sr.ht/~emersion/soju/1
2020-03-16 12:44:59 +01:00
Simon Ser
7fe0986859
Split user logic into its own file 2020-03-16 11:18:41 +01:00