[dss-commits] digitalSTROM Server branch, master, updated. 3b42bdf1854cfc2cb037ea9f0a305cffa5b05917
git version control
dss-commits at forum.digitalstrom.org
Tue Dec 8 11:14:07 CET 2009
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "digitalSTROM Server".
The branch, master has been updated
via 3b42bdf1854cfc2cb037ea9f0a305cffa5b05917 (commit)
via d58b8237a7a99b5e01c25b5888b6e86ba09e4578 (commit)
via ea022ba86997f0452e82eaa78de2cb3c14aa2b41 (commit)
from ff4f5806bb1230291d7095db2f5903ce40b0474f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 3b42bdf1854cfc2cb037ea9f0a305cffa5b05917
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date: Tue Dec 8 11:12:41 2009 +0100
Removed commented line in webservices.cpp
commit d58b8237a7a99b5e01c25b5888b6e86ba09e4578
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date: Tue Dec 8 11:11:06 2009 +0100
Check if the socket is still alive in EventWaitFor
Fixes #215
commit ea022ba86997f0452e82eaa78de2cb3c14aa2b41
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date: Tue Dec 8 09:45:52 2009 +0100
Register the right function for dev.turnOff
Fixes #228
-----------------------------------------------------------------------
Changes:
diff --git a/core/scripting/modeljs.cpp b/core/scripting/modeljs.cpp
index f01d5a4..503e970 100644
--- a/core/scripting/modeljs.cpp
+++ b/core/scripting/modeljs.cpp
@@ -528,7 +528,7 @@ namespace dss {
JSFunctionSpec device_interface_methods[] = {
{"turnOn", dev_turn_on, 0, 0, 0},
- {"turnOff", dev_turn_on, 0, 0, 0},
+ {"turnOff", dev_turn_off, 0, 0, 0},
{"enable", dev_enable, 0, 0, 0},
{"disable", dev_disable, 0, 0, 0},
{"startDim", dev_start_dim, 1, 0, 0},
diff --git a/webservices/model_soap.cpp b/webservices/model_soap.cpp
index d9e5443..9b4ed36 100644
--- a/webservices/model_soap.cpp
+++ b/webservices/model_soap.cpp
@@ -1157,7 +1157,7 @@ int dss__EventWaitFor(struct soap *soap, int _token, int _timeout, std::vector<d
return getResult;
}
- session->waitForEvent(_timeout);
+ session->waitForEvent(_timeout, soap);
while(session->hasEvent()) {
dss::Event origEvent = session->popEvent();
diff --git a/webservices/webservices.cpp b/webservices/webservices.cpp
index 29c47f9..9c3a87a 100644
--- a/webservices/webservices.cpp
+++ b/webservices/webservices.cpp
@@ -39,7 +39,6 @@ namespace dss {
m_PendingRequests.push_back(req_copy);
m_RequestsMutex.unlock();
m_RequestArrived.signal();
-// m_Service.serve();
}
}
} // execute
@@ -203,9 +202,43 @@ namespace dss {
assert(m_pEventListener != NULL);
} // createListener
- bool WebServiceSession::waitForEvent(const int _timeoutMS) {
+ bool WebServiceSession::waitForEvent(const int _timeoutMS, soap* _soapRequest) {
createListener();
- return m_pEventListener->waitForEvent(_timeoutMS);
+ const int kSocketDisconnectTimeoutMS = 200;
+ bool timedOut = false;
+ bool result = false;
+ int timeoutMSLeft = _timeoutMS;
+ while(!timedOut && !result) {
+ // check if we're still connected
+ uint8_t tmp;
+ int res = recv(_soapRequest->socket, &tmp, 1, MSG_PEEK | MSG_DONTWAIT);
+ if(res == -1) {
+ if((errno != EAGAIN) && (errno != EINTR) && (errno != EWOULDBLOCK)) {
+ Logger::getInstance()->log("WebServiceSession::waitForEvent: lost connection", lsInfo);
+ break;
+ }
+ } else if(res == 0) {
+ // if we were still connected, recv would return -1 with an errno listed above or 1
+ Logger::getInstance()->log("WebServiceSession::waitForEvent: lost connection", lsInfo);
+ break;
+ }
+ // calculate the length of our wait
+ int waitTime;
+ if(_timeoutMS == -1) {
+ timedOut = true;
+ waitTime = 0;
+ } else if(_timeoutMS != 0) {
+ waitTime = std::min(timeoutMSLeft, kSocketDisconnectTimeoutMS);
+ timeoutMSLeft -= waitTime;
+ timedOut = (timeoutMSLeft == 0);
+ } else {
+ waitTime = kSocketDisconnectTimeoutMS;
+ timedOut = false;
+ }
+ // wait for the event
+ result = m_pEventListener->waitForEvent(waitTime);
+ }
+ return result;
} // waitForEvent
Event WebServiceSession::popEvent() {
diff --git a/webservices/webservices.h b/webservices/webservices.h
index 48ad795..9ebce3c 100644
--- a/webservices/webservices.h
+++ b/webservices/webservices.h
@@ -37,7 +37,7 @@ namespace dss {
bool isOwner(soap* _soapRequest);
WebServiceSession& operator=(const WebServiceSession& _other);
- bool waitForEvent(const int _timeoutMS);
+ bool waitForEvent(const int _timeoutMS, soap* _soapRequest);
Event popEvent();
bool hasEvent();
hooks/post-receive
--
digitalSTROM Server
More information about the dss-commits
mailing list