Browse Source

Buffered or unbuffered? That is the question.

pull/2/head
Justine Alexandra Roberts Tunney 11 years ago
parent
commit
1bdbfbf2cc
4 changed files with 9 additions and 8 deletions
  1. +1
    -1
      rtp/session.go
  2. +2
    -0
      sip/dialog.go
  3. +4
    -5
      sip/receiver.go
  4. +2
    -2
      sip/transport.go

+ 1
- 1
rtp/session.go View File

@ -53,7 +53,7 @@ func NewSession(host string) (rs *Session, err error) {
return nil, err return nil, err
} }
rs = &Session{ rs = &Session{
C: make(chan *Frame, 32),
C: make(chan *Frame, 4),
E: make(chan error, 1), E: make(chan error, 1),
Sock: sock.(*net.UDPConn), Sock: sock.(*net.UDPConn),
Header: Header{ Header: Header{


+ 2
- 0
sip/dialog.go View File

@ -256,6 +256,8 @@ func (dls *dialogState) cleanup() {
if dls.sock != nil { if dls.sock != nil {
dls.sock.Close() dls.sock.Close()
dls.sock = nil dls.sock = nil
_, _ = <-dls.sockMsgs
<-dls.sockErrs
} }
} }


+ 4
- 5
sip/receiver.go View File

@ -1,7 +1,6 @@
package sip package sip
import ( import (
"github.com/jart/gosip/util"
"log" "log"
"net" "net"
"strconv" "strconv"
@ -13,10 +12,8 @@ func ReceiveMessages(contact *Addr, sock *net.UDPConn, c chan<- *Msg, e chan<- e
for { for {
amt, addr, err := sock.ReadFromUDP(buf) amt, addr, err := sock.ReadFromUDP(buf)
if err != nil { if err != nil {
if !util.IsUseOfClosed(err) {
e <- err
}
return
e <- err
break
} }
ts := time.Now() ts := time.Now()
packet := string(buf[0:amt]) packet := string(buf[0:amt])
@ -36,6 +33,8 @@ func ReceiveMessages(contact *Addr, sock *net.UDPConn, c chan<- *Msg, e chan<- e
fixMessagesFromStrictRouters(contact, msg) fixMessagesFromStrictRouters(contact, msg)
c <- msg c <- msg
} }
close(c)
close(e)
} }
func addReceived(msg *Msg, addr *net.UDPAddr) { func addReceived(msg *Msg, addr *net.UDPAddr) {


+ 2
- 2
sip/transport.go View File

@ -48,8 +48,8 @@ func NewTransport(contact *Addr) (tp *Transport, err error) {
contact.Next = nil contact.Next = nil
contact.Uri.Port = uint16(addr.Port) contact.Uri.Port = uint16(addr.Port)
contact.Uri.Params["transport"] = "udp" contact.Uri.Params["transport"] = "udp"
c := make(chan *Msg, 32)
e := make(chan error, 1)
c := make(chan *Msg)
e := make(chan error)
tp = &Transport{ tp = &Transport{
C: c, C: c,
E: e, E: e,


Loading…
Cancel
Save