Signed-off-by: Connor McAdams cmcadams@codeweavers.com --- dlls/webservices/channel.c | 5 +++++ dlls/webservices/tests/channel.c | 28 +++++++++++++++++++++------- 2 files changed, 26 insertions(+), 7 deletions(-)
diff --git a/dlls/webservices/channel.c b/dlls/webservices/channel.c index 1148744346c..cfb6566921d 100644 --- a/dlls/webservices/channel.c +++ b/dlls/webservices/channel.c @@ -2415,6 +2415,11 @@ HRESULT WINAPI WsReceiveMessage( WS_CHANNEL *handle, WS_MESSAGE *msg, const WS_M LeaveCriticalSection( &channel->cs ); return E_INVALIDARG; } + if (channel->state != WS_CHANNEL_STATE_OPEN) + { + LeaveCriticalSection( &channel->cs ); + return WS_E_INVALID_OPERATION; + }
if (!ctx) async_init( &async, &ctx_local ); hr = queue_receive_message( channel, msg, desc, count, option, read_option, heap, value, size, index, diff --git a/dlls/webservices/tests/channel.c b/dlls/webservices/tests/channel.c index e3cadc7d344..f70eafaecc8 100644 --- a/dlls/webservices/tests/channel.c +++ b/dlls/webservices/tests/channel.c @@ -626,6 +626,7 @@ static void server_duplex_session( WS_CHANNEL *channel ) static void client_duplex_session( const struct listener_info *info ) { WS_XML_STRING action = {6, (BYTE *)"action"}, localname = {9, (BYTE *)"localname"}, ns = {2, (BYTE *)"ns"}; + const WS_MESSAGE_DESCRIPTION *descs[1]; WS_ELEMENT_DESCRIPTION desc_body; WS_MESSAGE_DESCRIPTION desc; WS_ENDPOINT_ADDRESS addr; @@ -645,6 +646,26 @@ static void client_duplex_session( const struct listener_info *info ) hr = WsShutdownSessionChannel( channel, NULL, NULL ); ok( hr == WS_E_INVALID_OPERATION, "got %#lx\n", hr );
+ desc_body.elementLocalName = &localname; + desc_body.elementNs = &ns; + desc_body.type = WS_INT32_TYPE; + desc_body.typeDescription = NULL; + desc.action = &action; + desc.bodyElementDescription = &desc_body; + descs[0] = &desc; + + hr = WsCreateMessageForChannel( channel, NULL, 0, &msg, NULL ); + ok( hr == S_OK, "got %#lx\n", hr ); + + hr = WsReceiveMessage( channel, msg, descs, 1, WS_RECEIVE_REQUIRED_MESSAGE, WS_READ_REQUIRED_VALUE, + NULL, &val, sizeof(val), NULL, NULL, NULL ); + ok( hr == WS_E_INVALID_OPERATION, "got %#lx\n", hr); + + hr = WsSendMessage( channel, msg, &desc, WS_WRITE_REQUIRED_VALUE, &val, sizeof(val), NULL, NULL ); + ok( hr == WS_E_INVALID_OPERATION, "got %#lx\n", hr ); + + WsFreeMessage( msg ); + memset( &addr, 0, sizeof(addr) ); addr.url.length = wsprintfW( buf, L"net.tcp://localhost:%u", info->port ); addr.url.chars = buf; @@ -654,13 +675,6 @@ static void client_duplex_session( const struct listener_info *info ) hr = WsCreateMessageForChannel( channel, NULL, 0, &msg, NULL ); ok( hr == S_OK, "got %#lx\n", hr );
- desc_body.elementLocalName = &localname; - desc_body.elementNs = &ns; - desc_body.type = WS_INT32_TYPE; - desc_body.typeDescription = NULL; - desc.action = &action; - desc.bodyElementDescription = &desc_body; - hr = WsSendMessage( channel, msg, &desc, WS_WRITE_REQUIRED_VALUE, &val, sizeof(val), NULL, NULL ); ok( hr == S_OK, "got %#lx\n", hr );