Hi, David.
Yes, I have thought about exactly the same:
either difftime+last_check or thread-switch.
I didn't compare the efficient of thease methods.
I'v made thread because switch occur 1 time at minute (or any configured
timeout) but difftime can occur many times in minute (unpredictable, depends
on load).
PS. I'm not running sms gateway part of kannel,
so I have not load on http server,
so I'm ready to vote for your difftime+last_check solution ;).

David Schmitz wrote:
Hi Slava (and others),

yeah, you have got a point there...
But this can be avoided by using something like:

last_check = time(NULL);
while....
....
now = time(NULL);
       if ((ret == 0) || (difftime(now, last_check) >= MIN_TIME_OUT)) {
           check_timeout();
           last_check = time(NULL);
       }
....

It depends on whether you prefer a contex-switch (because of a thread) to the calculation of a difftime.

Regards,
David

Vjacheslav Chekushin schrieb:

Hi, David.

Ok. Let's suppose that we get realy high load on kannel http server.
So we get, let's say, ~5 new connection in second.
Threrefore we will check for timeouts ~5 times in second. I think it is not
efficient way.
That why I have created the thread to deal with it.
You must to choose between wasted thread's resources and perfomance
degradation. My choice was - thread's resources.
You can make your own choice.


David Schmitz wrote:

Hi Slava,

argh, correct. An IMO easy solution is to call check_timeout even if the recent poll did not timeout, as in:
[snip]
if ((ret = gwthread_poll(tab, n, MIN_TIME_OUT)) < 1) {
switch(ret) {
case 0: /* timeout */
break;
case -1: /* error */
if (errno != EINTR) /* a signal was caught during poll() function */
warning(0, "HTTP: gwthread_poll failed.");
continue;
break;
default: /* should not happen */
panic(0, "This is not supposed to happen!");
}
}
check_timeout();
[snap]
That should take care of loaded environments...


Regards,
David

Vjacheslav Chekushin schrieb:

Hi, David.

If I understand correctly then check_timeouts() will be called only if no any new connection to kannel http server for MIN_TIME_OUT time.
So for busy enviroment this check will be quite undeterminate and can
be not called for hours. Isn't it?


David Schmitz wrote:

Hi again,

attached is the new patch for HTTP-timeouts. I have included the work of Slava wrt. server-timeouts, but modified it such that no new thread is needed. Another new thing is the purging of active clients upon port-removal, as suggested by Alex.

Please, try it out and share your comments :)

Best regards,
David










--
Vjacheslav Chekushin                                mailto:[EMAIL PROTECTED]
Latvian Mobile Phone Company                        http://www.lmt.lv




Reply via email to