Skip to content

Commit bff65fc

Browse files
committed
XmlRpcEmbedder: use putC on piped process to hopefully fix deadlock that was prevalent on windows
1 parent 23732e1 commit bff65fc

2 files changed

Lines changed: 17 additions & 9 deletions

File tree

XmlRpcEmbedder/XmlRpcEmbedder-unix.cbp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@
5555
</Compiler>
5656
<Linker>
5757
<Add option="`wx-config --libs`" />
58-
<Add library="XmlRpc" />
59-
<Add directory="XMLRPC" />
6058
</Linker>
6159
</Target>
6260
</Build>

XmlRpcEmbedder/xmlrpc_embedder.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,26 @@ class XmlRpcPipeClient
151151
}
152152
std::string msg;
153153
if(!generateRequest(method,params,msg))
154-
return set_error("bad request value for method call "+std::string(method),result);
154+
return set_error("Bad request value for method call "+std::string(method),result);
155155
uint32_t r_size=msg.size(); //TODO: Is it safer to use uint64_t (would need to use long long on the python side)
156-
m_ostream->Write(&r_size,sizeof(uint32_t));
157-
if(m_ostream->GetLastError()!=wxSTREAM_NO_ERROR)
158-
return set_error("broken stream attempting to write request size to pipe",result);
156+
char *cr_size = (char*)&r_size;
157+
for(uint32_t i=0;i<sizeof(uint32_t);++i)
158+
{
159+
do
160+
{
161+
m_ostream->PutC(cr_size[i]);
162+
if(m_ostream->GetLastError()!=wxSTREAM_NO_ERROR)
163+
return set_error("Broken stream attempting to write request size to pipe",result);
164+
} while (m_ostream->LastWrite()!=sizeof(uint32_t));
165+
}
159166
for(uint32_t i=0;i<msg.size();++i)
160167
{
161-
m_ostream->PutC(msg[i]);
162-
if(m_ostream->GetLastError()!=wxSTREAM_NO_ERROR)
163-
return set_error("Broken stream attempting to write request to pipe",result);
168+
do
169+
{
170+
m_ostream->PutC(msg[i]);
171+
if(m_ostream->GetLastError()!=wxSTREAM_NO_ERROR)
172+
return set_error("Broken stream attempting to write request to pipe",result);
173+
} while (m_ostream->LastWrite()!=sizeof(uint32_t));
164174
}
165175

166176
//NOW WAIT FOR THE REPLY

0 commit comments

Comments
 (0)