Svante Signell, le Fri 15 Feb 2013 10:54:44 +0100, a écrit :
> I did understand the code, but maybe the change went wrong. I would
> really appreciate if you could help me to understand what's the problem
> with the new code.
>
> Old code: (cleaning previously allocated ports when one FD is bogus and
> exit out of the loop)
> if (fd < _hurd_dtablesize)
> {
> ...
> if (d[i].io_port != MACH_PORT_NULL)
> continue;
> }
Let's call ii the value of i at this point
> /* If one descriptor is bogus, we fail completely. */
> while (i-- > 0)
> if (d[i].type != 0)
> _hurd_port_free (&d[i].cell->port,
> &d[i].ulink, d[i].io_port);
> break;
So it's ii-1 whose array position gets _hurd_port_free()d. array
position ii does *not* get _hurd_port_free()d, while
> /* If one descriptor is bogus, mark and remove it. */
> if (d[i].io_port == MACH_PORT_NULL)
> {
> _hurd_port_free (&d[i].cell->port,
> &d[i].ulink, d[i].io_port);
> continue; /* Next i */
> }
This does _hurd_port_free() array position ii, even if it is actually
undefined since _hurd_port_get returning MACH_PORT_NULL means it didn't
work (and thus didn't fill the array position).
Samuel