|
From: <fe...@us...> - 2010-06-09 16:39:43
|
Revision: 41
http://ehs.svn.sourceforge.net/ehs/?rev=41&view=rev
Author: felfert
Date: 2010-06-09 16:39:37 +0000 (Wed, 09 Jun 2010)
Log Message:
-----------
- Cosmetics
Modified Paths:
--------------
trunk/ehs.cpp
Modified: trunk/ehs.cpp
===================================================================
--- trunk/ehs.cpp 2010-06-09 16:37:23 UTC (rev 40)
+++ trunk/ehs.cpp 2010-06-09 16:39:37 UTC (rev 41)
@@ -591,11 +591,6 @@
try {
HandleData(1000, self); // 1000ms select timeout
-#if 0
- EHS_TRACE ( "B1=%d B2=%d TID=%p\n",
- (m_nServerRunningStatus == SERVERRUNNING_THREADPOOL),
- (self == m_nAcceptThreadId), self );
-#endif
} catch (exception &e) {
catched = true;
eResponse = m_poTopLevelEHS->HandleThreadException(self, m_poCurrentRequest, e);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fe...@us...> - 2011-11-15 10:17:22
|
Revision: 64
http://ehs.svn.sourceforge.net/ehs/?rev=64&view=rev
Author: felfert
Date: 2011-11-15 10:17:16 +0000 (Tue, 15 Nov 2011)
Log Message:
-----------
- Tweaking around...
Modified Paths:
--------------
trunk/ehs.cpp
Modified: trunk/ehs.cpp
===================================================================
--- trunk/ehs.cpp 2011-11-14 22:46:17 UTC (rev 63)
+++ trunk/ehs.cpp 2011-11-15 10:17:16 UTC (rev 64)
@@ -749,6 +749,7 @@
EHS_TRACE("add response found something to delete\n");
// Both mutexes are interlocked intentionally.
pthread_mutex_lock(&m_poEHSServer->m_oMutex);
+ MutexHelper server_mutex(&m_poEHSServer->m_oMutex);
mutex.Unlock();
m_poEHSServer->RemoveEHSConnection(this);
mutex.Lock();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fe...@us...> - 2012-01-30 13:32:55
|
Revision: 77
http://ehs.svn.sourceforge.net/ehs/?rev=77&view=rev
Author: felfert
Date: 2012-01-30 13:32:45 +0000 (Mon, 30 Jan 2012)
Log Message:
-----------
- Send response body without locking
Modified Paths:
--------------
trunk/ehs.cpp
Modified: trunk/ehs.cpp
===================================================================
--- trunk/ehs.cpp 2012-01-19 14:02:46 UTC (rev 76)
+++ trunk/ehs.cpp 2012-01-30 13:32:45 UTC (rev 77)
@@ -774,7 +774,7 @@
break;
case EHSConnection::ADDBUFFER_NORESOURCE:
{
- // Immediately send a 500 response, then close the connection
+ // Immediately send a 503 response, then close the connection
auto_ptr<HttpResponse> tmp(HttpResponse::Error(HTTPRESPONSECODE_503_SERVICEUNAVAILABLE, 0, *i));
(*i)->SendHttpResponse(tmp);
(*i)->DoneReading(false);
@@ -802,7 +802,9 @@
if (m_oHttpResponseMap.end() != i) {
found = true;
--m_nActiveRequests;
+ mutex.Unlock();
SendHttpResponse(auto_ptr<HttpResponse>(i->second));
+ mutex.Lock();
m_oHttpResponseMap.erase(i);
++m_nResponses;
// set last activity to the current time for idle purposes
@@ -814,6 +816,8 @@
void EHSConnection::SendHttpResponse(auto_ptr<HttpResponse> response)
{
+ MutexHelper mutex(&m_oMutex);
+
// only send it if the client isn't disconnected
if (Disconnected()) {
return;
@@ -840,6 +844,7 @@
// extra line break signalling end of headers
oss << "\r\n";
+ mutex.Unlock();
m_poNetworkAbstraction->Send(
reinterpret_cast<const void *>(oss.str().c_str()), oss.str().length());
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fre...@us...> - 2012-01-31 10:59:07
|
Revision: 79
http://ehs.svn.sourceforge.net/ehs/?rev=79&view=rev
Author: fredroth
Date: 2012-01-31 10:58:57 +0000 (Tue, 31 Jan 2012)
Log Message:
-----------
handling of 'request too large' and 'invalid request' seperated
Modified Paths:
--------------
trunk/ehs.cpp
Modified: trunk/ehs.cpp
===================================================================
--- trunk/ehs.cpp 2012-01-31 08:54:03 UTC (rev 78)
+++ trunk/ehs.cpp 2012-01-31 10:58:57 UTC (rev 79)
@@ -763,7 +763,6 @@
// if add buffer failed, don't read from this connection anymore
switch (nAddBufferResult) {
case EHSConnection::ADDBUFFER_INVALIDREQUEST:
- case EHSConnection::ADDBUFFER_TOOBIG:
{
// Immediately send a 400 response, then close the connection
auto_ptr<HttpResponse> tmp(HttpResponse::Error(HTTPRESPONSECODE_400_BADREQUEST, 0, *i));
@@ -772,6 +771,15 @@
EHS_TRACE("Done reading because we got a bad request");
}
break;
+ case EHSConnection::ADDBUFFER_TOOBIG:
+ {
+ // Immediately send a 413 response, then close the connection
+ auto_ptr<HttpResponse> tmp(HttpResponse::Error(HTTPRESPONSECODE_413_TOOLARGE, 0, *i));
+ (*i)->SendHttpResponse(tmp);
+ (*i)->DoneReading(false);
+ EHS_TRACE("Done reading because we got a too large request");
+ }
+ break;
case EHSConnection::ADDBUFFER_NORESOURCE:
{
// Immediately send a 503 response, then close the connection
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fe...@us...> - 2012-04-25 01:51:42
|
Revision: 138
http://ehs.svn.sourceforge.net/ehs/?rev=138&view=rev
Author: felfert
Date: 2012-04-25 01:51:36 +0000 (Wed, 25 Apr 2012)
Log Message:
-----------
- Don't operate concurrently on STL containers.
Modified Paths:
--------------
trunk/ehs.cpp
Modified: trunk/ehs.cpp
===================================================================
--- trunk/ehs.cpp 2012-04-22 17:35:08 UTC (rev 137)
+++ trunk/ehs.cpp 2012-04-25 01:51:36 UTC (rev 138)
@@ -868,8 +868,9 @@
// push the object on to the list
m_oResponseQueue.push_back(ehs_move(response));
while (!m_oResponseQueue.empty()) {
+ GenericResponse *r = m_oResponseQueue.front().get();
mutex.Unlock();
- SendResponse(m_oResponseQueue.front().get());
+ SendResponse(r);
mutex.Lock();
m_oResponseQueue.pop_front();
// set last activity to the current time for idle purposes
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fe...@us...> - 2012-04-25 18:09:52
|
Revision: 139
http://ehs.svn.sourceforge.net/ehs/?rev=139&view=rev
Author: felfert
Date: 2012-04-25 18:09:46 +0000 (Wed, 25 Apr 2012)
Log Message:
-----------
- Better thread safety
Modified Paths:
--------------
trunk/ehs.cpp
Modified: trunk/ehs.cpp
===================================================================
--- trunk/ehs.cpp 2012-04-25 01:51:36 UTC (rev 138)
+++ trunk/ehs.cpp 2012-04-25 18:09:46 UTC (rev 139)
@@ -868,11 +868,11 @@
// push the object on to the list
m_oResponseQueue.push_back(ehs_move(response));
while (!m_oResponseQueue.empty()) {
- GenericResponse *r = m_oResponseQueue.front().get();
+ ehs_autoptr<GenericResponse> tmp = ehs_move(m_oResponseQueue.front());
+ m_oResponseQueue.pop_front();
mutex.Unlock();
- SendResponse(r);
+ SendResponse(tmp.get());
mutex.Lock();
- m_oResponseQueue.pop_front();
// set last activity to the current time for idle purposes
UpdateLastActivity();
EHS_TRACE("Sending %d response(s) to %x", m_nResponses, this);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fe...@us...> - 2012-05-12 07:06:13
|
Revision: 141
http://ehs.svn.sourceforge.net/ehs/?rev=141&view=rev
Author: felfert
Date: 2012-05-12 07:06:07 +0000 (Sat, 12 May 2012)
Log Message:
-----------
- Mark connection for closing on error during sending a response.
Modified Paths:
--------------
trunk/ehs.cpp
Modified: trunk/ehs.cpp
===================================================================
--- trunk/ehs.cpp 2012-04-25 21:52:50 UTC (rev 140)
+++ trunk/ehs.cpp 2012-05-12 07:06:07 UTC (rev 141)
@@ -882,6 +882,7 @@
void EHSConnection::SendResponse(GenericResponse *gresp)
{
MutexHelper mutex(&m_oMutex);
+ int r = 0;
HttpResponse *response = dynamic_cast<HttpResponse *>(gresp);
if (NULL == response) {
@@ -893,8 +894,9 @@
mutex.Unlock();
if (0 < len) {
EHS_TRACE("Sending GENERIC response", "");
- m_poNetworkAbstraction->Send(
+ r = m_poNetworkAbstraction->Send(
reinterpret_cast<const void *>(gresp->GetBody().data()), gresp->GetBody().length());
+ EHS_TRACE("Sent GENERIC response r=%d", r);
} else {
// Special case: "sending" a zero-sized body triggers a close.
DoneReading(false);
@@ -930,28 +932,33 @@
// extra line break signalling end of headers
oss << "\r\n";
mutex.Unlock();
- m_poNetworkAbstraction->Send(
+ r = m_poNetworkAbstraction->Send(
reinterpret_cast<const void *>(oss.str().c_str()), oss.str().length());
- // Switch protocols if necessary
- if (HTTPRESPONSECODE_101_SWITCHING_PROTOCOLS == response->GetResponseCode()) {
- EHS_TRACE("Switching connection to RAW mode", "");
- m_bRawMode = true;
- RawSocketHandler *rsh = m_poEHSServer->m_poTopLevelEHS->GetRawSocketHandler();
- if (rsh) {
- rsh->OnConnect(this);
+ if (-1 != r) {
+ // Switch protocols if necessary
+ if (HTTPRESPONSECODE_101_SWITCHING_PROTOCOLS == response->GetResponseCode()) {
+ EHS_TRACE("Switching connection to RAW mode", "");
+ m_bRawMode = true;
+ RawSocketHandler *rsh = m_poEHSServer->m_poTopLevelEHS->GetRawSocketHandler();
+ if (rsh) {
+ rsh->OnConnect(this);
+ }
+ return;
}
- return;
- }
- // now send the body
- int blen = atoi(response->GetHeaders()["content-length"].c_str());
- if (blen > 0) {
- EHS_TRACE("Sending %d bytes in thread %08x", blen, pthread_self());
- m_poNetworkAbstraction->Send(response->GetBody().data(), blen);
- EHS_TRACE("Done sending %d bytes in thread %08x", blen, pthread_self());
+ // now send the body
+ int blen = atoi(response->GetHeaders()["content-length"].c_str());
+ if (blen > 0) {
+ EHS_TRACE("Sending %d bytes in thread %08x", blen, pthread_self());
+ int r = m_poNetworkAbstraction->Send(response->GetBody().data(), blen);
+ EHS_TRACE("Done sending %d bytes in thread %08x r=%d", blen, pthread_self(), r);
+ }
}
}
+ if (-1 == r) {
+ DoneReading(false);
+ }
}
void EHSServer::EndServerThread()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fe...@us...> - 2012-06-08 03:29:14
|
Revision: 152
http://ehs.svn.sourceforge.net/ehs/?rev=152&view=rev
Author: felfert
Date: 2012-06-08 03:29:07 +0000 (Fri, 08 Jun 2012)
Log Message:
-----------
- Fixed close handling
Modified Paths:
--------------
trunk/ehs.cpp
Modified: trunk/ehs.cpp
===================================================================
--- trunk/ehs.cpp 2012-06-07 15:43:04 UTC (rev 151)
+++ trunk/ehs.cpp 2012-06-08 03:29:07 UTC (rev 152)
@@ -915,11 +915,8 @@
}
EHS_TRACE("Sending HTTP response", "");
HttpResponse *response = reinterpret_cast<HttpResponse *>(gresp);
- if (HTTPRESPONSECODE_101_SWITCHING_PROTOCOLS == response->GetResponseCode()) {
- // Make shure, that we don't close the connaction when switching protocols
- response->RemoveHeader("Connection");
- }
- forceClose = (0 == response->Header("connection").compare("close"));
+ forceClose = ((0 == response->Header("connection").compare("close")) &&
+ (HTTPRESPONSECODE_101_SWITCHING_PROTOCOLS != response->GetResponseCode()));
ostringstream oss;
// add in the response code
oss << "HTTP/1.1 " << response->GetResponseCode()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|