- {
- LOCK_FILES();
- /* locate next free slot */
- if (fd == fdstart && fd == fdend)
- fdstart = fdend + 1;
- else if (fd == fdstart)
- {
- fdstart++;
- while (fdstart < fdend &&
- ((info = get_ioinfo_nolock(fdstart))->exflag & EF_CRIT_INIT))
- {
- if (TryEnterCriticalSection(&info->crit))
- {
- if (info->handle == INVALID_HANDLE_VALUE)
- {
- LeaveCriticalSection(&info->crit);
- break;
- }
- LeaveCriticalSection(&info->crit);
- }
- fdstart++;
- }
- }
- /* update last fd in use */
- if (fd >= fdend)
- fdend = fd + 1;
- TRACE("fdstart is %d, fdend is %d\n", fdstart, fdend);
- UNLOCK_FILES();