diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/UdpTransceiver.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp index 1147d6c45ce..60416db2311 100644 --- a/cpp/src/Ice/UdpTransceiver.cpp +++ b/cpp/src/Ice/UdpTransceiver.cpp @@ -446,12 +446,20 @@ IceInternal::UdpTransceiver::startWrite(Buffer& buf) DataWriter^ writer = ref new DataWriter(task.get()); writer->WriteBytes(ref new Array<unsigned char>(&*buf.i, static_cast<int>(buf.b.size()))); DataWriterStoreOperation^ operation = writer->StoreAsync(); - if(checkIfErrorOrCompleted(SocketOperationWrite, operation)) + + if(operation->Status == Windows::Foundation::AsyncStatus::Completed) { + // + // NOTE: unlike other methods, it's important to modify _write.count + // _before_ calling checkIfErrorOrCompleted since this isn't called + // with the connection mutex but from a Windows thread pool thread. + // So we can't modify the _write structure after calling the + // completed callback. + // _write.count = operation->GetResults(); - _completedHandler(SocketOperationWrite); } - else + + if(!checkIfErrorOrCompleted(SocketOperationWrite, operation)) { operation->Completed = _writeOperationCompletedHandler; } |