Keep proper track of nsegs counter: sem_free is called for all

allocated semaphores, so it's wrong to increase it conditionally,
  in this case for every over-the-limit semaphore nsegs is decreased
  without being previously increased.

  PR:	kern/123685
  Approved by:	cognet (mentor)
This commit is contained in:
Oleksandr Tymoshenko 2008-06-10 20:55:10 +00:00
parent 3bff0167b9
commit c9688a603b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=179716

View File

@ -221,14 +221,13 @@ sem_create(struct thread *td, const char *name, struct ksem **ksret,
sem_enter(td->td_proc, ret);
*ksret = ret;
mtx_lock(&sem_lock);
if (nsems >= p31b_getcfg(CTL_P1003_1B_SEM_NSEMS_MAX)) {
nsems++;
if (nsems > p31b_getcfg(CTL_P1003_1B_SEM_NSEMS_MAX)) {
sem_leave(td->td_proc, ret);
sem_free(ret);
error = ENFILE;
} else {
nsems++;
} else
error = 0;
}
mtx_unlock(&sem_lock);
return (error);
}