* sockets.h, sockets.c: Move socket initialization to new

lwip_socket_init() function.
This commit is contained in:
jifl 2007-02-26 20:01:04 +00:00
parent de665f7cf9
commit 1d22294974
3 changed files with 14 additions and 10 deletions

View File

@ -27,6 +27,12 @@ HISTORY
++ New features:
2007-02-26 Jonathan Larmour (based on patch from Simon Goldschmidt)
* sockets.h, sockets.c: Move socket initialization to new
lwip_socket_init() function.
NOTE: this changes the API with ports. Ports will have to be
updated to call lwip_socket_init() now.
2007-02-26 Jonathan Larmour (based on patch from Simon Goldschmidt)
* api_lib.c: Use memcpy in netbuf_copy_partial.

View File

@ -106,6 +106,13 @@ static int err_to_errno_table[11] = {
} while (0)
void
lwip_socket_init(void)
{
socksem = sys_sem_new(1);
selectsem = sys_sem_new(1);
}
static struct lwip_socket *
get_socket(int s)
{
@ -133,9 +140,6 @@ alloc_socket(struct netconn *newconn)
{
int i;
if (!socksem)
socksem = sys_sem_new(1);
/* Protect socket array */
sys_sem_wait(socksem);
@ -252,8 +256,6 @@ lwip_close(int s)
struct lwip_socket *sock;
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_close(%d)\n", s));
if (!socksem)
socksem = sys_sem_new(1);
/* We cannot allow multiple closes of the same socket. */
sys_sem_wait(socksem);
@ -675,8 +677,6 @@ lwip_select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
select_cb.sem_signalled = 0;
/* Protect ourselves searching through the list */
if (!selectsem)
selectsem = sys_sem_new(1);
sys_sem_wait(selectsem);
if (readset)
@ -831,9 +831,6 @@ event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len)
else
return;
if (!selectsem)
selectsem = sys_sem_new(1);
sys_sem_wait(selectsem);
/* Set event as required */
switch (evt)

View File

@ -222,6 +222,7 @@ struct linger {
#endif
void lwip_socket_init(void);
int lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen);
int lwip_bind(int s, struct sockaddr *name, socklen_t namelen);
int lwip_shutdown(int s, int how);