[ENet-discuss] server crashes when calling enet_host_flush() from other thread

aj3423 aj3423 at gmail.com
Fri Jan 22 07:43:46 PST 2016


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..
The code: http://pastebin.com/xmqjn15B

2016-01-22 23:27 GMT+08:00 Lee Salzman <lsalzman at gmail.com>:

> enet_host_service must also be locked. enet_host_service and
> enet_host_flush both will modify sensitive internal bits of the host
> structure AND the peer structure, so unfortunately, all of these must
> be locked at the same time to work.
>
> On Fri, Jan 22, 2016 at 9:38 AM, aj3423 <aj3423 at gmail.com> wrote:
> > Thanks. I tried simply guard all access to 'peer' (the line of
> peer->address
> > is commented out), still not working. My code at:
> > http://pastebin.com/QJhH871p , what do I miss?
> >
> > 2016-01-22 22:05 GMT+08:00 Lee Salzman <lsalzman at gmail.com>:
> >>
> >> You would have to guard all access to ENetPeer as well, including
> >> enet_peer_send and peer->address.
> >>
> >> On Fri, Jan 22, 2016 at 1:27 AM, aj3423 <aj3423 at gmail.com> wrote:
> >> > My server should receive message from client and echo back some
> message,
> >> > but
> >> > in my case building the message packet costs time, so I need to
> create a
> >> > thread to echo message to clients.
> >> >
> >> > I wrote a test to illustrate this problem, the client runs a infinit
> >> > loop,
> >> > sending 2k data to server and receive 2k data. The server crashes
> after
> >> > a
> >> > while, randomly. the code:
> >> >
> >> > server: http://pastebin.com/99kpQgTJ
> >> > client:  http://pastebin.com/wX8jfZgk
> >> >
> >> > It crashes at function enet_host_flush, I tried to use `std::mutex`
> but
> >> > doesn't help. Any idea? Thanks.
> >> >
> >> > My Environment: Win7 32bit + VS2013 + Enet 1.3.13
> >> >
> >> >
> >> > _______________________________________________
> >> > ENet-discuss mailing list
> >> > ENet-discuss at cubik.org
> >> > http://lists.cubik.org/mailman/listinfo/enet-discuss
> >> >
> >> _______________________________________________
> >> ENet-discuss mailing list
> >> ENet-discuss at cubik.org
> >> http://lists.cubik.org/mailman/listinfo/enet-discuss
> >
> >
> >
> > _______________________________________________
> > ENet-discuss mailing list
> > ENet-discuss at cubik.org
> > http://lists.cubik.org/mailman/listinfo/enet-discuss
> >
> _______________________________________________
> ENet-discuss mailing list
> ENet-discuss at cubik.org
> http://lists.cubik.org/mailman/listinfo/enet-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubik.org/pipermail/enet-discuss/attachments/20160122/815aea31/attachment-0001.html>


More information about the ENet-discuss mailing list