[patch #5959] Implement SO_RCVTIMEO for accept and recv (on TCP netconn)

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[patch #5959] Implement SO_RCVTIMEO for accept and recv (on TCP netconn)

Ondrej Lufinka

URL:
  <http://savannah.nongnu.org/patch/?5959>

                 Summary: Implement SO_RCVTIMEO for accept and recv (on TCP
netconn)
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: fbernon
            Submitted on: mercredi 23.05.2007 à 12:32
                Category: None
                Priority: 3 - Low
                  Status: None
                 Privacy: Public
             Assigned to: fbernon
        Originator Email:
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

It's a very simple patch I propose :

for netconn_accept, in api_lib.c :

#if LWIP_SO_RCVTIMEO
    if (sys_arch_mbox_fetch(conn->acceptmbox, (void *)&newconn,
conn->recv_timeout)==SYS_ARCH_TIMEOUT) {
      newconn = NULL;
    }
#else
    sys_arch_mbox_fetch(conn->acceptmbox, (void *)&newconn, 0);
#endif /* LWIP_SO_RCVTIMEO*/

for netconn_recv, it the same thing.

No more code for users using LWIP_SO_RCVTIMEO=0, a little bit for users using
LWIP_SO_RCVTIMEO=1 (+2 tests and +2 set).

For accept, it's very useful when you want to stop some services (some others
stack allows to do a "close" on a socket currently use in a "accept", but
don't try with lwIP ;) )






    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?5959>

_______________________________________________
  Message posté via/par Savannah
  http://savannah.nongnu.org/



_______________________________________________
lwip-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[patch #5959] Implement SO_RCVTIMEO for accept and recv (on TCP netconn)

Ondrej Lufinka

Follow-up Comment #1, patch #5959 (project lwip):

Looks fine to me.

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?5959>

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



_______________________________________________
lwip-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[patch #5959] Implement SO_RCVTIMEO for accept and recv (on TCP netconn)

Ondrej Lufinka

Follow-up Comment #2, patch #5959 (project lwip):

Ok, I check in. Just a tips about the fact to call or not the conn->callback
with NETCONN_EVT_RCVMINUS, I'm not 100% sure of the thing to do, but I have
try to respect the current instruction flow, but tell me.

It is also possible to get a "simpler" code with #if/#else/#endif in the
code, with a macro like this at the beginning of api_lib.c:

#if LWIP_SO_RCVTIMEO
#define CONN_RCVTIMEO(conn) (conn->recv_timeout)
#else
#define CONN_RCVTIMEO(conn) (0)
#endif /* LWIP_SO_RCVTIMEO*/

And further in the code always let the test like this:

if (sys_arch_mbox_fetch(conn->recvmbox, (void *)&p,
CONN_RCVTIMEO(conn))==SYS_ARCH_TIMEOUT) {
  p = NULL;
}

It better to get a code more lisible, but add a test and a set.

Tell me if you prefer...



    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?5959>

_______________________________________________
  Message posté via/par Savannah
  http://savannah.nongnu.org/



_______________________________________________
lwip-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[patch #5959] Implement SO_RCVTIMEO for accept and recv (on TCP netconn)

Ondrej Lufinka

Follow-up Comment #3, patch #5959 (project lwip):

Since you asked for a comment.... I don't think the code is made sufficiently
more complex that this "simpler" is worth the test and set. It looks neater,
but the version without the macro is still easy to understand and maintain.
In fact, since someone would have to look up what macro does, I'm not sure it
would save the complexity anyway.


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?5959>

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



_______________________________________________
lwip-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-devel
Reply | Threaded
Open this post in threaded view
|

[patch #5959] Implement SO_RCVTIMEO for accept and recv (on TCP netconn)

Ondrej Lufinka

Update of patch #5959 (project lwip):

                  Status:                    None => Done                  
             Open/Closed:                    Open => Closed                

    _______________________________________________________

Follow-up Comment #4:

So, if I understand, like it's check in, it's good for you?

Ok, so, I close that... (reopen if I'm wrong...)

    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/patch/?5959>

_______________________________________________
  Message posté via/par Savannah
  http://savannah.nongnu.org/



_______________________________________________
lwip-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/lwip-devel