Fix locking for disconnect operation (use post and fetch on the connection's mbox in the two threads like other operations).Make netconn_peer take a pointer to addr instead of pointer to pointer to addr.Addr is a 4 byte struct an IP address so use structure assignment not just pointer assignment when saving the peer.This way the address is really saved :fixes bug #1897
This commit is contained in:
@@ -87,7 +87,7 @@ lwip_accept(int s, struct sockaddr *addr, int *addrlen)
|
||||
{
|
||||
struct lwip_socket *sock;
|
||||
struct netconn *newconn;
|
||||
struct ip_addr *naddr;
|
||||
struct ip_addr naddr;
|
||||
u16_t port;
|
||||
int newsock;
|
||||
|
||||
@@ -101,7 +101,7 @@ lwip_accept(int s, struct sockaddr *addr, int *addrlen)
|
||||
/* get the IP address and port of the remote host */
|
||||
netconn_peer(newconn, &naddr, &port);
|
||||
|
||||
((struct sockaddr_in *)addr)->sin_addr.s_addr = naddr->addr;
|
||||
((struct sockaddr_in *)addr)->sin_addr.s_addr = naddr.addr;
|
||||
((struct sockaddr_in *)addr)->sin_port = port;
|
||||
|
||||
newsock = alloc_socket(newconn);
|
||||
@@ -345,7 +345,7 @@ lwip_sendto(int s, void *data, int size, unsigned int flags,
|
||||
struct sockaddr *to, int tolen)
|
||||
{
|
||||
struct lwip_socket *sock;
|
||||
struct ip_addr remote_addr, *addr;
|
||||
struct ip_addr remote_addr, addr;
|
||||
u16_t remote_port, port;
|
||||
int ret,connected;
|
||||
|
||||
@@ -366,7 +366,7 @@ lwip_sendto(int s, void *data, int size, unsigned int flags,
|
||||
/* reset the remote address and port number
|
||||
of the connection */
|
||||
if (connected)
|
||||
netconn_connect(sock->conn, addr, port);
|
||||
netconn_connect(sock->conn, &addr, port);
|
||||
else
|
||||
netconn_disconnect(sock->conn);
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user