EldoS | Feel safer!

Software components for data protection, secure storage and transfer

DataAvailable but no callback

Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.
#13262
Posted: 05/11/2010 06:01:46
by neil young (Standard support level)
Joined: 11/05/2007
Posts: 96

Hi,
recently I reported a problem with a MaxBytes = 0 OnReceive callback on DataAvailable. Right now we fight a deadlock: We can bring the code into the situation, in which NO OnReceive is following to a DataAvailable. Is there a chance to come closer to this problem? We can't step through, we just see: We call you by DataAvailable and no OnReceive happens. Maybe something in conjunction with a closed socket, while data is there or so?

Can you imagine a situation, in which you don't OnReceive on DataAvailable?
#13263
Posted: 05/11/2010 06:06:26
by Eugene Mayevski (EldoS Corp.)

Of course, there's possibility that the service packet is received (i.e. no actual data payload). Also if there was an invalid packet, nothing will be received as well.


Sincerely yours
Eugene Mayevski
#13264
Posted: 05/11/2010 06:21:57
by neil young (Standard support level)
Joined: 11/05/2007
Posts: 96

Good to know.

For the rx part we are using the mechanics of your sample code. Is this code supposed to run well under this circumstances?

I'm referring to this:
Code
      private void AsyncReceiveCallback(IAsyncResult ar)
      {
         try
         {
            if (clientSocket == null)
            {
               return;
            }
            inBufferOffset += clientSocket.EndReceive(ar);
            while (inBufferOffset > 0)
               secureClient.DataAvailable();
            if (clientSocket != null)
            {
               clientSocket.BeginReceive(inBuffer, inBufferOffset,
                  inBuffer.Length - inBufferOffset, 0,
                  new AsyncCallback(AsyncReceiveCallback), clientSocket);            
            }
         }
         catch (Exception ex)
         {
            Reset();
            SetStatusText("Connection closed");
            AppendToMemo("Connection closed - " + ex.Message);
         }
      }

      private void ElSecureClientReceive(Object sender,
         ref byte[] buffer, int maxSize, out int written)
      {
         int len = Math.Min(maxSize, inBufferOffset);
         written = len;
         inBufferOffset -= len;

         for (int i = 0; i < len; i++)
            buffer[i] = inBuffer[i];

         for (int i = len; i < inBufferOffset + len; i++)
            inBuffer[i - len] = inBuffer[i];
      }



If inBufferOffset is not moved by ElSecureClientReceive (because the callback never occurs), how shall

Code
            while (inBufferOffset > 0)
               secureClient.DataAvailable();

come to an end?

Regards
#13269
Posted: 05/11/2010 08:37:39
by Eugene Mayevski (EldoS Corp.)

The sample code is designed to show how the component must behave in normal circumstances. This sample code was not designed to handle all kinds of problems that would happen. Its developer's job to check for invalid conditions - the sample code doesn't do this.


Sincerely yours
Eugene Mayevski
#13270
Posted: 05/11/2010 09:15:40
by neil young (Standard support level)
Joined: 11/05/2007
Posts: 96

Eugene,
I really appreciate your job, you know that, but here you are totally wrong. Sample is one thing, of course, we didn't take the sample "as is", but we took the _protocol_. And the protocol is: Call DataAvailable, as long as data is in the socket reception buffer, we will drain it...

Of course, we well never call you with an empty inputbuffer, but in this case the socket input buffer wasn't empty. What are we supposed to do?

Strange, but closed for me.
#13271
Posted: 05/11/2010 09:30:35
by Eugene Mayevski (EldoS Corp.)

Frankly speaking I don't see how your previous message is related to the last one.

Please create a testcase that reproduces the issue and post it to the helpdesk. Please post the complete source code with a project file.


Sincerely yours
Eugene Mayevski
#13273
Posted: 05/11/2010 09:32:54
by neil young (Standard support level)
Joined: 11/05/2007
Posts: 96

Please identify "previous" and "last" message and what you don't understand.
I'll be happy to elaborate.
Regards
#13274
Posted: 05/11/2010 09:35:05
by Eugene Mayevski (EldoS Corp.)

Just a comment: when you are asking about something, you have a complete situation / problem in mind. When it comes to the post, you put only the part (which you find most important) there, however the complete picture is not clear and in many cases we can just guess what's going on under the hood. The complete test case is the only thing that can give a complete picture relatively easy.


Sincerely yours
Eugene Mayevski
#13275
Posted: 05/11/2010 09:49:34
by neil young (Standard support level)
Joined: 11/05/2007
Posts: 96

Hmm. Give you that. I can't really provide the full picture, you would get lost. I just was looking for the reason, under which condx it is possible to have a DataAvailable call not answered by a OnReceive. You said: It is possible. I asked, how to overcome this situation. There is no indication, e.g. with a return of DataAvailable, that the OnReceive will never come. Probably it would be easier, if I would have a synchronous "upload" API function, which I could call, whenever I have a bunch of data received. The trick with "I have something, call me back" seems to be not stable enough.
#13279
Posted: 05/11/2010 13:41:58
by neil young (Standard support level)
Joined: 11/05/2007
Posts: 96

From SecureBlackbox.chm:

ElSecureServer.DataAvailable

Use this method to tell ElSecureServer that there are data in the socket. ElSecureServer then fires OnReceive event to read the block of data.
If the application uses one of wait methods to check availability of the data in the socket (select() or WaitFor* API functions), right place to call DataAvailable is right after the call to those wait methods.

I don't read something about "OnReceive is _not_ fired under the following conditions".

Thanks
Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.

Reply

Statistics

Topic viewed 2232 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!