Missing recv_timeout initialize in accept_function. Minor style fix (indent, mbox checking...)

This commit is contained in:
fbernon 2007-03-28 18:21:24 +00:00
parent 913a99dd35
commit 9ec08fa76a
2 changed files with 54 additions and 62 deletions

View File

@ -186,7 +186,6 @@ err_tcp(void *arg, err_t err)
conn->pcb.tcp = NULL;
conn->err = err;
if (conn->recvmbox != SYS_MBOX_NULL) {
/* Register event with callback */
@ -224,7 +223,6 @@ setup_tcp(struct netconn *conn)
static err_t
accept_function(void *arg, struct tcp_pcb *newpcb, err_t err)
{
sys_mbox_t mbox;
struct netconn *newconn;
struct netconn *conn;
@ -234,7 +232,6 @@ accept_function(void *arg, struct tcp_pcb *newpcb, err_t err)
#endif /* TCP_DEBUG */
#endif /* API_MSG_DEBUG */
conn = (struct netconn *)arg;
mbox = conn->acceptmbox;
newconn = memp_malloc(MEMP_NETCONN);
if (newconn == NULL) {
return ERR_MEM;
@ -252,8 +249,8 @@ accept_function(void *arg, struct tcp_pcb *newpcb, err_t err)
}
newconn->sem = sys_sem_new(0);
if (newconn->sem == SYS_SEM_NULL) {
sys_mbox_free(newconn->recvmbox);
sys_mbox_free(newconn->mbox);
sys_mbox_free(newconn->recvmbox);
memp_free(MEMP_NETCONN, newconn);
return ERR_MEM;
}
@ -272,8 +269,11 @@ accept_function(void *arg, struct tcp_pcb *newpcb, err_t err)
newconn->callback = conn->callback;
newconn->socket = -1;
newconn->recv_avail = 0;
#if LWIP_SO_RCVTIMEO
newconn->recv_timeout = 0;
#endif /* LWIP_SO_RCVTIMEO */
sys_mbox_post(mbox, newconn);
sys_mbox_post( conn->acceptmbox, newconn);
return ERR_OK;
}
#endif /* LWIP_TCP */
@ -339,7 +339,6 @@ do_newconn(struct api_msg_msg *msg)
#endif
}
sys_mbox_post(msg->conn->mbox, NULL);
}
@ -618,8 +617,7 @@ do_listen(struct api_msg_msg *msg)
msg->conn->err = ERR_MEM;
} else {
if (msg->conn->acceptmbox == SYS_MBOX_NULL) {
msg->conn->acceptmbox = sys_mbox_new();
if (msg->conn->acceptmbox == SYS_MBOX_NULL) {
if ((msg->conn->acceptmbox = sys_mbox_new()) == SYS_MBOX_NULL) {
msg->conn->err = ERR_MEM;
break;
}
@ -748,8 +746,7 @@ do_close(struct api_msg_msg *msg)
case NETCONN_TCP:
if (msg->conn->pcb.tcp->state == LISTEN) {
err = tcp_close(msg->conn->pcb.tcp);
}
else if (msg->conn->pcb.tcp->state == CLOSE_WAIT) {
} else if (msg->conn->pcb.tcp->state == CLOSE_WAIT) {
err = tcp_output(msg->conn->pcb.tcp);
}
msg->conn->err = err;

View File

@ -53,8 +53,7 @@ struct lwip_socket {
int err;
};
struct lwip_select_cb
{
struct lwip_select_cb {
struct lwip_select_cb *next;
fd_set *readset;
fd_set *writeset;
@ -362,8 +361,7 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
buf = sock->lastdata;
} else {
/* If this is non-blocking call, then check first */
if (((flags & MSG_DONTWAIT) || (sock->flags & O_NONBLOCK)) && !sock->rcvevent)
{
if (((flags & MSG_DONTWAIT) || (sock->flags & O_NONBLOCK)) && !sock->rcvevent) {
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_recvfrom(%d): returning EWOULDBLOCK\n", s));
sock_set_errno(sock, EWOULDBLOCK);
return -1;
@ -440,7 +438,6 @@ lwip_recvfrom(int s, void *mem, int len, unsigned int flags,
netbuf_delete(buf);
}
sock_set_errno(sock, 0);
return copylen;
}
@ -1064,7 +1061,6 @@ int lwip_getsockopt (int s, int level, int optname, void *optval, socklen_t *opt
}
/* Now do the actual option processing */
switch(level) {
@ -1245,8 +1241,8 @@ int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_
}
case IP_ADD_MEMBERSHIP:
case IP_DROP_MEMBERSHIP:
{ if( optlen < sizeof(struct ip_mreq) )
{ err = EINVAL;
{ if( optlen < sizeof(struct ip_mreq) ) {
err = EINVAL;
}
break;
}
@ -1296,7 +1292,6 @@ int lwip_setsockopt (int s, int level, int optname, const void *optval, socklen_
}
/* Now do the actual option processing */
switch(level) {