Re: [PATCH] Naive approach to HTTP-timeouts
Vjacheslav Chekushin <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Organization | LMT |
| Message-ID | <[email protected]> |
Hi, David.
You start timeout_control_thread in http_init(). It is wrong because this code:
> +static void timeout_control_thread(void *arg) {
> + while (run_status == running) {
> + debug("",0, "timeout_control sleeping");
> + gwthread_sleep(MIN_TIME_OUT);
> + debug("",0, "timeout_control awake");
> + check_timeout();
> + }
> + timeout_control_thread_id = -1;
will be executed when run_status still is "limbo".
David Schmitz wrote:
> Hi Slava,
>
> no need to vote for my patch, because your approach is better.
> IMO the discussion difftime vs. thread is needless, because we should
> aim for scalability, and the thread-approach scales....
> Thus I have merged my client stuff into your thread-stuff and voila, see
> the attached patch. Let me know what you think :)
>
> Regards,
> David
>
> Vjacheslav Chekushin schrieb:
>
>> 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.
>>>
--
Vjacheslav Chekushin mailto:[email protected]
Latvian Mobile Phone Company http://www.lmt.lv