You are correct, it was timeouts.  My pthread application was overloading
the SSL server and it wasn't returning within the timeout, so that is why I
kept receiving "Error with sockets".   I have an additional question related
to SSL_write on a non-blocking IO.  What is the proper method to check and
make sure that the SSL write was performed properly?  I've seen a few errors
in my SSL server log that look like this that have actually been crashing my
SSL daemon:

There are no problems with service_data->servicesend, this is always a
simple HTTP HEAD request, I've already checked this.



[Mon May 13 16:10:40 2002] [error] [client xxx.xx.x.xx] Invalid method in
request ^A^C^A
[Mon May 13 16:11:58 2002] [error] [client xxx.xx.x.xx] Invalid method in
request ^A^C^A
[Mon May 13 16:13:24 2002] [error] [client xxx.xx.x.xx] Invalid method in
request ^A^C^A
[Mon May 13 16:18:26 2002] [error] SSL_accept failed

Below is the code:

ssl = SSL_new(ssl_ctx);
SSL_set_fd(ssl, sockfd);
if(SSL_connect(ssl) == 0) {
        close(sockfd);
        SSL_free(ssl);

return(2);
}
SSL_write(ssl, service_data->servicesend,
strlen(service_data->servicesend));

numbytes = 1;
FD_ZERO(&rset);
FD_SET(sockfd, &rset);
while(numbytes != 0)

        // run select as below and cycle until we get what we want.

Best Regards,

Nicholas Gaugler
CommuniTech.Net Development

- Kansas City 2001 Small Business of the Year
- A HostIndex.com Top 15 Web Hosting Company
- Member of the BBB On-Line Reliability Program
- Member of the Web Host Guild & VeriHost

-----Original Message-----
From: Nick Gaugler [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 09, 2002 5:53 PM
To: [EMAIL PROTECTED]
Subject: Basic OpenSSL Client w/Pthreads


I've come up with the following BASIC OpenSSL client from the cli.cpp
example and I am trying to turn it into a multi threaded application with
pthreads.   Each thread will open a brand new connection, it will not read
off of the same connection, so it should not be any different.  I've added
the th-lock.c library into it before the threads are created and after they
are destroyed, from the limited documentation I've found, that should cover
everything.  The only thing I have changed with the basic cli.cpp is that I
am using non-blocking IO through SELECT/FD_ISSET.  By doing this I have also
added support for SSL_ERROR_WANT_READ, so that shouldn't be the issue.  The
problem I am seeing is within the select/FD_ISSET.  My FD_ISSET is failing.
(Enclosed below)


c = select(sockfd+900, &readfds, NULL, NULL, &tv);
if (c < 0) {
        perror("SELECT");
        fprintf(stderr, "Error with the select\n");
        break;
}

if (!FD_ISSET(sockfd, &readfds)) {
        perror("Error");
        fprintf(stderr,"Error with socket\n");
        break;
}

Should I not be using this with OpenSSL and/or pthreads?  Are there any
known issues or can anyone shed some light onto the subject for me?

Thanks in advance,

Nick
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to