lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [bug #20021] conn->sem is only signaled one-way


From: Frédéric Bernon
Subject: [lwip-devel] [bug #20021] conn->sem is only signaled one-way
Date: Wed, 04 Jul 2007 09:29:03 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4

Follow-up Comment #22, bug #20021 (project lwip):

About socket layer: so, netconn_close is not called, we stay on a
netconn_delete: ok, since this call do the job (and a smart linker will
remove netconn_close/do_close from the code).

I see a little problem: netconn_delete is called inside the
sys_sem_wait(socksem)/sys_sem_signal(socksem).

I think it could be a problem because any new socket can't be created during
the close. Comments in lwip_close say it's done because "/* We cannot allow
multiple closes of the same socket. */". Since others API file like lwip_send
can call by another thread in the same time, I think this protection is not
enough, and give more problem.

I propose to change the code like this :

int
lwip_close(int s)
{
  struct lwip_socket *sock;

  LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_close(%d)n", s));

  sock = get_socket(s);
  if (!sock) {
    return -1;
  }

  netconn_delete(sock->conn);

  sys_sem_wait(socksem);
  if (sock->lastdata) {
    netbuf_delete(sock->lastdata);
  }
  sock->lastdata   = NULL;
  sock->lastoffset = 0;
  sock->conn       = NULL;
  sock_set_errno(sock, 0);
  sys_sem_signal(socksem);
  return 0;
}

Comments?


    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?20021>

_______________________________________________
  Message posté via/par Savannah
  http://savannah.nongnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]