![thorpej](/assets/img/avatar_default.png)
fdexpand(). The former will return ENOSPC if there is not space in the current filedesc table. The latter performs the expansion of the filedesc table. This means that fdalloc() won't ever block, and it gives callers an opportunity to clean up before the potentially-blocking fdexpand() call. Update all fdalloc() callers to deal with the need-to-fdexpand() case. Rewrite unp_externalize() to use fdalloc() and fdexpand() in a safe way, using an algorithm suggested by Bill Sommerfeld: - Use a temporary array of integers to hold the new filedesc table indexes. This allows us to repeat the loop if necessary. - Loop through the array of file *'s, assigning them to filedesc table slots. If fdalloc() indicates expansion is necessary, undo the assignments we've done so far, expand, and retry the whole process. - Once all file *'s have been assigned to slots, update the f_msgcount and unp_rights counters. - Right before we return, copy the temporary integer array to the message buffer, and trim the length as before. Note that once locking is added to the filedesc array, this entire operation will be `atomic', in that the lock will be held while file *'s are assigned to embryonic table slots, thus preventing anything else from using them.
…
…
…
…
…
…
…
…
…
…
…
…
…
Description
No description provided
Languages
C
85.3%
Roff
7.2%
Assembly
3.1%
Shell
1.7%
Makefile
1.2%
Other
0.9%