More logging for TelldusService debug, ticket #266, 266-1.
This commit is contained in:
parent
7ee8407922
commit
df6bd27883
4 changed files with 19 additions and 9 deletions
|
@ -108,14 +108,14 @@ void CallbackMainDispatcher::run(){
|
||||||
}
|
}
|
||||||
//logga här, att den fortfarande körs, ev till fil bara för att det kan bli så mkt...
|
//logga här, att den fortfarande körs, ev till fil bara för att det kan bli så mkt...
|
||||||
//om för mkt, kolla att viss tid gått sedan förra ggn eller ngt...
|
//om för mkt, kolla att viss tid gått sedan förra ggn eller ngt...
|
||||||
debuglog(333, "Callbackevent, signalled");
|
//debuglog(333, "Callbackevent, signalled");
|
||||||
TelldusCore::MutexLocker locker(&d->mutex);
|
TelldusCore::MutexLocker locker(&d->mutex);
|
||||||
//logga, har låst
|
//logga, har låst
|
||||||
debuglog(333, "Callbackevent, locked");
|
//debuglog(333, "Callbackevent, locked");
|
||||||
for(CallbackList::iterator callback_it = d->callbackList.begin(); callback_it != d->callbackList.end(); ++callback_it) {
|
for(CallbackList::iterator callback_it = d->callbackList.begin(); callback_it != d->callbackList.end(); ++callback_it) {
|
||||||
if ( (*callback_it)->type == cbd->type ) {
|
if ( (*callback_it)->type == cbd->type ) {
|
||||||
//ev logga här också, att det finns ngnstans att skicka till
|
//ev logga här också, att det finns ngnstans att skicka till
|
||||||
debuglog((*callback_it)->id, "Callbackevent, sending");
|
//debuglog((*callback_it)->id, "Callbackevent, sending");
|
||||||
std::tr1::shared_ptr<TelldusCore::TDEventDispatcher> ptr(new TelldusCore::TDEventDispatcher(eventData, *callback_it, d->janitor));
|
std::tr1::shared_ptr<TelldusCore::TDEventDispatcher> ptr(new TelldusCore::TDEventDispatcher(eventData, *callback_it, d->janitor));
|
||||||
d->eventThreadList.push_back(ptr);
|
d->eventThreadList.push_back(ptr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,20 +154,23 @@ std::wstring Client::sendToService(const Message &msg) {
|
||||||
if(tries == 20){
|
if(tries == 20){
|
||||||
TelldusCore::Message msg;
|
TelldusCore::Message msg;
|
||||||
msg.addArgument(TELLSTICK_ERROR_CONNECTING_SERVICE);
|
msg.addArgument(TELLSTICK_ERROR_CONNECTING_SERVICE);
|
||||||
|
debuglog(555, "Connection failed, 20 retries, giving up.");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
Socket s;
|
Socket s;
|
||||||
s.connect(L"TelldusClient");
|
s.connect(L"TelldusClient");
|
||||||
if (!s.isConnected()) { //Connection failed
|
if (!s.isConnected()) { //Connection failed
|
||||||
|
debuglog(555, "Connection failed");
|
||||||
msleep(500);
|
msleep(500);
|
||||||
continue; //retry
|
continue; //retry
|
||||||
}
|
}
|
||||||
s.write(msg.data());
|
s.write(msg.data());
|
||||||
if (!s.isConnected()) { //Connection failed sometime during operation... (better check here, instead of 5 seconds timeout later)
|
if (!s.isConnected()) { //Connection failed sometime during operation... (better check here, instead of 5 seconds timeout later)
|
||||||
msleep(500);
|
msleep(500);
|
||||||
|
debuglog(555, "Error in write, should retry");
|
||||||
continue; //retry
|
continue; //retry
|
||||||
}
|
}
|
||||||
readData = s.read(8000); //TODO changed to 10000 from 5000, how much does this do...?
|
readData = s.read(1000); //TODO changed to 10000 from 5000, how much does this do...?
|
||||||
if(readData == L""){
|
if(readData == L""){
|
||||||
msleep(500);
|
msleep(500);
|
||||||
continue; //TODO can we be really sure it SHOULD be anything?
|
continue; //TODO can we be really sure it SHOULD be anything?
|
||||||
|
|
|
@ -120,6 +120,7 @@ std::wstring Socket::read(int timeout){
|
||||||
|
|
||||||
if (!fSuccess) {
|
if (!fSuccess) {
|
||||||
DWORD err = GetLastError();
|
DWORD err = GetLastError();
|
||||||
|
debuglog((int)err, "Something read error");
|
||||||
if(err != ERROR_OPERATION_ABORTED){ //gets this "error" always when nothing was reads
|
if(err != ERROR_OPERATION_ABORTED){ //gets this "error" always when nothing was reads
|
||||||
debuglog((int)err, "Socket read error");
|
debuglog((int)err, "Socket read error");
|
||||||
}
|
}
|
||||||
|
@ -131,7 +132,7 @@ std::wstring Socket::read(int timeout){
|
||||||
buf[0] = 0;
|
buf[0] = 0;
|
||||||
}
|
}
|
||||||
if (err == ERROR_BROKEN_PIPE){
|
if (err == ERROR_BROKEN_PIPE){
|
||||||
debuglog(222, "Got an error, close this socket");
|
debuglog((int)err, "Got an error, close this socket");
|
||||||
d->connected = false;
|
d->connected = false;
|
||||||
break; //TODO is this correct?
|
break; //TODO is this correct?
|
||||||
}
|
}
|
||||||
|
@ -158,7 +159,7 @@ void Socket::write(const std::wstring &msg){
|
||||||
BOOL writeSuccess = WriteFile(d->hPipe, msg.data(), (DWORD)msg.length()*sizeof(wchar_t), &bytesWritten, &oOverlap);
|
BOOL writeSuccess = WriteFile(d->hPipe, msg.data(), (DWORD)msg.length()*sizeof(wchar_t), &bytesWritten, &oOverlap);
|
||||||
result = GetLastError();
|
result = GetLastError();
|
||||||
if (writeSuccess || result == ERROR_IO_PENDING) {
|
if (writeSuccess || result == ERROR_IO_PENDING) {
|
||||||
result = WaitForSingleObject(writeEvent, 500);
|
result = WaitForSingleObject(writeEvent, 30000);
|
||||||
if (result == WAIT_TIMEOUT) {
|
if (result == WAIT_TIMEOUT) {
|
||||||
CancelIo(d->hPipe);
|
CancelIo(d->hPipe);
|
||||||
WaitForSingleObject(oOverlap.hEvent, INFINITE);
|
WaitForSingleObject(oOverlap.hEvent, INFINITE);
|
||||||
|
@ -169,12 +170,18 @@ void Socket::write(const std::wstring &msg){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fSuccess = GetOverlappedResult(d->hPipe, &oOverlap, &bytesWritten, TRUE);
|
fSuccess = GetOverlappedResult(d->hPipe, &oOverlap, &bytesWritten, TRUE);
|
||||||
|
if (!fSuccess){
|
||||||
|
debuglog(result, "Error in GetOverlappedResult");
|
||||||
|
result = GetLastError();
|
||||||
|
debuglog(result, "Error in GetOverlappedResult, this message");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseHandle(writeEvent);
|
CloseHandle(writeEvent);
|
||||||
if (!fSuccess) {
|
if (!fSuccess) {
|
||||||
CloseHandle(d->hPipe);
|
CloseHandle(d->hPipe);
|
||||||
d->hPipe = 0;
|
d->hPipe = 0;
|
||||||
|
debuglog(result, "Error in write event, closing socket");
|
||||||
d->connected = false;
|
d->connected = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ void EventUpdateManager::sendMessageToClients(EventUpdateData *data){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//printf("Sent message to %d connected clients", connected)
|
//printf("Sent message to %d connected clients", connected)
|
||||||
std::stringstream strMessage;
|
//std::stringstream strMessage;
|
||||||
strMessage << "Sent message to " << connected << " clients" << std::endl;
|
//strMessage << "Sent message to " << connected << " clients" << std::endl;
|
||||||
debuglogservice(0, strMessage.str());
|
//debuglogservice(0, strMessage.str());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue