lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [bug #19167] tcp timeout handler can cause crash being invo


From: Dmitry Potapov
Subject: [lwip-devel] [bug #19167] tcp timeout handler can cause crash being invoked by sys_sem_wait()
Date: Wed, 28 Feb 2007 11:45:20 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.10) Gecko/20070216 Firefox/1.5.0.10

Follow-up Comment #4, bug #19167 (project lwip):

Using of timestamps instead of time-delta does NOT require 64-bit.

/* timestamp_t value in milliseconds taken by module 2^32,
   so after 0xFFFFFFFF should be 0. */
typedef u32_t timestamp_t;
typedef s32_t timediff_t;

Now we need to define TIMESTAMP_DIFF macro that calculates the difference
between two timestamp_t values taken into account overflow and return it as
timediff_t, and TIMESTAMP_ADD which adds some timeout value to the given
timestamp.

Practically all modern processors use two's complement to represent signed
integers. So you can define them as

#define TIMESTAMP_DIFF(t1, t2) ((timediff_t)((t1) - (t2)))
#define TIMESTAMP_ADD(timestamp, timeout) \
 ((timestamp_t)((timestamp)+(timeout)))

then you can write

timediff_t timeout = TIMESTAMP_DIFF(timeouts->next->expires,
sys_time_now());
if (timeout > 0)
        sys_arch_mbox_fetch(mbox, msg, timeout)
else
        timeout_handler();


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?19167>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]