Re: [PATCH] Naive approach to HTTP-timeouts

"David Schmitz" <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
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
>>>>
>>>
>>
>>
>
>


-- 

Mit freundlichen Gruessen/Best regards

David Schmitz
Softwareentwicklung

-----------------------------------------------------------------
Wapme Systems AG
Vogelsanger Weg 80
40470 Düsseldorf

Tel.:  + 49 -211-7 48 45 - 2708
Fax:  + 49 -211-80-6-06-2801

E-Mail:   [email protected]
Internet: http://www.wapme-systems.de
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.