Hans Leidekker : webservices: Keep track of service proxy state.
Alexandre Julliard
julliard at winehq.org
Wed Apr 5 16:17:07 CDT 2017
Module: wine
Branch: master
Commit: e1e36be4b8880795a281e214029aa5cdd1d0d5bd
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e1e36be4b8880795a281e214029aa5cdd1d0d5bd
Author: Hans Leidekker <hans at codeweavers.com>
Date: Wed Apr 5 11:40:23 2017 +0200
webservices: Keep track of service proxy state.
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/webservices/proxy.c | 30 +++++++++++++++++++++---------
dlls/webservices/tests/proxy.c | 36 ++++++++++++++++++++++--------------
2 files changed, 43 insertions(+), 23 deletions(-)
diff --git a/dlls/webservices/proxy.c b/dlls/webservices/proxy.c
index 63cf559..ac8387a 100644
--- a/dlls/webservices/proxy.c
+++ b/dlls/webservices/proxy.c
@@ -43,11 +43,12 @@ static const struct prop_desc proxy_props[] =
struct proxy
{
- ULONG magic;
- CRITICAL_SECTION cs;
- WS_CHANNEL *channel;
- ULONG prop_count;
- struct prop prop[sizeof(proxy_props)/sizeof(proxy_props[0])];
+ ULONG magic;
+ CRITICAL_SECTION cs;
+ WS_SERVICE_PROXY_STATE state;
+ WS_CHANNEL *channel;
+ ULONG prop_count;
+ struct prop prop[sizeof(proxy_props)/sizeof(proxy_props[0])];
};
#define PROXY_MAGIC (('P' << 24) | ('R' << 16) | ('O' << 8) | 'X')
@@ -222,7 +223,7 @@ HRESULT WINAPI WsGetServiceProxyProperty( WS_SERVICE_PROXY *handle, WS_PROXY_PRO
void *buf, ULONG size, WS_ERROR *error )
{
struct proxy *proxy = (struct proxy *)handle;
- HRESULT hr;
+ HRESULT hr = S_OK;
TRACE( "%p %u %p %u %p\n", handle, id, buf, size, error );
if (error) FIXME( "ignoring error parameter\n" );
@@ -237,7 +238,16 @@ HRESULT WINAPI WsGetServiceProxyProperty( WS_SERVICE_PROXY *handle, WS_PROXY_PRO
return E_INVALIDARG;
}
- hr = prop_get( proxy->prop, proxy->prop_count, id, buf, size );
+ switch (id)
+ {
+ case WS_PROXY_PROPERTY_STATE:
+ if (!buf || size != sizeof(proxy->state)) hr = E_INVALIDARG;
+ else *(WS_SERVICE_PROXY_STATE *)buf = proxy->state;
+ break;
+
+ default:
+ hr = prop_get( proxy->prop, proxy->prop_count, id, buf, size );
+ }
LeaveCriticalSection( &proxy->cs );
return hr;
@@ -266,7 +276,8 @@ HRESULT WINAPI WsOpenServiceProxy( WS_SERVICE_PROXY *handle, const WS_ENDPOINT_A
return E_INVALIDARG;
}
- hr = WsOpenChannel( proxy->channel, endpoint, NULL, NULL );
+ if ((hr = WsOpenChannel( proxy->channel, endpoint, NULL, NULL )) == S_OK)
+ proxy->state = WS_SERVICE_PROXY_STATE_OPEN;
LeaveCriticalSection( &proxy->cs );
return hr;
@@ -294,7 +305,8 @@ HRESULT WINAPI WsCloseServiceProxy( WS_SERVICE_PROXY *handle, const WS_ASYNC_CON
return E_INVALIDARG;
}
- hr = WsCloseChannel( proxy->channel, NULL, NULL );
+ if ((hr = WsCloseChannel( proxy->channel, NULL, NULL )) == S_OK)
+ proxy->state = WS_SERVICE_PROXY_STATE_CLOSED;
LeaveCriticalSection( &proxy->cs );
return hr;
diff --git a/dlls/webservices/tests/proxy.c b/dlls/webservices/tests/proxy.c
index 79f6444..9351d2d 100644
--- a/dlls/webservices/tests/proxy.c
+++ b/dlls/webservices/tests/proxy.c
@@ -95,7 +95,7 @@ static void test_WsCreateServiceProxy(void)
HRESULT hr;
WS_SERVICE_PROXY *proxy;
WS_SERVICE_PROXY_STATE state;
- ULONG size, value;
+ ULONG value;
hr = WsCreateServiceProxy( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, NULL,
0, NULL, 0, NULL, NULL );
@@ -109,13 +109,11 @@ static void test_WsCreateServiceProxy(void)
/* write-only property */
value = 0xdeadbeef;
- size = sizeof(value);
- hr = WsGetServiceProxyProperty( proxy, WS_PROXY_PROPERTY_CALL_TIMEOUT, &value, size, NULL );
+ hr = WsGetServiceProxyProperty( proxy, WS_PROXY_PROPERTY_CALL_TIMEOUT, &value, sizeof(value), NULL );
ok( hr == E_INVALIDARG, "got %08x\n", hr );
state = 0xdeadbeef;
- size = sizeof(state);
- hr = WsGetServiceProxyProperty( proxy, WS_PROXY_PROPERTY_STATE, &state, size, NULL );
+ hr = WsGetServiceProxyProperty( proxy, WS_PROXY_PROPERTY_STATE, &state, sizeof(state), NULL );
ok( hr == S_OK, "got %08x\n", hr );
ok( state == WS_SERVICE_PROXY_STATE_CREATED, "got %u\n", state );
@@ -151,6 +149,7 @@ static void test_WsOpenServiceProxy(void)
WCHAR url[] = {'h','t','t','p',':','/','/','l','o','c','a','l','h','o','s','t','/'};
HRESULT hr;
WS_SERVICE_PROXY *proxy;
+ WS_SERVICE_PROXY_STATE state;
WS_HTTP_POLICY_DESCRIPTION policy;
WS_ENDPOINT_ADDRESS addr;
@@ -159,17 +158,30 @@ static void test_WsOpenServiceProxy(void)
NULL, 0, &policy, sizeof(policy), &proxy, NULL );
ok( hr == S_OK, "got %08x\n", hr );
+ state = 0xdeadbeef;
+ hr = WsGetServiceProxyProperty( proxy, WS_PROXY_PROPERTY_STATE, &state, sizeof(state), NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+ ok( state == WS_SERVICE_PROXY_STATE_CREATED, "got %u\n", state );
+
+ memset( &addr, 0, sizeof(addr) );
addr.url.length = sizeof(url)/sizeof(url[0]);
addr.url.chars = url;
- addr.headers = NULL;
- addr.extensions = NULL;
- addr.identity = NULL;
hr = WsOpenServiceProxy( proxy, &addr, NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
+ state = 0xdeadbeef;
+ hr = WsGetServiceProxyProperty( proxy, WS_PROXY_PROPERTY_STATE, &state, sizeof(state), NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+ ok( state == WS_SERVICE_PROXY_STATE_OPEN, "got %u\n", state );
+
hr = WsCloseServiceProxy( proxy , NULL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
+ state = 0xdeadbeef;
+ hr = WsGetServiceProxyProperty( proxy, WS_PROXY_PROPERTY_STATE, &state, sizeof(state), NULL );
+ ok( hr == S_OK, "got %08x\n", hr );
+ ok( state == WS_SERVICE_PROXY_STATE_CLOSED, "got %u\n", state );
+
WsFreeServiceProxy( proxy );
}
@@ -197,11 +209,9 @@ static HRESULT create_channel( int port, WS_CHANNEL **ret )
hr = WsCreateChannel( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, prop, 2, NULL, &channel, NULL );
if (hr != S_OK) return hr;
+ memset( &addr, 0, sizeof(addr) );
addr.url.length = wsprintfW( buf, fmt, port );
addr.url.chars = buf;
- addr.headers = NULL;
- addr.extensions = NULL;
- addr.identity = NULL;
hr = WsOpenChannel( channel, &addr, NULL, NULL );
if (hr == S_OK) *ret = channel;
else WsFreeChannel( channel );
@@ -335,11 +345,9 @@ static HRESULT create_proxy( int port, WS_SERVICE_PROXY **ret )
0, prop, sizeof(prop)/sizeof(prop[0]), &proxy, NULL );
if (hr != S_OK) return hr;
+ memset( &addr, 0, sizeof(addr) );
addr.url.length = wsprintfW( url, fmt, port );
addr.url.chars = url;
- addr.headers = NULL;
- addr.extensions = NULL;
- addr.identity = NULL;
hr = WsOpenServiceProxy( proxy, &addr, NULL, NULL );
if (hr == S_OK) *ret = proxy;
else WsFreeServiceProxy( proxy );
More information about the wine-cvs
mailing list