Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(306)

Delta Between Two Patch Sets: src/pkg/runtime/netpoll_windows.c

Issue 12413043: code review 12413043: net: reduce number of memory allocations during IO oper... (Closed)
Left Patch Set: Created 11 years, 7 months ago
Right Patch Set: diff -r a29203f71b1f https://go.googlecode.com/hg/ Created 11 years, 7 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/net/tcp_test.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2013 The Go Authors. All rights reserved. 1 // Copyright 2013 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 #include "runtime.h" 5 #include "runtime.h"
6 #include "defs_GOOS_GOARCH.h" 6 #include "defs_GOOS_GOARCH.h"
7 #include "os_GOOS.h" 7 #include "os_GOOS.h"
8 8
9 #define DWORD_MAX 0xffffffff 9 #define DWORD_MAX 0xffffffff
10 10
11 #pragma dynimport runtime·CreateIoCompletionPort CreateIoCompletionPort "kernel3 2.dll" 11 #pragma dynimport runtime·CreateIoCompletionPort CreateIoCompletionPort "kernel3 2.dll"
12 #pragma dynimport runtime·GetQueuedCompletionStatus GetQueuedCompletionStatus "k ernel32.dll" 12 #pragma dynimport runtime·GetQueuedCompletionStatus GetQueuedCompletionStatus "k ernel32.dll"
13 13
14 extern void *runtime·CreateIoCompletionPort; 14 extern void *runtime·CreateIoCompletionPort;
15 extern void *runtime·GetQueuedCompletionStatus; 15 extern void *runtime·GetQueuedCompletionStatus;
16 16
17 #define INVALID_HANDLE_VALUE ((uintptr)-1) 17 #define INVALID_HANDLE_VALUE ((uintptr)-1)
18 18
19 // net_anOp must be the same as beginning of net.anOp. Keep these in sync. 19 // net_op must be the same as beginning of net.operation. Keep these in sync.
20 typedef struct net_anOp net_anOp; 20 typedef struct net_op net_op;
21 struct net_anOp 21 struct net_op
22 { 22 {
23 // used by windows 23 // used by windows
24 Overlapped o; 24 Overlapped o;
25 // used by netpoll 25 // used by netpoll
26 uintptr runtimeCtx; 26 uintptr runtimeCtx;
27 int32 mode; 27 int32 mode;
28 int32 errno; 28 int32 errno;
29 uint32 qty; 29 uint32 qty;
30 }; 30 };
31 31
(...skipping 27 matching lines...) Expand all
59 return 0; 59 return 0;
60 } 60 }
61 61
62 // Polls for completed network IO. 62 // Polls for completed network IO.
63 // Returns list of goroutines that become runnable. 63 // Returns list of goroutines that become runnable.
64 G* 64 G*
65 runtime·netpoll(bool block) 65 runtime·netpoll(bool block)
66 { 66 {
67 uint32 wait, qty, key; 67 uint32 wait, qty, key;
68 int32 mode, errno; 68 int32 mode, errno;
69 » net_anOp *o; 69 » net_op *o;
70 G *gp; 70 G *gp;
71 71
72 if(iocphandle == INVALID_HANDLE_VALUE) 72 if(iocphandle == INVALID_HANDLE_VALUE)
73 return nil; 73 return nil;
74 gp = nil; 74 gp = nil;
75 retry: 75 retry:
76 o = nil; 76 o = nil;
77 errno = 0; 77 errno = 0;
78 qty = 0; 78 qty = 0;
79 wait = INFINITE; 79 wait = INFINITE;
(...skipping 23 matching lines...) Expand all
103 runtime·printf("netpoll: GetQueuedCompletionStatus returned inva lid mode=%d\n", mode); 103 runtime·printf("netpoll: GetQueuedCompletionStatus returned inva lid mode=%d\n", mode);
104 runtime·throw("netpoll: GetQueuedCompletionStatus returned inval id mode"); 104 runtime·throw("netpoll: GetQueuedCompletionStatus returned inval id mode");
105 } 105 }
106 o->errno = errno; 106 o->errno = errno;
107 o->qty = qty; 107 o->qty = qty;
108 runtime·netpollready(&gp, (void*)o->runtimeCtx, mode); 108 runtime·netpollready(&gp, (void*)o->runtimeCtx, mode);
109 if(block && gp == nil) 109 if(block && gp == nil)
110 goto retry; 110 goto retry;
111 return gp; 111 return gp;
112 } 112 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b