Hi,
I observed a deadlock in by application because the IP-stack ran out of network buffers.
My solution is to make send non-blocking (see below)
but my question is if there is a better way to configure allocation strategy of network buffers.
Situation:
Assume a thread needs to receive and, from time to time, send UDP multicasts (for some kind of service announcement and discovery).
Most of the time, this thread is blocked in a select() call waiting for incoming network packets.
This select call is configured with a timeout, which, when fired causes the thread to send a UDP multicast by itself.
I observed a situation, where, between the thread being woken-up from select due to timeout and the thread reaching the socket's send call,
a lot of network packets arrive on the same socket (from other devices).
Those incoming network packets seem to consume all available network buffers.
This causes the send-call to block, for it can not allocate a network buffer to send out its message.
This situation causes not only to deadlock this thread but renders the entire IP-stack unusable, for there is not a single network buffer available anymore.
Could my observation be correct? Can this situation occur?
Is there a way to deal with it?
As a work-around, I configured the send to be non-blocking and skip sending out this single message.
Can I limit number of network packets consumed by incoming UDP (multicasts) packets to ensure packets are available for send-calls?
Thanks a lot
Stefan
I observed a deadlock in by application because the IP-stack ran out of network buffers.
My solution is to make send non-blocking (see below)
but my question is if there is a better way to configure allocation strategy of network buffers.
Situation:
Assume a thread needs to receive and, from time to time, send UDP multicasts (for some kind of service announcement and discovery).
Most of the time, this thread is blocked in a select() call waiting for incoming network packets.
This select call is configured with a timeout, which, when fired causes the thread to send a UDP multicast by itself.
I observed a situation, where, between the thread being woken-up from select due to timeout and the thread reaching the socket's send call,
a lot of network packets arrive on the same socket (from other devices).
Those incoming network packets seem to consume all available network buffers.
This causes the send-call to block, for it can not allocate a network buffer to send out its message.
This situation causes not only to deadlock this thread but renders the entire IP-stack unusable, for there is not a single network buffer available anymore.
Could my observation be correct? Can this situation occur?
Is there a way to deal with it?
As a work-around, I configured the send to be non-blocking and skip sending out this single message.
Can I limit number of network packets consumed by incoming UDP (multicasts) packets to ensure packets are available for send-calls?
Thanks a lot
Stefan