From cbbf08a7e219c84eafef2d574706360e998c3254 Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Wed, 26 Jan 2005 20:53:06 +0000 Subject: [PATCH] - Use InterlockedIncrement for the ipid counter instead of a critical section (suggested by Mike Hearn). - Remove a line added by a bad merge. - Implement RemUnkStub_Disconnect. - Remove all of the RPC disconnect code. --- dlls/ole32/compobj.c | 2 +- dlls/ole32/compobj_private.h | 2 +- dlls/ole32/marshal.c | 1 - dlls/ole32/oleproxy.c | 2 ++ dlls/ole32/rpc.c | 68 +------------------------------------------- dlls/ole32/stubmanager.c | 4 +-- 6 files changed, 6 insertions(+), 73 deletions(-) diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index 575f04fd230..afa73db3ae6 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -246,7 +246,7 @@ APARTMENT* COM_CreateApartment(DWORD model) list_init(&apt->proxies); list_init(&apt->stubmgrs); - apt->ipidc = 1; + apt->ipidc = 0; apt->refs = 1; apt->remunk_exported = FALSE; apt->oidc = 1; diff --git a/dlls/ole32/compobj_private.h b/dlls/ole32/compobj_private.h index ee9ed9a3058..6b7686bd791 100644 --- a/dlls/ole32/compobj_private.h +++ b/dlls/ole32/compobj_private.h @@ -123,7 +123,7 @@ struct apartment DWORD tid; /* thread id (RO) */ HANDLE thread; /* thread handle (RO) */ OXID oxid; /* object exporter ID (RO) */ - DWORD ipidc; /* interface pointer ID counter, starts at 1 (CS cs) */ + DWORD ipidc; /* interface pointer ID counter, starts at 1 (LOCK) */ HWND win; /* message window (RO) */ CRITICAL_SECTION cs; /* thread safety */ LPMESSAGEFILTER filter; /* message filter (CS cs) */ diff --git a/dlls/ole32/marshal.c b/dlls/ole32/marshal.c index fa0d7e72643..ca050700479 100644 --- a/dlls/ole32/marshal.c +++ b/dlls/ole32/marshal.c @@ -349,7 +349,6 @@ static HRESULT proxy_manager_construct( This->oid = oid; This->refs = 1; - This->sorflags = sorflags; /* the DCOM draft specification states that the SORF_NOPING flag is * proxy manager specific, not ifproxy specific, so this implies that we diff --git a/dlls/ole32/oleproxy.c b/dlls/ole32/oleproxy.c index eeb051c2cec..6c8ecf97198 100644 --- a/dlls/ole32/oleproxy.c +++ b/dlls/ole32/oleproxy.c @@ -509,6 +509,8 @@ static void WINAPI RemUnkStub_Disconnect(LPRPCSTUBBUFFER iface) { RemUnkStub *This = (RemUnkStub *)iface; TRACE("(%p)->Disconnect()\n",This); + IUnknown_Release(This->iface); + This->iface = NULL; } static HRESULT WINAPI RemUnkStub_Invoke(LPRPCSTUBBUFFER iface, diff --git a/dlls/ole32/rpc.c b/dlls/ole32/rpc.c index bee0d189ce5..f440c6e5201 100644 --- a/dlls/ole32/rpc.c +++ b/dlls/ole32/rpc.c @@ -54,7 +54,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(ole); #define REQTYPE_REQUEST 0 #define REQTYPE_RESPONSE 1 -#define REQTYPE_DISCONNECT 2 struct request_header { @@ -71,13 +70,6 @@ struct response_header DWORD retval; }; -/* used when shutting down a pipe, e.g. at the end of a process */ -struct disconnect_header -{ - DWORD reqid; - wine_marshal_id mid; /* mid of stub to delete */ -}; - #define REQSTATE_START 0 #define REQSTATE_REQ_QUEUED 1 @@ -291,34 +283,11 @@ static ULONG WINAPI PipeBuf_Release(LPRPCCHANNELBUFFER iface) { PipeBuf *This = (PipeBuf *)iface; ULONG ref; -#if 0 - struct disconnect_header header; - HANDLE pipe; - DWORD reqtype = REQTYPE_DISCONNECT; - DWORD magic; -#endif ref = InterlockedDecrement(&This->ref); if (ref) return ref; -#if 0 /* no longer needed now we've got IRemUnknown ref counting */ - memcpy(&header.mid, &This->mid, sizeof(wine_marshal_id)); - - pipe = PIPE_FindByMID(&This->mid); - - write_pipe(pipe, &reqtype, sizeof(reqtype)); - write_pipe(pipe, &header, sizeof(struct disconnect_header)); - - TRACE("written disconnect packet\n"); - - /* prevent a disconnect race with the other side: this isn't - * necessary for real dcom but the test suite needs it */ - - read_pipe(pipe, &magic, sizeof(magic)); - if (magic != 0xcafebabe) ERR("bad disconnection magic: expecting 0xcafebabe but got 0x%lx\n", magic); -#endif - HeapFree(GetProcessHeap(),0,This); return 0; } @@ -771,42 +740,7 @@ COM_RpcReceive(struct pipe *xpipe) { EnterCriticalSection(&(xpipe->crit)); /* only received by servers */ - if (reqtype == REQTYPE_DISCONNECT) { - struct disconnect_header header; - struct stub_manager *stubmgr; - DWORD magic = 0xcafebabe; - APARTMENT *apt; - - hres = read_pipe(xhPipe, &header, sizeof(header)); - if (hres) { - ERR("could not read disconnect header\n"); - goto disconnect_end; - } - - TRACE("read disconnect header\n"); - - if (!(apt = COM_ApartmentFromOXID(header.mid.oxid, TRUE))) - { - ERR("Could not map OXID %s to apartment object in disconnect\n", wine_dbgstr_longlong(header.mid.oxid)); - goto disconnect_end; - } - - if (!(stubmgr = get_stub_manager(apt, header.mid.oid))) - { - ERR("could not locate stub to disconnect, mid.oid=%s\n", wine_dbgstr_longlong(header.mid.oid)); - COM_ApartmentRelease(apt); - goto disconnect_end; - } - - stub_manager_ext_release(stubmgr, 1); - - stub_manager_int_release(stubmgr); - COM_ApartmentRelease(apt); - -disconnect_end: - write_pipe(xhPipe, &magic, sizeof(magic)); - goto end; - } else if (reqtype == REQTYPE_REQUEST) { + if (reqtype == REQTYPE_REQUEST) { struct rpc *xreq; RPC_GetRequest(&xreq); diff --git a/dlls/ole32/stubmanager.c b/dlls/ole32/stubmanager.c index 47df17414fc..c9e754bee75 100644 --- a/dlls/ole32/stubmanager.c +++ b/dlls/ole32/stubmanager.c @@ -334,9 +334,7 @@ static inline HRESULT generate_ipid(struct stub_manager *m, IPID *ipid) return hr; } - EnterCriticalSection(&m->apt->cs); - ipid->Data1 = m->apt->ipidc++; - LeaveCriticalSection(&m->apt->cs); + ipid->Data1 = InterlockedIncrement(&m->apt->ipidc); ipid->Data2 = (USHORT)m->apt->tid; ipid->Data3 = (USHORT)GetCurrentProcessId(); return S_OK; -- 2.11.4.GIT