OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [net/] [newpollserver.go] - Blame information for rev 861

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2010 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
 
5
// +build darwin freebsd linux netbsd openbsd
6
 
7
package net
8
 
9
import (
10
        "os"
11
        "syscall"
12
)
13
 
14
func newPollServer() (s *pollServer, err error) {
15
        s = new(pollServer)
16
        s.cr = make(chan *netFD, 1)
17
        s.cw = make(chan *netFD, 1)
18
        if s.pr, s.pw, err = os.Pipe(); err != nil {
19
                return nil, err
20
        }
21
        if err = syscall.SetNonblock(s.pr.Fd(), true); err != nil {
22
                goto Errno
23
        }
24
        if err = syscall.SetNonblock(s.pw.Fd(), true); err != nil {
25
                goto Errno
26
        }
27
        if s.poll, err = newpollster(); err != nil {
28
                goto Error
29
        }
30
        if _, err = s.poll.AddFD(s.pr.Fd(), 'r', true); err != nil {
31
                s.poll.Close()
32
                goto Error
33
        }
34
        s.pending = make(map[int]*netFD)
35
        go s.Run()
36
        return s, nil
37
 
38
Errno:
39
        err = &os.PathError{
40
                Op:   "setnonblock",
41
                Path: s.pr.Name(),
42
                Err:  err,
43
        }
44
Error:
45
        s.pr.Close()
46
        s.pw.Close()
47
        return nil, err
48
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.