[2/7] webservices: Implement WsResetChannel.

Hans Leidekker hans at codeweavers.com
Wed Apr 5 04:40:22 CDT 2017


Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
 dlls/webservices/channel.c        | 65 ++++++++++++++++++++++++++++++---------
 dlls/webservices/tests/channel.c  | 60 ++++++++++++++++++++++++++++++++++++
 dlls/webservices/webservices.spec |  2 +-
 3 files changed, 111 insertions(+), 16 deletions(-)

diff --git a/dlls/webservices/channel.c b/dlls/webservices/channel.c
index d44fcc0..d82aa67 100644
--- a/dlls/webservices/channel.c
+++ b/dlls/webservices/channel.c
@@ -121,14 +121,27 @@ static struct channel *alloc_channel(void)
     return ret;
 }
 
-static void free_channel( struct channel *channel )
+static void reset_channel( struct channel *channel )
 {
-    WsFreeWriter( channel->writer );
-    WsFreeReader( channel->reader );
+    channel->state           = WS_CHANNEL_STATE_CREATED;
+    heap_free( channel->addr.url.chars );
+    channel->addr.url.chars  = NULL;
+    channel->addr.url.length = 0;
+
     WinHttpCloseHandle( channel->http_request );
+    channel->http_request    = NULL;
     WinHttpCloseHandle( channel->http_connect );
+    channel->http_connect    = NULL;
     WinHttpCloseHandle( channel->http_session );
-    heap_free( channel->addr.url.chars );
+    channel->http_session    = NULL;
+}
+
+static void free_channel( struct channel *channel )
+{
+    reset_channel( channel );
+
+    WsFreeWriter( channel->writer );
+    WsFreeReader( channel->reader );
 
     channel->cs.DebugInfo->Spare[0] = 0;
     DeleteCriticalSection( &channel->cs );
@@ -226,6 +239,38 @@ void WINAPI WsFreeChannel( WS_CHANNEL *handle )
 }
 
 /**************************************************************************
+ *          WsResetChannel		[webservices.@]
+ */
+HRESULT WINAPI WsResetChannel( WS_CHANNEL *handle, WS_ERROR *error )
+{
+    struct channel *channel = (struct channel *)handle;
+
+    TRACE( "%p %p\n", handle, error );
+    if (error) FIXME( "ignoring error parameter\n" );
+
+    if (!channel) return E_INVALIDARG;
+
+    EnterCriticalSection( &channel->cs );
+
+    if (channel->magic != CHANNEL_MAGIC)
+    {
+        LeaveCriticalSection( &channel->cs );
+        return E_INVALIDARG;
+    }
+
+    if (channel->state != WS_CHANNEL_STATE_CREATED && channel->state != WS_CHANNEL_STATE_CLOSED)
+    {
+        LeaveCriticalSection( &channel->cs );
+        return WS_E_INVALID_OPERATION;
+    }
+
+    reset_channel( channel );
+
+    LeaveCriticalSection( &channel->cs );
+    return S_OK;
+}
+
+/**************************************************************************
  *          WsGetChannelProperty		[webservices.@]
  */
 HRESULT WINAPI WsGetChannelProperty( WS_CHANNEL *handle, WS_CHANNEL_PROPERTY_ID id, void *buf,
@@ -343,17 +388,7 @@ HRESULT WINAPI WsOpenChannel( WS_CHANNEL *handle, const WS_ENDPOINT_ADDRESS *end
 
 static HRESULT close_channel( struct channel *channel )
 {
-    WinHttpCloseHandle( channel->http_request );
-    channel->http_request = NULL;
-    WinHttpCloseHandle( channel->http_connect );
-    channel->http_connect = NULL;
-    WinHttpCloseHandle( channel->http_session );
-    channel->http_session = NULL;
-
-    heap_free( channel->addr.url.chars );
-    channel->addr.url.chars  = NULL;
-    channel->addr.url.length = 0;
-
+    reset_channel( channel );
     channel->state = WS_CHANNEL_STATE_CLOSED;
     return S_OK;
 }
diff --git a/dlls/webservices/tests/channel.c b/dlls/webservices/tests/channel.c
index f053c15..74cef3b 100644
--- a/dlls/webservices/tests/channel.c
+++ b/dlls/webservices/tests/channel.c
@@ -103,8 +103,68 @@ static void test_WsOpenChannel(void)
     WsFreeChannel( channel );
 }
 
+static void test_WsResetChannel(void)
+{
+    WCHAR url[] = {'h','t','t','p',':','/','/','l','o','c','a','l','h','o','s','t'};
+    HRESULT hr;
+    WS_CHANNEL *channel;
+    WS_CHANNEL_STATE state;
+    WS_CHANNEL_TYPE type;
+    WS_ENDPOINT_ADDRESS addr;
+    ULONG size, timeout;
+
+    hr = WsCreateChannel( WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING, NULL, 0, NULL, &channel, NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+
+    hr = WsResetChannel( channel, NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+
+    timeout = 5000;
+    size = sizeof(timeout);
+    hr = WsSetChannelProperty( channel, WS_CHANNEL_PROPERTY_RESOLVE_TIMEOUT, &timeout, size, NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+
+    addr.url.length = sizeof(url)/sizeof(url[0]);
+    addr.url.chars  = url;
+    addr.headers    = NULL;
+    addr.extensions = NULL;
+    addr.identity   = NULL;
+    hr = WsOpenChannel( channel, &addr, NULL, NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+
+    hr = WsResetChannel( channel, NULL );
+    ok( hr == WS_E_INVALID_OPERATION, "got %08x\n", hr );
+
+    hr = WsCloseChannel( channel, NULL, NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+
+    hr = WsResetChannel( channel, NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+
+    state = 0xdeadbeef;
+    size = sizeof(state);
+    hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_STATE, &state, size, NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+    ok( state == WS_CHANNEL_STATE_CREATED, "got %u\n", state );
+
+    type = 0xdeadbeef;
+    size = sizeof(type);
+    hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_CHANNEL_TYPE, &type, size, NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+    ok( type == WS_CHANNEL_TYPE_REQUEST, "got %u\n", type );
+
+    timeout = 0xdeadbeef;
+    size = sizeof(timeout);
+    hr = WsGetChannelProperty( channel, WS_CHANNEL_PROPERTY_RESOLVE_TIMEOUT, &timeout, size, NULL );
+    ok( hr == S_OK, "got %08x\n", hr );
+    ok( timeout == 5000, "got %u\n", timeout );
+
+    WsFreeChannel( channel );
+}
+
 START_TEST(channel)
 {
     test_WsCreateChannel();
     test_WsOpenChannel();
+    test_WsResetChannel();
 }
diff --git a/dlls/webservices/webservices.spec b/dlls/webservices/webservices.spec
index fd4a831..0a3057d 100644
--- a/dlls/webservices/webservices.spec
+++ b/dlls/webservices/webservices.spec
@@ -133,7 +133,7 @@
 @ stub WsRemoveNode
 @ stub WsRequestReply
 @ stub WsRequestSecurityToken
-@ stub WsResetChannel
+@ stdcall WsResetChannel(ptr ptr)
 @ stdcall WsResetError(ptr)
 @ stdcall WsResetHeap(ptr ptr)
 @ stub WsResetListener
-- 
2.1.4




More information about the wine-patches mailing list