- nhttp: enable threading

This is ported from neutrino-mp and contains code by martii and seife
from following commits:
20d3031b8bb47b5af79bf10c385e3564fe5c26dc
93d01c1987
363633dc1b
c3e1310a2f727e26ce11669e3aeae78305f87049
This commit is contained in:
svenhoefer
2014-08-19 13:13:31 +02:00
committed by [CST] Focus
parent f9c7662c73
commit 7589a3a9e0
5 changed files with 50 additions and 32 deletions

View File

@@ -48,7 +48,7 @@ CWebserver::CWebserver() {
FD_ZERO(&read_fds);
fdmax = 0;
open_connections = 0;
#ifdef Y_CONFIG_BUILD_AS_DAEMON
#ifdef Y_CONFIG_FEATURE_THREADING
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
#endif
@@ -412,13 +412,13 @@ bool CWebserver::handle_connection(CySocket *newSock) {
newConn->ySock = newSock;
newConn->ySock->handling = true;
newConn->WebserverBackref = this;
#ifdef Y_CONFIG_BUILD_AS_DAEMON
#ifdef Y_CONFIG_FEATURE_THREADING
newConn->is_treaded = is_threading;
#else
newConn->is_treaded = false;
#endif
int index = -1;
#ifdef Y_CONFIG_BUILD_AS_DAEMON
#ifdef Y_CONFIG_FEATURE_THREADING
if(is_threading)
{
pthread_mutex_lock( &mutex );
@@ -442,7 +442,7 @@ bool CWebserver::handle_connection(CySocket *newSock) {
// start connection Thread
if(pthread_create(&Connection_Thread_List[index], &attr, WebThread, (void *)newConn) != 0)
dperror("Could not create Connection-Thread\n");
dperror("Could not create Connection-Thread\n");
}
else // non threaded
#endif