mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-12-28 09:19:53 +00:00
Reduced the time SYS_ARCH_PROTECT is protecting the socket array
This commit is contained in:
parent
90bed0c5ac
commit
b0b4290c29
@ -223,15 +223,17 @@ alloc_socket(struct netconn *newconn, int accepted)
|
||||
SYS_ARCH_PROTECT(lev);
|
||||
if (!sockets[i].conn) {
|
||||
sockets[i].conn = newconn;
|
||||
/* The socket is not yet known to anyone, so no need to protect
|
||||
after having marked it as used. */
|
||||
SYS_ARCH_UNPROTECT(lev);
|
||||
sockets[i].lastdata = NULL;
|
||||
sockets[i].lastoffset = 0;
|
||||
sockets[i].rcvevent = 0;
|
||||
/* TCP sendbuf is empty, but not connected yet, so not yet writable
|
||||
/* TCP sendbuf is empty, but the socket is not yet writable until connected
|
||||
* (unless it has been created by accept()). */
|
||||
sockets[i].sendevent = (newconn->type == NETCONN_TCP ? (accepted != 0) : 1);
|
||||
sockets[i].errevent = 0;
|
||||
sockets[i].err = 0;
|
||||
SYS_ARCH_UNPROTECT(lev);
|
||||
return i;
|
||||
}
|
||||
SYS_ARCH_UNPROTECT(lev);
|
||||
@ -239,7 +241,7 @@ alloc_socket(struct netconn *newconn, int accepted)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/** Free a socket. The socket's netbuf must have been
|
||||
/** Free a socket. The socket's netconn must have been
|
||||
* delete before!
|
||||
*
|
||||
* @param sock the socket to free
|
||||
@ -250,13 +252,14 @@ free_socket(struct lwip_socket *sock)
|
||||
struct netbuf *lastdata;
|
||||
SYS_ARCH_DECL_PROTECT(lev);
|
||||
|
||||
/* Protect socket array */
|
||||
SYS_ARCH_PROTECT(lev);
|
||||
lastdata = sock->lastdata;
|
||||
sock->lastdata = NULL;
|
||||
sock->lastoffset = 0;
|
||||
sock->conn = NULL;
|
||||
sock->err = 0;
|
||||
|
||||
/* Protect socket array */
|
||||
SYS_ARCH_PROTECT(lev);
|
||||
sock->conn = NULL;
|
||||
SYS_ARCH_UNPROTECT(lev);
|
||||
|
||||
if (lastdata != NULL) {
|
||||
@ -335,9 +338,8 @@ lwip_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
|
||||
return -1;
|
||||
}
|
||||
LWIP_ASSERT("invalid socket index", (newsock >= 0) && (newsock < NUM_SOCKETS));
|
||||
newconn->callback = event_callback;
|
||||
LWIP_ASSERT("newconn->callback == event_callback", newconn->callback == event_callback);
|
||||
nsock = &sockets[newsock];
|
||||
LWIP_ASSERT("invalid socket pointer", nsock != NULL);
|
||||
|
||||
/* See event_callback: If data comes in right away after an accept, even
|
||||
* though the server task might not have created a new socket yet.
|
||||
|
Loading…
Reference in New Issue
Block a user