[CMAKE]
[reactos.git] / dll / win32 / rpcrt4 / rpcrt4_ros.diff
1 Index: epm_towers.h
2 ===================================================================
3 --- epm_towers.h (working copy)
4 +++ epm_towers.h (working copy)
5 @@ -17,11 +17,11 @@
6 * License along with this library; if not, write to the Free Software
7 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
8 *
9 */
10
11 -#include "epm.h"
12 +#include "epm_c.h"
13
14 #define EPM_PROTOCOL_DNET_NSP 0x04
15 #define EPM_PROTOCOL_OSI_TP4 0x05
16 #define EPM_PROTOCOL_OSI_CLNS 0x06
17 #define EPM_PROTOCOL_TCP 0x07
18 Index: ndr_marshall.c
19 ===================================================================
20 --- ndr_marshall.c (working copy)
21 +++ ndr_marshall.c (working copy)
22 @@ -6032,6 +6032,7 @@
23 case RPC_FC_WCHAR:
24 case RPC_FC_SHORT:
25 case RPC_FC_USHORT:
26 + case RPC_FC_ENUM16:
27 {
28 USHORT d;
29 ALIGN_POINTER(pStubMsg->Buffer, sizeof(USHORT));
30 Index: rpc_epmap.c
31 ===================================================================
32 --- rpc_epmap.c (working copy)
33 +++ rpc_epmap.c (working copy)
34 @@ -30,11 +30,11 @@
35
36 #include "wine/debug.h"
37 #include "wine/exception.h"
38
39 #include "rpc_binding.h"
40 -#include "epm.h"
41 +#include "epm_c.h"
42 #include "epm_towers.h"
43
44 WINE_DEFAULT_DEBUG_CHANNEL(ole);
45
46 /* The "real" RPC portmapper endpoints that I know of are:
47 Index: rpc_server.c
48 ===================================================================
49 --- rpc_server.c (working copy)
50 +++ rpc_server.c (working copy)
51 @@ -1040,22 +1040,28 @@
52 /***********************************************************************
53 * RpcMgmtServerWaitListen (RPCRT4.@)
54 */
55 RPC_STATUS WINAPI RpcMgmtWaitServerListen( void )
56 {
57 - TRACE("()\n");
58 + RpcServerProtseq *cps;
59
60 EnterCriticalSection(&listen_cs);
61
62 if (!std_listen) {
63 LeaveCriticalSection(&listen_cs);
64 return RPC_S_NOT_LISTENING;
65 }
66
67 + do {
68 LeaveCriticalSection(&listen_cs);
69 + LIST_FOR_EACH_ENTRY(cps, &protseqs, RpcServerProtseq, entry)
70 + WaitForSingleObject(cps->server_ready_event, INFINITE);
71
72 - FIXME("not waiting for server calls to finish\n");
73 + EnterCriticalSection(&listen_cs);
74 + } while (!std_listen);
75 +
76 + LeaveCriticalSection(&listen_cs);
77
78 return RPC_S_OK;
79 }
80
81 /***********************************************************************
82 Index: rpc_transport.c
83 ===================================================================
84 --- rpc_transport.c (working copy)
85 +++ rpc_transport.c (working copy)
86 @@ -65,10 +65,13 @@
87 # include <sys/poll.h>
88 # endif
89 # define closesocket close
90 #endif /* defined(__MINGW32__) || defined (_MSC_VER) */
91
92 +#include <winsock2.h>
93 +#include <ws2tcpip.h>
94 +
95 #include "windef.h"
96 #include "winbase.h"
97 #include "winnls.h"
98 #include "winerror.h"
99 #include "winternl.h"
100 @@ -82,10 +85,12 @@
101 #include "rpc_binding.h"
102 #include "rpc_message.h"
103 #include "rpc_server.h"
104 #include "epm_towers.h"
105
106 +#include "unix_func.h"
107 +
108 #ifndef SOL_TCP
109 # define SOL_TCP IPPROTO_TCP
110 #endif
111
112 WINE_DEFAULT_DEBUG_CHANNEL(rpc);
113 @@ -94,11 +99,11 @@
114
115 typedef struct _RpcConnection_np
116 {
117 RpcConnection common;
118 HANDLE pipe;
119 - OVERLAPPED ovl;
120 + OVERLAPPED ovl[2];
121 BOOL listening;
122 } RpcConnection_np;
123
124 static RpcConnection *rpcrt4_conn_np_alloc(void)
125 {
126 @@ -118,17 +123,17 @@
127 return RPC_S_OK;
128
129 npc->listening = TRUE;
130 for (;;)
131 {
132 - if (ConnectNamedPipe(npc->pipe, &npc->ovl))
133 + if (ConnectNamedPipe(npc->pipe, &npc->ovl[0]))
134 return RPC_S_OK;
135
136 switch(GetLastError())
137 {
138 case ERROR_PIPE_CONNECTED:
139 - SetEvent(npc->ovl.hEvent);
140 + SetEvent(npc->ovl[0].hEvent);
141 return RPC_S_OK;
142 case ERROR_IO_PENDING:
143 /* will be completed in rpcrt4_protseq_np_wait_for_new_connection */
144 return RPC_S_OK;
145 case ERROR_NO_DATA_DETECTED:
146 @@ -146,11 +151,11 @@
147 static RPC_STATUS rpcrt4_conn_create_pipe(RpcConnection *Connection, LPCSTR pname)
148 {
149 RpcConnection_np *npc = (RpcConnection_np *) Connection;
150 TRACE("listening on %s\n", pname);
151
152 - npc->pipe = CreateNamedPipeA(pname, PIPE_ACCESS_DUPLEX,
153 + npc->pipe = CreateNamedPipeA(pname, PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
154 PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE,
155 PIPE_UNLIMITED_INSTANCES,
156 RPC_MAX_PACKET_SIZE, RPC_MAX_PACKET_SIZE, 5000, NULL);
157 if (npc->pipe == INVALID_HANDLE_VALUE) {
158 WARN("CreateNamedPipe failed with error %d\n", GetLastError());
159 @@ -159,11 +164,12 @@
160 else
161 return RPC_S_CANT_CREATE_ENDPOINT;
162 }
163
164 memset(&npc->ovl, 0, sizeof(npc->ovl));
165 - npc->ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
166 + npc->ovl[0].hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
167 + npc->ovl[1].hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
168
169 /* Note: we don't call ConnectNamedPipe here because it must be done in the
170 * server thread as the thread must be alertable */
171 return RPC_S_OK;
172 }
173 @@ -220,11 +226,12 @@
174 /* success */
175 memset(&npc->ovl, 0, sizeof(npc->ovl));
176 /* pipe is connected; change to message-read mode. */
177 dwMode = PIPE_READMODE_MESSAGE;
178 SetNamedPipeHandleState(pipe, &dwMode, NULL, NULL);
179 - npc->ovl.hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
180 + npc->ovl[0].hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
181 + npc->ovl[1].hEvent = CreateEventW(NULL, TRUE, FALSE, NULL);
182 npc->pipe = pipe;
183
184 return RPC_S_OK;
185 }
186
187 @@ -326,11 +333,12 @@
188 {
189 /* because of the way named pipes work, we'll transfer the connected pipe
190 * to the child, then reopen the server binding to continue listening */
191
192 new_npc->pipe = old_npc->pipe;
193 - new_npc->ovl = old_npc->ovl;
194 + new_npc->ovl[0] = old_npc->ovl[0];
195 + new_npc->ovl[1] = old_npc->ovl[1];
196 old_npc->pipe = 0;
197 memset(&old_npc->ovl, 0, sizeof(old_npc->ovl));
198 old_npc->listening = FALSE;
199 }
200
201 @@ -377,13 +385,18 @@
202 unsigned int bytes_left = count;
203
204 while (bytes_left)
205 {
206 DWORD bytes_read;
207 - ret = ReadFile(npc->pipe, buf, bytes_left, &bytes_read, NULL);
208 - if (!ret || !bytes_read)
209 + ret = ReadFile(npc->pipe, buf, bytes_left, &bytes_read, &npc->ovl[0]);
210 + if ((!ret || !bytes_read) && (GetLastError() != ERROR_IO_PENDING))
211 + break;
212 +
213 + ret = GetOverlappedResult(npc->pipe, &npc->ovl[0], &bytes_read, TRUE);
214 + if (!ret && (GetLastError() != ERROR_MORE_DATA))
215 break;
216 +
217 bytes_left -= bytes_read;
218 buf += bytes_read;
219 }
220 return ret ? count : -1;
221 }
222 @@ -397,13 +410,18 @@
223 unsigned int bytes_left = count;
224
225 while (bytes_left)
226 {
227 DWORD bytes_written;
228 - ret = WriteFile(npc->pipe, buf, bytes_left, &bytes_written, NULL);
229 - if (!ret || !bytes_written)
230 + ret = WriteFile(npc->pipe, buf, bytes_left, &bytes_written, &npc->ovl[1]);
231 + if ((!ret || !bytes_written) && (GetLastError() != ERROR_IO_PENDING))
232 + break;
233 +
234 + ret = GetOverlappedResult(npc->pipe, &npc->ovl[1], &bytes_written, TRUE);
235 + if (!ret && (GetLastError() != ERROR_MORE_DATA))
236 break;
237 +
238 bytes_left -= bytes_written;
239 buf += bytes_written;
240 }
241 return ret ? count : -1;
242 }
243 @@ -414,13 +432,17 @@
244 if (npc->pipe) {
245 FlushFileBuffers(npc->pipe);
246 CloseHandle(npc->pipe);
247 npc->pipe = 0;
248 }
249 - if (npc->ovl.hEvent) {
250 - CloseHandle(npc->ovl.hEvent);
251 - npc->ovl.hEvent = 0;
252 + if (npc->ovl[0].hEvent) {
253 + CloseHandle(npc->ovl[0].hEvent);
254 + npc->ovl[0].hEvent = 0;
255 + }
256 + if (npc->ovl[1].hEvent) {
257 + CloseHandle(npc->ovl[1].hEvent);
258 + npc->ovl[1].hEvent = 0;
259 }
260 return 0;
261 }
262
263 static void rpcrt4_conn_np_cancel_call(RpcConnection *Connection)
264 @@ -579,11 +601,11 @@
265 /* open and count connections */
266 *count = 1;
267 conn = CONTAINING_RECORD(protseq->conn, RpcConnection_np, common);
268 while (conn) {
269 rpcrt4_conn_listen_pipe(conn);
270 - if (conn->ovl.hEvent)
271 + if (conn->ovl[0].hEvent)
272 (*count)++;
273 conn = CONTAINING_RECORD(conn->common.Next, RpcConnection_np, common);
274 }
275
276 /* make array of connections */
277 @@ -600,11 +622,11 @@
278
279 objs[0] = npps->mgr_event;
280 *count = 1;
281 conn = CONTAINING_RECORD(protseq->conn, RpcConnection_np, common);
282 while (conn) {
283 - if ((objs[*count] = conn->ovl.hEvent))
284 + if ((objs[*count] = conn->ovl[0].hEvent))
285 (*count)++;
286 conn = CONTAINING_RECORD(conn->common.Next, RpcConnection_np, common);
287 }
288 LeaveCriticalSection(&protseq->cs);
289 return objs;
290 @@ -647,11 +669,11 @@
291 b_handle = objs[res - WAIT_OBJECT_0];
292 /* find which connection got a RPC */
293 EnterCriticalSection(&protseq->cs);
294 conn = CONTAINING_RECORD(protseq->conn, RpcConnection_np, common);
295 while (conn) {
296 - if (b_handle == conn->ovl.hEvent) break;
297 + if (b_handle == conn->ovl[0].hEvent) break;
298 conn = CONTAINING_RECORD(conn->common.Next, RpcConnection_np, common);
299 }
300 cconn = NULL;
301 if (conn)
302 RPCRT4_SpawnConnection(&cconn, &conn->common);