Date: Thu, 7 Jan 2010 04:15:49 +0000 (UTC) From: David Xu <davidxu@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r201715 - in head: lib/libc/gen tools/regression/posixsem2 Message-ID: <201001070415.o074Fnvw037680@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: davidxu Date: Thu Jan 7 04:15:49 2010 New Revision: 201715 URL: http://svn.freebsd.org/changeset/base/201715 Log: Don't forget to use fourth argument if O_CREAT is set in argument oflag. The fourth specifies initial value for the semaphore. Modified: head/lib/libc/gen/sem_new.c head/tools/regression/posixsem2/semtest.c Modified: head/lib/libc/gen/sem_new.c ============================================================================== --- head/lib/libc/gen/sem_new.c Thu Jan 7 02:25:19 2010 (r201714) +++ head/lib/libc/gen/sem_new.c Thu Jan 7 04:15:49 2010 (r201715) @@ -143,6 +143,7 @@ _sem_open(const char *name, int flags, . struct sem_nameinfo *ni = NULL; sem_t *sem = NULL; int fd = -1, mode, len; + int value = 0; if (name[0] != '/') { errno = EINVAL; @@ -170,6 +171,7 @@ _sem_open(const char *name, int flags, . if (flags & O_CREAT) { va_start(ap, flags); mode = va_arg(ap, int); + value = va_arg(ap, int); va_end(ap); } @@ -203,7 +205,7 @@ _sem_open(const char *name, int flags, . tmp._magic = SEM_MAGIC; tmp._kern._has_waiters = 0; - tmp._kern._count = 0; + tmp._kern._count = value; tmp._kern._flags = USYNC_PROCESS_SHARED | SEM_NAMED; if (_write(fd, &tmp, sizeof(tmp)) != sizeof(tmp)) { flock(fd, LOCK_UN); Modified: head/tools/regression/posixsem2/semtest.c ============================================================================== --- head/tools/regression/posixsem2/semtest.c Thu Jan 7 02:25:19 2010 (r201714) +++ head/tools/regression/posixsem2/semtest.c Thu Jan 7 04:15:49 2010 (r201715) @@ -58,10 +58,10 @@ test_named(void) printf("testing named process-shared semaphore\n"); sem_unlink(SEM_NAME); - s = sem_open(SEM_NAME, O_CREAT, 0777); + s = sem_open(SEM_NAME, O_CREAT, 0777, 0); if (s == SEM_FAILED) err(1, "sem_open failed"); - s2 = sem_open(SEM_NAME, O_CREAT, 0777); + s2 = sem_open(SEM_NAME, O_CREAT, 0777, 0); if (s2 == SEM_FAILED) err(2, "second sem_open call failed"); if (s != s2)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001070415.o074Fnvw037680>