OLD | NEW |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package net | 5 package net |
6 | 6 |
7 import ( | 7 import ( |
8 "io" | 8 "io" |
9 "os" | 9 "os" |
10 "syscall" | 10 "syscall" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 } | 52 } |
53 n, err1 := syscall.Sendfile(dst, src, nil, n) | 53 n, err1 := syscall.Sendfile(dst, src, nil, n) |
54 if n > 0 { | 54 if n > 0 { |
55 written += int64(n) | 55 written += int64(n) |
56 remain -= int64(n) | 56 remain -= int64(n) |
57 } | 57 } |
58 if n == 0 && err1 == nil { | 58 if n == 0 && err1 == nil { |
59 break | 59 break |
60 } | 60 } |
61 if err1 == syscall.EAGAIN { | 61 if err1 == syscall.EAGAIN { |
62 » » » if err1 = c.pollServer.WaitWrite(c); err1 == nil { | 62 » » » if err1 = c.pd.WaitWrite(); err1 == nil { |
63 continue | 63 continue |
64 } | 64 } |
65 } | 65 } |
66 if err1 != nil { | 66 if err1 != nil { |
67 // This includes syscall.ENOSYS (no kernel | 67 // This includes syscall.ENOSYS (no kernel |
68 // support) and syscall.EINVAL (fd types which | 68 // support) and syscall.EINVAL (fd types which |
69 // don't implement sendfile together) | 69 // don't implement sendfile together) |
70 err = &OpError{"sendfile", c.net, c.raddr, err1} | 70 err = &OpError{"sendfile", c.net, c.raddr, err1} |
71 break | 71 break |
72 } | 72 } |
73 } | 73 } |
74 if lr != nil { | 74 if lr != nil { |
75 lr.N = remain | 75 lr.N = remain |
76 } | 76 } |
77 return written, err, written > 0 | 77 return written, err, written > 0 |
78 } | 78 } |
OLD | NEW |