stricter reply code checking: verify that we get the expected reply, not just that we don't get IPC_FAIL
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56817 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -53,20 +53,22 @@
|
|||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
|
||||||
// Message codes
|
// Message codes (don't change them to avoid breaking the existing code using
|
||||||
|
// wxIPC protocol!)
|
||||||
enum IPCCode
|
enum IPCCode
|
||||||
{
|
{
|
||||||
IPC_EXECUTE = 1,
|
IPC_EXECUTE = 1,
|
||||||
IPC_REQUEST,
|
IPC_REQUEST = 2,
|
||||||
IPC_POKE,
|
IPC_POKE = 3,
|
||||||
IPC_ADVISE_START,
|
IPC_ADVISE_START = 4,
|
||||||
IPC_ADVISE_REQUEST,
|
IPC_ADVISE_REQUEST = 5,
|
||||||
IPC_ADVISE,
|
IPC_ADVISE = 6,
|
||||||
IPC_ADVISE_STOP,
|
IPC_ADVISE_STOP = 7,
|
||||||
IPC_REQUEST_REPLY,
|
IPC_REQUEST_REPLY = 8,
|
||||||
IPC_FAIL,
|
IPC_FAIL = 9,
|
||||||
IPC_CONNECT,
|
IPC_CONNECT = 10,
|
||||||
IPC_DISCONNECT
|
IPC_DISCONNECT = 11,
|
||||||
|
IPC_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
@@ -576,8 +578,8 @@ const void *wxTCPConnection::Request(const wxString& item,
|
|||||||
|
|
||||||
IPCOutput(m_streams).Write(IPC_REQUEST, item, format);
|
IPCOutput(m_streams).Write(IPC_REQUEST, item, format);
|
||||||
|
|
||||||
int ret = m_streams->Read8();
|
const int ret = m_streams->Read8();
|
||||||
if ( ret == IPC_FAIL )
|
if ( ret != IPC_REQUEST_REPLY )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return m_streams->ReadData(this, size);
|
return m_streams->ReadData(this, size);
|
||||||
@@ -605,11 +607,9 @@ bool wxTCPConnection::StartAdvise(const wxString& item)
|
|||||||
|
|
||||||
IPCOutput(m_streams).Write(IPC_ADVISE_START, item);
|
IPCOutput(m_streams).Write(IPC_ADVISE_START, item);
|
||||||
|
|
||||||
int ret = m_streams->Read8();
|
const int ret = m_streams->Read8();
|
||||||
if (ret != IPC_FAIL)
|
|
||||||
return true;
|
return ret == IPC_ADVISE_START;
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTCPConnection::StopAdvise (const wxString& item)
|
bool wxTCPConnection::StopAdvise (const wxString& item)
|
||||||
@@ -619,12 +619,9 @@ bool wxTCPConnection::StopAdvise (const wxString& item)
|
|||||||
|
|
||||||
IPCOutput(m_streams).Write(IPC_ADVISE_STOP, item);
|
IPCOutput(m_streams).Write(IPC_ADVISE_STOP, item);
|
||||||
|
|
||||||
int ret = m_streams->Read8();
|
const int ret = m_streams->Read8();
|
||||||
|
|
||||||
if (ret != IPC_FAIL)
|
return ret == IPC_ADVISE_STOP;
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calls that SERVER can make
|
// Calls that SERVER can make
|
||||||
@@ -797,6 +794,11 @@ void wxTCPEventHandler::Client_OnRequest(wxSocketEvent &event)
|
|||||||
connection->OnDisconnect();
|
connection->OnDisconnect();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case IPC_FAIL:
|
||||||
|
wxLogDebug("Unexpected IPC_FAIL received");
|
||||||
|
error = true;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
wxLogDebug("Unknown message code %d received.", msg);
|
wxLogDebug("Unknown message code %d received.", msg);
|
||||||
error = true;
|
error = true;
|
||||||
|
Reference in New Issue
Block a user