Liu dejun <dejun.liu@gmail.com> wrote:
why not restricted the conditions ,and add the if condition to just if the total threads exceed the max threads,if so just add to the thread queue and return ,if not do the spawn thread function to spawn a new thread .and do this ,it will reduce many functioin calls is this function,at the same time it will reduce too much time when too many packets arrived.
I'm not sure I understand what you mean by this. Could you send a patch implementing what you suggest? I *think* you mean to always spawn a new thread, until "max_threads" is hit. If that is what you mean, then the current design is intended to *avoid* spawning new threads as much as possible. The overhead of spawning a new thread is much, much, more than a function call. So the server does not spawn a new thread unless it absolutely has to. Alan DeKok.