Consulting wrong list to see if socket is listening for a connection
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2069 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
5b5b170f0f
commit
01ba4b6d05
@ -63,6 +63,43 @@ static struct uip_conn *uip_listenports[CONFIG_NET_MAX_LISTENPORTS];
|
|||||||
* Private Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Function: uip_findlistener
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Return the connection listener for connections on this port (if any)
|
||||||
|
*
|
||||||
|
* Assumptions:
|
||||||
|
* Called at interrupt level
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
struct uip_conn *uip_findlistener(uint16 portno)
|
||||||
|
{
|
||||||
|
int ndx;
|
||||||
|
|
||||||
|
/* Examine each connection structure in each slot of the listener list */
|
||||||
|
|
||||||
|
for (ndx = 0; ndx < CONFIG_NET_MAX_LISTENPORTS; ndx++)
|
||||||
|
{
|
||||||
|
/* Is this slot assigned? If so, does the connection have the same
|
||||||
|
* local port number?
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct uip_conn *conn = uip_listenports[ndx];
|
||||||
|
if (conn && conn->lport == portno)
|
||||||
|
{
|
||||||
|
/* Yes.. we found a listener on this port */
|
||||||
|
|
||||||
|
return conn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No listener for this port */
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@ -193,28 +230,7 @@ int uip_listen(struct uip_conn *conn)
|
|||||||
|
|
||||||
boolean uip_islistener(uint16 portno)
|
boolean uip_islistener(uint16 portno)
|
||||||
{
|
{
|
||||||
int ndx;
|
return uip_findlistener(portno) != NULL;
|
||||||
|
|
||||||
/* Examine each connection structure in each slot of the listener list */
|
|
||||||
|
|
||||||
for (ndx = 0; ndx < CONFIG_NET_MAX_LISTENPORTS; ndx++)
|
|
||||||
{
|
|
||||||
/* Is this slot assigned? If so, does the connection have the same
|
|
||||||
* local port number?
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct uip_conn *conn = uip_listenports[ndx];
|
|
||||||
if (conn && conn->lport == portno)
|
|
||||||
{
|
|
||||||
/* Yes.. we found a listener on this port */
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* No listener for this port */
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -238,7 +254,7 @@ int uip_accept(struct uip_driver_s *dev, struct uip_conn *conn, uint16 portno)
|
|||||||
* connection.
|
* connection.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
listener = uip_tcplistener(portno);
|
listener = uip_findlistener(portno);
|
||||||
if (listener)
|
if (listener)
|
||||||
{
|
{
|
||||||
/* Yes, there is a listener. Is it accepting connections now? */
|
/* Yes, there is a listener. Is it accepting connections now? */
|
||||||
|
@ -238,7 +238,7 @@ int uip_backlogadd(FAR struct uip_conn *conn, FAR struct uip_conn *blconn)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
bls = conn->backlog;
|
bls = conn->backlog;
|
||||||
if (conn->backlog && blconn)
|
if (bls && blconn)
|
||||||
{
|
{
|
||||||
/* Allocate a container for the connection from the free list */
|
/* Allocate a container for the connection from the free list */
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user