<div dir="ltr">I tried to lock everything... still not working, I cannot figure out if there is still crash, because the server almost doesn't work anymore..<div>The code: <a href="http://pastebin.com/xmqjn15B">http://pastebin.com/xmqjn15B</a></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-01-22 23:27 GMT+08:00 Lee Salzman <span dir="ltr"><<a href="mailto:lsalzman@gmail.com" target="_blank">lsalzman@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">enet_host_service must also be locked. enet_host_service and<br>
enet_host_flush both will modify sensitive internal bits of the host<br>
structure AND the peer structure, so unfortunately, all of these must<br>
be locked at the same time to work.<br>
<div class="HOEnZb"><div class="h5"><br>
On Fri, Jan 22, 2016 at 9:38 AM, aj3423 <<a href="mailto:aj3423@gmail.com">aj3423@gmail.com</a>> wrote:<br>
> Thanks. I tried simply guard all access to 'peer' (the line of peer->address<br>
> is commented out), still not working. My code at:<br>
> <a href="http://pastebin.com/QJhH871p" rel="noreferrer" target="_blank">http://pastebin.com/QJhH871p</a> , what do I miss?<br>
><br>
> 2016-01-22 22:05 GMT+08:00 Lee Salzman <<a href="mailto:lsalzman@gmail.com">lsalzman@gmail.com</a>>:<br>
>><br>
>> You would have to guard all access to ENetPeer as well, including<br>
>> enet_peer_send and peer->address.<br>
>><br>
>> On Fri, Jan 22, 2016 at 1:27 AM, aj3423 <<a href="mailto:aj3423@gmail.com">aj3423@gmail.com</a>> wrote:<br>
>> > My server should receive message from client and echo back some message,<br>
>> > but<br>
>> > in my case building the message packet costs time, so I need to create a<br>
>> > thread to echo message to clients.<br>
>> ><br>
>> > I wrote a test to illustrate this problem, the client runs a infinit<br>
>> > loop,<br>
>> > sending 2k data to server and receive 2k data. The server crashes after<br>
>> > a<br>
>> > while, randomly. the code:<br>
>> ><br>
>> > server: <a href="http://pastebin.com/99kpQgTJ" rel="noreferrer" target="_blank">http://pastebin.com/99kpQgTJ</a><br>
>> > client:  <a href="http://pastebin.com/wX8jfZgk" rel="noreferrer" target="_blank">http://pastebin.com/wX8jfZgk</a><br>
>> ><br>
>> > It crashes at function enet_host_flush, I tried to use `std::mutex` but<br>
>> > doesn't help. Any idea? Thanks.<br>
>> ><br>
>> > My Environment: Win7 32bit + VS2013 + Enet 1.3.13<br>
>> ><br>
>> ><br>
>> > _______________________________________________<br>
>> > ENet-discuss mailing list<br>
>> > <a href="mailto:ENet-discuss@cubik.org">ENet-discuss@cubik.org</a><br>
>> > <a href="http://lists.cubik.org/mailman/listinfo/enet-discuss" rel="noreferrer" target="_blank">http://lists.cubik.org/mailman/listinfo/enet-discuss</a><br>
>> ><br>
>> _______________________________________________<br>
>> ENet-discuss mailing list<br>
>> <a href="mailto:ENet-discuss@cubik.org">ENet-discuss@cubik.org</a><br>
>> <a href="http://lists.cubik.org/mailman/listinfo/enet-discuss" rel="noreferrer" target="_blank">http://lists.cubik.org/mailman/listinfo/enet-discuss</a><br>
><br>
><br>
><br>
> _______________________________________________<br>
> ENet-discuss mailing list<br>
> <a href="mailto:ENet-discuss@cubik.org">ENet-discuss@cubik.org</a><br>
> <a href="http://lists.cubik.org/mailman/listinfo/enet-discuss" rel="noreferrer" target="_blank">http://lists.cubik.org/mailman/listinfo/enet-discuss</a><br>
><br>
_______________________________________________<br>
ENet-discuss mailing list<br>
<a href="mailto:ENet-discuss@cubik.org">ENet-discuss@cubik.org</a><br>
<a href="http://lists.cubik.org/mailman/listinfo/enet-discuss" rel="noreferrer" target="_blank">http://lists.cubik.org/mailman/listinfo/enet-discuss</a><br>
</div></div></blockquote></div><br></div>