mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 21:34:07 +08:00
Move poll storage slot from pollfd struct to socket struct
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1286 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
+7
-1
@@ -95,6 +95,12 @@ struct socket
|
||||
#endif
|
||||
#endif
|
||||
void *s_conn; /* Connection: struct uip_conn or uip_udp_conn */
|
||||
|
||||
/* The socket poll logic needs a place to retain state info */
|
||||
|
||||
#if !defined(CONFIG_DISABLE_POLL) && defined(CONFIG_NET_TCP) && CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0
|
||||
FAR void *private;
|
||||
#endif
|
||||
};
|
||||
|
||||
/* This defines a list of sockets indexed by the socket descriptor */
|
||||
@@ -160,7 +166,7 @@ EXTERN int netdev_ioctl(int sockfd, int cmd, struct ifreq *req);
|
||||
|
||||
#ifndef CONFIG_DISABLE_POLL
|
||||
struct pollfd; /* Forward reference -- see poll.h */
|
||||
EXTERN int net_poll(int sockfd, struct pollfd *fds, boolean setup);
|
||||
EXTERN int net_poll(int sockfd, struct pollfd *fds);
|
||||
#endif
|
||||
|
||||
/* netdev-register.c *********************************************************/
|
||||
|
||||
@@ -108,12 +108,6 @@ struct pollfd
|
||||
sem_t *sem; /* Pointer to semaphore used to post output event */
|
||||
pollevent_t events; /* The input event flags */
|
||||
pollevent_t revents; /* The output event flags */
|
||||
|
||||
/* The socket poll logic needs a place to retain state info */
|
||||
|
||||
#if CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET_TCP) && CONFIG_NET_NTCP_READAHEAD_BUFFERS > 0
|
||||
FAR void *private;
|
||||
#endif
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
+13
-21
@@ -162,8 +162,9 @@ static uint16 poll_interrupt(struct uip_driver_s *dev, FAR void *conn,
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_NETPOLL
|
||||
static inline int net_pollsetup(FAR struct uip_conn *conn, struct pollfd *fds)
|
||||
static inline int net_pollsetup(FAR struct socket *psock, struct pollfd *fds)
|
||||
{
|
||||
FAR struct uip_conn *conn = psock->s_conn;
|
||||
FAR struct uip_callback_s *cb;
|
||||
irqstate_t flags;
|
||||
int ret;
|
||||
@@ -171,7 +172,7 @@ static inline int net_pollsetup(FAR struct uip_conn *conn, struct pollfd *fds)
|
||||
/* Sanity check */
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!conn || !fds || fds->private)
|
||||
if (!conn || !fds || psock->private)
|
||||
{
|
||||
ret = -EINVAL;
|
||||
goto errout;
|
||||
@@ -199,7 +200,7 @@ static inline int net_pollsetup(FAR struct uip_conn *conn, struct pollfd *fds)
|
||||
|
||||
/* Save the nps reference in the poll structure for use at teardown as well */
|
||||
|
||||
fds->private = (FAR void *)cb;
|
||||
psock->private = (FAR void *)cb;
|
||||
|
||||
/* Check for read data availability now */
|
||||
|
||||
@@ -238,15 +239,16 @@ errout:
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_NETPOLL
|
||||
static inline int net_pollteardown(FAR struct uip_conn *conn, struct pollfd *fds)
|
||||
static inline int net_pollteardown(FAR struct socket *psock)
|
||||
{
|
||||
FAR struct uip_conn *conn = psock->s_conn;
|
||||
FAR struct uip_callback_s *cb;
|
||||
irqstate_t flags;
|
||||
|
||||
/* Sanity check */
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!conn || !fds || !fds->private)
|
||||
if (!conn || !psock->private)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
@@ -254,7 +256,7 @@ static inline int net_pollteardown(FAR struct uip_conn *conn, struct pollfd *fds
|
||||
|
||||
/* Recover the socket descriptor poll state info from the poll structure */
|
||||
|
||||
cb = (FAR struct uip_callback_s *)fds->private;
|
||||
cb = (FAR struct uip_callback_s *)psock->private;
|
||||
if (cb)
|
||||
{
|
||||
/* Release the callback */
|
||||
@@ -265,7 +267,7 @@ static inline int net_pollteardown(FAR struct uip_conn *conn, struct pollfd *fds
|
||||
|
||||
/* Release the poll/select data slot */
|
||||
|
||||
fds->private = NULL;
|
||||
psock->private = NULL;
|
||||
}
|
||||
|
||||
return OK;
|
||||
@@ -294,7 +296,7 @@ static inline int net_pollteardown(FAR struct uip_conn *conn, struct pollfd *fds
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef CONFIG_DISABLE_POLL
|
||||
int net_poll(int sockfd, struct pollfd *fds, boolean setup)
|
||||
int net_poll(int sockfd, struct pollfd *fds)
|
||||
{
|
||||
#ifndef HAVE_NETPOLL
|
||||
return -ENOSYS;
|
||||
@@ -302,16 +304,6 @@ int net_poll(int sockfd, struct pollfd *fds, boolean setup)
|
||||
FAR struct socket *psock;
|
||||
int ret;
|
||||
|
||||
/* Verify that non-NULL pointers were passed */
|
||||
|
||||
#ifdef CONFIG_DEBUG
|
||||
if (!fds)
|
||||
{
|
||||
ret = -EINVAL;
|
||||
goto errout;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get the underlying socket structure and verify that the sockfd
|
||||
* corresponds to valid, allocated socket
|
||||
*/
|
||||
@@ -334,17 +326,17 @@ int net_poll(int sockfd, struct pollfd *fds, boolean setup)
|
||||
#endif
|
||||
|
||||
/* Check if we are setting up or tearing down the poll */
|
||||
if (setup)
|
||||
if (fds)
|
||||
{
|
||||
/* Perform the TCP/IP poll() setup */
|
||||
|
||||
ret = net_pollsetup((FAR struct uip_conn *)psock->s_conn, fds);
|
||||
ret = net_pollsetup(psock, fds);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Perform the TCP/IP poll() teardown */
|
||||
|
||||
ret = net_pollteardown((FAR struct uip_conn *)psock->s_conn, fds);
|
||||
ret = net_pollteardown(psock);
|
||||
}
|
||||
|
||||
errout:
|
||||
|
||||
Reference in New Issue
Block a user