Skip to content

Commit

Permalink
fixes for weekly.2012-02-22.
Browse files Browse the repository at this point in the history
  • Loading branch information
4ad committed Feb 28, 2012
1 parent d3bce22 commit 38b9a0b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
3 changes: 2 additions & 1 deletion peer/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"log"
"net"
"os"
"syscall"
"time"
)

Expand Down Expand Up @@ -187,7 +188,7 @@ func Main(clusterName, self, buri, rwsk, rosk string, cl *doozer.Conn, udpConn *

buf := make([]byte, maxUDPLen)
n, addr, err := udpConn.ReadFromUDP(buf)
if err == os.EINVAL {
if err == syscall.EINVAL {
return
}
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/ha/doozerd/store"
"log"
"net"
"os"
"syscall"
)

// ListenAndServe listens on l, accepts network connections, and
Expand All @@ -15,10 +15,10 @@ func ListenAndServe(l net.Listener, canWrite chan bool, st *store.Store, p conse
for {
c, err := l.Accept()
if err != nil {
if err == os.EINVAL {
if err == syscall.EINVAL {
break
}
if e, ok := err.(*net.OpError); ok && e.Err == os.EINVAL {
if e, ok := err.(*net.OpError); ok && e.Err == syscall.EINVAL {
break
}
log.Println(err)
Expand Down
24 changes: 12 additions & 12 deletions server/txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/ha/doozerd/store"
"io"
"log"
"os"
"sort"
"syscall"
)

type txn struct {
Expand Down Expand Up @@ -48,7 +48,7 @@ func (t *txn) run() {

func (t *txn) get() {
if !t.c.raccess {
t.respondOsError(os.EACCES)
t.respondOsError(syscall.EACCES)
return
}

Expand Down Expand Up @@ -80,7 +80,7 @@ func (t *txn) get() {

func (t *txn) set() {
if !t.c.waccess {
t.respondOsError(os.EACCES)
t.respondOsError(syscall.EACCES)
return
}

Expand All @@ -107,7 +107,7 @@ func (t *txn) set() {

func (t *txn) del() {
if !t.c.waccess {
t.respondOsError(os.EACCES)
t.respondOsError(syscall.EACCES)
return
}

Expand All @@ -133,7 +133,7 @@ func (t *txn) del() {

func (t *txn) nop() {
if !t.c.waccess {
t.respondOsError(os.EACCES)
t.respondOsError(syscall.EACCES)
return
}

Expand All @@ -156,7 +156,7 @@ func (t *txn) rev() {

func (t *txn) stat() {
if !t.c.raccess {
t.respondOsError(os.EACCES)
t.respondOsError(syscall.EACCES)
return
}

Expand All @@ -176,7 +176,7 @@ func (t *txn) stat() {

func (t *txn) getdir() {
if !t.c.raccess {
t.respondOsError(os.EACCES)
t.respondOsError(syscall.EACCES)
return
}

Expand Down Expand Up @@ -216,7 +216,7 @@ func (t *txn) getdir() {

func (t *txn) wait() {
if !t.c.raccess {
t.respondOsError(os.EACCES)
t.respondOsError(syscall.EACCES)
return
}

Expand Down Expand Up @@ -256,7 +256,7 @@ func (t *txn) wait() {

func (t *txn) walk() {
if !t.c.raccess {
t.respondOsError(os.EACCES)
t.respondOsError(syscall.EACCES)
return
}

Expand Down Expand Up @@ -306,7 +306,7 @@ func (t *txn) access() {
if t.c.grant(string(t.req.Value)) {
t.respond()
} else {
t.respondOsError(os.EACCES)
t.respondOsError(syscall.EACCES)
}
}

Expand All @@ -318,9 +318,9 @@ func (t *txn) respondOsError(err error) {
t.respondErrCode(response_REV_MISMATCH)
case store.ErrTooLate:
t.respondErrCode(response_TOO_LATE)
case os.EISDIR:
case syscall.EISDIR:
t.respondErrCode(response_ISDIR)
case os.ENOTDIR:
case syscall.ENOTDIR:
t.respondErrCode(response_NOTDIR)
default:
t.resp.ErrDetail = proto.String(err.Error())
Expand Down
12 changes: 6 additions & 6 deletions store/node.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package store

import (
"os"
"syscall"
)

var emptyDir = node{V: "", Ds: make(map[string]node), Rev: Dir}
Expand Down Expand Up @@ -41,14 +41,14 @@ func (n node) at(parts []string) (node, error) {
return m.at(parts[1:])
}
}
return node{}, os.ENOENT
return node{}, syscall.ENOENT
}
panic("unreachable")
}

func (n node) get(parts []string) ([]string, int64) {
switch m, err := n.at(parts); err {
case os.ENOENT:
case syscall.ENOENT:
return []string{""}, Missing
default:
if len(m.Ds) > 0 {
Expand All @@ -66,7 +66,7 @@ func (n node) Get(path string) ([]string, int64) {

func (n node) stat(parts []string) (int32, int64) {
switch m, err := n.at(parts); err {
case os.ENOENT:
case syscall.ENOENT:
return 0, Missing
default:
l := len(m.Ds)
Expand Down Expand Up @@ -143,7 +143,7 @@ func (n node) apply(seqn int64, mut string) (rep node, ev Event) {
break
}
if dirRev != Dir {
ev.Err = os.ENOTDIR
ev.Err = syscall.ENOTDIR
break
}
}
Expand All @@ -154,7 +154,7 @@ func (n node) apply(seqn int64, mut string) (rep node, ev Event) {
if rev != Clobber && rev < curRev {
ev.Err = ErrRevMismatch
} else if curRev == Dir {
ev.Err = os.EISDIR
ev.Err = syscall.EISDIR
}
}

Expand Down

0 comments on commit 38b9a0b

Please sign in to comment.