Ian C. Fette wrote:
> Dr. Stephen Henson wrote:
>> On Wed, Jan 31, 2007, Ian C. Fette wrote:
>>
>>> I also tried implementing your reply. Before calling SSL_read() etc I'm
>>> now calling ERR_clear_error(). Unfortunately, I still seem to be getting
>>> cases where I see SSL_ERROR_SYSCALL and errno is set to EWOULDBLOCK. Do
>>> you have any other ideas as to what the problem might be? (Or is this
>>> just behavior that I have to live with?)
>>>
>> Try ERR_print_errors_fp(stderr) when you get that condition to see if the
>> error queue indicates EWOULDBLOCK or some other error.
>>
>> If you application is multi threaded make sure the process ID callback is set
>> to something sensible if the default (getpid on Unix) isn't appropriate.
>> Otherwise the error queue could get confused.
>>
>> Steve.
> 
> I have added the following:
>                                                       fprintf(stderr,"Got 
> SYSCALL/WOULDBLOCK\n");
> ERR_print_errors_fp(stderr);
> 
> Unfortunately, I see on the screen:
> Got SYSCALL/WOULDBLOCK
> Got SYSCALL/WOULDBLOCK
> Got SYSCALL/WOULDBLOCK
> 
> I.e. ER_print_errors_fp is not printing anything.
> 
> Sigh.
> 
> As for the process id callback, I have it set to pthread_self, as I
> believe this was recommended in the documentation.

One other thought crosses my mind, and I'm not sure if this is
problematic or not, but it's worth asking.

I create all of my SSL* objects in my main thread (on the heap),
establish the connection, make sure the handshake completed OK, and
*then* hand off the connected object to a freshly created worker thread.

The SSL_ERROR_SYSCALL does not appear on the first read - it's actually
a few opeartions in... but is it safe to hand off the SSL* pointer from
one thread to another? (There is never any concurrent access - once it's
 handed off to a worker thread, the main thread never touches that
object again...) I'm just wondering if when I call SSL_new(ctx) in
thread A, do some stuff, and then pass the SSL* off to thread B, if
somehow thread B is lacking a proper error stack or anything of the sort
(or is perhaps looking at an error stack somehow still related to thread A).

Multithreading just brings such joy to my life ;-)
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [email protected]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to