views:

39

answers:

0

Hello,

I have built a custom binding for being able to receive HTTP messages from an additional source. However, it is not bug-free yet.

I've observed that my service pushes CPU usage up to 100 % as soon as the first request was processed and the service getting slower and slower the more requests came in. The reason for this behavior could be seen after inserting logging commands into every single function of the binding.

Until before the first request gets in, everything works fine:

ChannelListener: OnBeginAcceptChannel
ChannelListener: OnAcceptChannel

Then, processing of the first message is done:

Channel: static constructor
Channel: constructor
ChannelListener: OnEndAcceptChannel (completes)
ChannelListener: Uri get
ChannelListener: OnBeginAcceptChannel
ChannelListener: OnAcceptChannel
Channel: OnOpen
Channel: BeginTryReceiveRequest
Channel: TryReceiveRequest
Channel: WaitForRequest
Channel: ReceiveRequest
Context: constructor
Channel: EndTryReceiveRequest (completes)
Context: RequestMessage get
`Channel: BeginTryReceiveRequest`
Context: Reply noTimeout
Context: Reply
Context: Close noTimeout
`Channel: TryReceiveRequest`
`Channel: WaitForRequest`
`Channel: ReceiveRequest (hangs)`
`Channel: EndTryReceiveRequest (doesn't complete since receive hangs)`
`Channel: BeginTryReceiveRequest`
`and so on...`

The channel implements the IReplyChannel interface, so it should only be possible to get a request, reply it and then close the channel. Instead of just closing the channel, the ServiceModel keeps spamming TryReceiveRequest on an already used channel regardless of the channel already being used in the past.

Is there some way to fix this properly? Why doesn't the ServiceModel close the channel after closing the reply context although it's useless to keep the channel open after it is consumed?