defunct commit?

Alan DeKok aland at deployingradius.com
Tue Sep 29 22:35:25 CEST 2009


Alexander Clouter wrote:
> Meant this one:
> 
> http://github.com/alandekok/freeradius-server/commit/1fef8c64bf31668808bb9c2a67c480d9d0a7f2d6

  Ah.  That's deep magic. :)

  In order to avoid mutex locks where possible, the "request" pointers
magically become invalid after a request has been proxied.  Referencing
them after a "proxy_listener->send" call will result in crashes.

  Why?  Thread race conditions.

thread 1) send proxied request packet
thread 2) receive response
thread 2) muck around with request
thread 1) access request
server)   Boom!

  Thread programming isn't hard if you have a twisted mind.

  The alternative is for every "request" to have a mutex associated with
it.  Threads lock the mutex when they're access the request, which
prevents any other thread from mucking with it.  This is also a lot more
expensive, and (IMHO) complicated.

  Alan DeKok.



More information about the Freeradius-Devel mailing list