Commits

Roger Light committed 0d3e6e3

Don't always attempt to call read() for SSL clients, irrespective of whether
they were ready to read or not. Reduces syscalls significantly.

Thanks to Karl Palsson.

  • Participants
  • Parent commits 7e68235
  • Branches 1.3

Comments (0)

Files changed (5)

File ChangeLog.txt

   easier parsing.
 - Change "$SYS/broker/heap/maximum size" to "$SYS/broker/heap/maximum" for
   easier parsing.
+- Don't always attempt to call read() for SSL clients, irrespective of whether
+  they were ready to read or not. Reduces syscalls significantly.
 
 Client library:
 - Fix support for Python 2.6, 3.0, 3.1.

File lib/mosquitto_internal.h

 	char *tls_psk_identity;
 	bool tls_insecure;
 #endif
-	bool want_read;
 	bool want_write;
 #if defined(WITH_THREADING) && !defined(WITH_BROKER)
 	pthread_mutex_t callback_mutex;

File lib/net_mosq.c

 		if(ret != 1){
 			ret = SSL_get_error(mosq->ssl, ret);
 			if(ret == SSL_ERROR_WANT_READ){
-				mosq->want_read = true;
+				/* We always try to read anyway */
 			}else if(ret == SSL_ERROR_WANT_WRITE){
 				mosq->want_write = true;
 			}else{
 			err = SSL_get_error(mosq->ssl, ret);
 			if(err == SSL_ERROR_WANT_READ){
 				ret = -1;
-				mosq->want_read = true;
 				errno = EAGAIN;
 			}else if(err == SSL_ERROR_WANT_WRITE){
 				ret = -1;
 			err = SSL_get_error(mosq->ssl, ret);
 			if(err == SSL_ERROR_WANT_READ){
 				ret = -1;
-				mosq->want_read = true;
 				errno = EAGAIN;
 			}else if(err == SSL_ERROR_WANT_WRITE){
 				ret = -1;
 			assert(pollfds[db->contexts[i]->pollfd_index].fd == db->contexts[i]->sock);
 #ifdef WITH_TLS
 			if(pollfds[db->contexts[i]->pollfd_index].revents & POLLIN ||
-					db->contexts[i]->want_read ||
 					(db->contexts[i]->ssl && db->contexts[i]->state == mosq_cs_new)){
 #else
 			if(pollfds[db->contexts[i]->pollfd_index].revents & POLLIN){
 						}
 						SSL_set_ex_data(new_context->ssl, tls_ex_index_context, new_context);
 						SSL_set_ex_data(new_context->ssl, tls_ex_index_listener, &db->config->listeners[i]);
-						new_context->want_read = true;
 						new_context->want_write = true;
 						bio = BIO_new_socket(new_sock, BIO_NOCLOSE);
 						SSL_set_bio(new_context->ssl, bio, bio);
 						if(rc != 1){
 							rc = SSL_get_error(new_context->ssl, rc);
 							if(rc == SSL_ERROR_WANT_READ){
-								new_context->want_read = true;
+								/* We always want to read. */
 							}else if(rc == SSL_ERROR_WANT_WRITE){
 								new_context->want_write = true;
 							}else{