Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
Disabling channels
Browse files Browse the repository at this point in the history
  • Loading branch information
pauarge committed Jan 7, 2018
1 parent fd0b7f4 commit 658fe20
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/server/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ func (g *Gossiper) handleStatusPacket(msg common.StatusPacket, relay *net.UDPAdd
relayStr := getRelayStr(relay)
log.Println("Got status packet from", relayStr)

g.channelsLock.RLock()
/*g.channelsLock.RLock()
if ch, ok := g.channels[relayStr]; ok {
ch <- true
}
g.channelsLock.RUnlock()
g.channelsLock.RUnlock()*/

remoteWant := parseWant(msg)
g.wantLock.RLock()
Expand Down
11 changes: 5 additions & 6 deletions src/server/senders.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"log"
"github.com/dedis/protobuf"
"github.com/pauarge/decWebRTC/src/common"
"time"
)

func (g *Gossiper) sendStatusPacket(relay *net.UDPAddr) {
Expand Down Expand Up @@ -51,24 +50,24 @@ func (g *Gossiper) rumorMongering(address string, msg common.RumorMessage) {
if err != nil {
log.Println(err)
} else {
g.channelsLock.RLock()
/*g.channelsLock.RLock()
ch := g.channels[address]
g.channelsLock.RUnlock()
g.channelsLock.RUnlock()*/

addr, err := net.ResolveUDPAddr("udp4", address)
_, err = g.gossipConn.WriteToUDP(packetBytes, addr)
if err != nil {
log.Println(err)
g.deletePeer(address)
ch <- true
//ch <- true
}
select {
/*select {
case _ = <-ch:
log.Println("Unlocked channel")
case <-time.After(time.Second * common.TimeOutSecs):
log.Println("Timeout on mongering")
g.deletePeer(address)
}
}*/
}
log.Println("Finished mongering to", address)
}
Expand Down
8 changes: 4 additions & 4 deletions src/server/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ func (g *Gossiper) addPeer(addr string) {
g.peersLock.Lock()
g.peers[addr] = true
g.peersLock.Unlock()
g.channelsLock.Lock()
/*g.channelsLock.Lock()
g.channels[addr] = make(chan bool)
g.channelsLock.Unlock()
g.channelsLock.Unlock()*/
g.sendUserList()
log.Println("Added peer", addr)
}
Expand All @@ -88,9 +88,9 @@ func (g *Gossiper) deletePeer(addr string) {
delete(g.want, addr)
g.wantLock.Unlock()

g.channelsLock.Lock()
/*g.channelsLock.Lock()
delete(g.channels, addr)
g.channelsLock.Unlock()
g.channelsLock.Unlock()*/

g.sendUserList()
log.Println("Delted peer", addr)
Expand Down

0 comments on commit 658fe20

Please sign in to comment.