libnetworking: Fix close of active sockets

Send a special event to notify tasks waiting for a socket state change
in case this socket gets closed.  This prevents a use after free.

Close #785.
This commit is contained in:
Sebastian Huber
2015-01-15 14:13:19 +01:00
parent 51c88e8bf4
commit f87ede57a2
8 changed files with 286 additions and 75 deletions

View File

@@ -167,7 +167,10 @@ static rtems_task serverTask(rtems_task_argument arg)
addrlen = sizeof farAddr;
s1 = accept(s, (struct sockaddr *)&farAddr, &addrlen);
if (s1 < 0)
rtems_panic("Can't accept connection: %s", strerror(errno));
if (errno == ENXIO)
rtems_task_delete(RTEMS_SELF);
else
rtems_panic("Can't accept connection: %s", strerror(errno));
else
printf("ACCEPTED:%lX\n", ntohl(farAddr.sin_addr.s_addr));
spawnTask(workerTask, myPriority, s1);