git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@4694 0c269be4-1314-0410-8aa9-9f06e86f4224tags/1.9.9.5
@@ -37,17 +37,12 @@ JackRequestDecoder::JackRequestDecoder(JackServer* server, JackClientHandlerInte | |||||
JackRequestDecoder::~JackRequestDecoder() | JackRequestDecoder::~JackRequestDecoder() | ||||
{} | {} | ||||
bool JackRequestDecoder::HandleRequest(detail::JackChannelTransactionInterface* socket) | |||||
void JackRequestDecoder::HandleRequest(detail::JackChannelTransactionInterface* socket, int type_aux) | |||||
{ | { | ||||
// Read header | |||||
JackRequest header; | |||||
if (header.Read(socket) < 0) { | |||||
jack_log("HandleRequest: cannot read header"); | |||||
return false; | |||||
} | |||||
JackRequest::RequestType type = (JackRequest::RequestType)type_aux; | |||||
// Read data | // Read data | ||||
switch (header.fType) { | |||||
switch (type) { | |||||
case JackRequest::kClientCheck: { | case JackRequest::kClientCheck: { | ||||
jack_log("JackRequest::ClientCheck"); | jack_log("JackRequest::ClientCheck"); | ||||
@@ -58,8 +53,11 @@ bool JackRequestDecoder::HandleRequest(detail::JackChannelTransactionInterface* | |||||
if (res.Write(socket) < 0) | if (res.Write(socket) < 0) | ||||
jack_error("JackRequest::ClientCheck write error name = %s", req.fName); | jack_error("JackRequest::ClientCheck write error name = %s", req.fName); | ||||
// Atomic ClientCheck followed by ClientOpen on same socket | // Atomic ClientCheck followed by ClientOpen on same socket | ||||
if (req.fOpen) | |||||
HandleRequest(socket); | |||||
if (req.fOpen) { | |||||
JackRequest header; | |||||
header.Read(socket); | |||||
HandleRequest(socket, header.fType); | |||||
} | |||||
break; | break; | ||||
} | } | ||||
@@ -369,11 +367,9 @@ bool JackRequestDecoder::HandleRequest(detail::JackChannelTransactionInterface* | |||||
} | } | ||||
default: | default: | ||||
jack_error("Unknown request %ld", header.fType); | |||||
jack_error("Unknown request %ld", type); | |||||
break; | break; | ||||
} | } | ||||
return true; | |||||
} | } | ||||
} // end of namespace | } // end of namespace | ||||
@@ -52,7 +52,7 @@ class JackRequestDecoder | |||||
JackRequestDecoder(JackServer* server, JackClientHandlerInterface* handler); | JackRequestDecoder(JackServer* server, JackClientHandlerInterface* handler); | ||||
virtual ~JackRequestDecoder(); | virtual ~JackRequestDecoder(); | ||||
bool HandleRequest(detail::JackChannelTransactionInterface* socket); | |||||
void HandleRequest(detail::JackChannelTransactionInterface* socket, int type); | |||||
}; | }; | ||||
} // end of namespace | } // end of namespace | ||||
@@ -236,9 +236,15 @@ bool JackSocketServerChannel::Execute() | |||||
jack_log("Poll client error err = %s", strerror(errno)); | jack_log("Poll client error err = %s", strerror(errno)); | ||||
ClientKill(fd); | ClientKill(fd); | ||||
} else if (fPollTable[i].revents & POLLIN) { | } else if (fPollTable[i].revents & POLLIN) { | ||||
if (!fDecoder->HandleRequest(fSocketTable[fd].second)) { | |||||
jack_log("Could not handle external client request"); | |||||
// Read header | |||||
JackClientSocket* socket = fSocketTable[fd].second; | |||||
JackRequest header; | |||||
if (header.Read(socket) < 0) { | |||||
jack_log("HandleRequest: cannot read header"); | |||||
ClientKill(fd); | ClientKill(fd); | ||||
return false; | |||||
} else { | |||||
fDecoder->HandleRequest(socket, header.fType); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@@ -88,18 +88,24 @@ bool JackClientPipeThread::Execute() | |||||
try{ | try{ | ||||
jack_log("JackClientPipeThread::Execute"); | jack_log("JackClientPipeThread::Execute"); | ||||
JackRequest header; | |||||
if (header.Read(socket) < 0) { | |||||
jack_log("HandleRequest: cannot read header"); | |||||
ClientKill(fd); | |||||
return false; | |||||
} | |||||
// Lock the global mutex | // Lock the global mutex | ||||
if (WaitForSingleObject(fMutex, INFINITE) == WAIT_FAILED) { | if (WaitForSingleObject(fMutex, INFINITE) == WAIT_FAILED) { | ||||
jack_error("JackClientPipeThread::HandleRequest: mutex wait error"); | jack_error("JackClientPipeThread::HandleRequest: mutex wait error"); | ||||
} | } | ||||
bool res = fDecoder->HandleRequest(fPipe); | |||||
if (!res) { | |||||
ClientKill(); | |||||
} | |||||
fDecoder->HandleRequest(fPipe, header.fType); | |||||
// Unlock the global mutex | // Unlock the global mutex | ||||
ReleaseMutex(fMutex); | |||||
if (!ReleaseMutex(fMutex)) { | |||||
jack_error("JackClientPipeThread::HandleRequest: mutex release error"); | |||||
} | |||||
return res; | return res; | ||||
} catch (JackQuitException& e) { | } catch (JackQuitException& e) { | ||||