Hi, I met a big problem when I use multi-threading of GSOAP with OpenSSL , I used SoapUI load test to test the multi-threading, in case of 5-10 multi-threads, it worked well . But if I increased the multi-threading numbers over 50 or even 100, I found there are lots of error message shown up,
SOAP 1.1 fault: SOAP-ENV:Server [no subcode] "Error observed by underlying BIO: Bad file descriptor" Detail: SSL_accept() failed in soap_ssl_accept() And on SoapUI side, the load test has been blocked. So, I wonder why there are lots of SSL_accept error return? Anybody can help me ? Thank you so much! Best regards Kevin the multi-threading is like following code ( please refer to http://www.cs.fsu.edu/~engelen/soapdoc2.html ) int main() { int m, s; pthread_t tid; struct soap soap, *tsoap; soap_ssl_init(); /* init OpenSSL (just once) */ if (CRYPTO_thread_setup()) // OpenSSL { fprintf(stderr, "Cannot setup thread mutex\n"); exit(1); } soap_init(&soap); if (soap_ssl_server_context(&soap, SOAP_SSL_DEFAULT, "server.pem", /* keyfile: required when server must authenticate to clients (see SSL docs on how to obtain this file) */ "password", /* password to read the key file (not used with GNUTLS) */ "cacert.pem", /* optional cacert file to store trusted certificates */ NULL, /* optional capath to directory with trusted certificates */ "dh512.pem", /* DH file name or DH key len bits (minimum is 512, e.g. "512") to generate DH param, if NULL use RSA */ NULL, /* if randfile!=NULL: use a file with random data to seed randomness */ NULL /* optional server identification to enable SSL session cache (must be a unique name) */ )) { soap_print_fault(&soap, stderr); exit(1); } m = soap_bind(&soap, NULL, 18000, 100); // use port 18000 if (m < 0) { soap_print_fault(&soap, stderr); exit(1); } fprintf(stderr, "Socket connection successful: master socket = %d\n", m); for (;;) { s = soap_accept(&soap); fprintf(stderr, "Socket connection successful: slave socket = %d\n", s); if (s < 0) { soap_print_fault(&soap, stderr); break; } tsoap = soap_copy(&soap); /* should call soap_ssl_accept on a copy */ if (!tsoap) break; pthread_create(&tid, NULL, &process_request, (void*)tsoap); } soap_done(&soap); /* deallocates SSL context */ CRYPTO_thread_cleanup(); // OpenSSL return 0; } void *process_request(void *soap) { pthread_detach(pthread_self()); if (soap_ssl_accept((struct soap*)soap)) soap_print_fault(tsoap, stderr); else soap_serve((struct soap*)soap); soap_destroy((struct soap*)soap); soap_end((struct soap*)soap); soap_free((struct soap*)soap); // done and free context return NULL; }
