Windows service, 2.1.0a and new changes for possible new version.

This commit is contained in:
Stefan Persson 2011-11-04 14:32:22 +01:00
parent 4b37109f27
commit 24586433d9
12 changed files with 226 additions and 42 deletions

View file

@ -1,4 +1,5 @@
#include "Socket.h"
#include "common.h"
#include <windows.h>
#include <AccCtrl.h>
@ -102,18 +103,24 @@ std::wstring Socket::read(int timeout){
if(!d->running){
CancelIo(d->hPipe);
CloseHandle(d->readEvent);
//debuglog(1, "Not running");
return L"";
}
if (result == WAIT_TIMEOUT) {
CancelIo(d->hPipe);
CloseHandle(d->readEvent);
//debuglog(1, "Wait timeout");
return L"";
}
fSuccess = GetOverlappedResult(d->hPipe, &oOverlap, &cbBytesRead, false);
if (!fSuccess) {
DWORD err = GetLastError();
//debuglog(result, "This then?");
//debuglog(1, "Unsuccessful");
if (err == ERROR_BROKEN_PIPE) {
//debuglog(1, "Broken pipe");
d->connected = false;
}
buf[0] = 0;
@ -143,6 +150,7 @@ void Socket::write(const std::wstring &msg){
CancelIo(d->hPipe);
CloseHandle(writeEvent);
d->connected = false;
//debuglog(2, "Wait timeout");
return;
}
fSuccess = GetOverlappedResult(d->hPipe, &oOverlap, &bytesWritten, TRUE);
@ -150,6 +158,7 @@ void Socket::write(const std::wstring &msg){
if (!fSuccess) {
CancelIo(d->hPipe);
d->connected = false;
//debuglog(2, "Unsuccessful");
return;
}
}