[SCM] an open source computer algebra system branch, cleanedupstream, updated. 6125e540ca6d66c307958938a9d53b245507c323

Bernhard R. Link brlink at debian.org
Tue Apr 24 15:54:06 UTC 2012


The following commit has been merged in the cleanedupstream branch:
commit 20571f84663da686888b07efc51eefeb7569cc88
Author: Hans Schoenemann <hannes at mathematik.uni-kl.de>
Date:   Mon Mar 12 15:10:56 2012 +0100

    fix: better (fool-proof) test for semaphores

diff --git a/Singular/semaphore.c b/Singular/semaphore.c
index dba6e08..747452d 100644
--- a/Singular/semaphore.c
+++ b/Singular/semaphore.c
@@ -4,6 +4,7 @@
 #include <sys/stat.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <Singular/mod2.h>
 
 #ifdef HAVE_SIMPLEIPC
 #include "simpleipc.h"
@@ -62,20 +63,20 @@ int sipc_semaphore_exists(int id)
 
 int sipc_semaphore_acquire(int id)
 {
-  if ((id<0) || (id >= SIPC_MAX_SEMAPHORES))  return -1;
+  if ((id<0) || (id >= SIPC_MAX_SEMAPHORES) || (semaphore[id]==NULL))  return -1;
   sem_wait(semaphore[id]);
   return 1;
 }
 
 int sipc_semaphore_try_acquire(int id)
 {
-  if ((id<0) || (id >= SIPC_MAX_SEMAPHORES))  return -1;
+  if ((id<0) || (id >= SIPC_MAX_SEMAPHORES) || (semaphore[id]==NULL))  return -1;
   return !sem_trywait(semaphore[id]);
 }
 
 int sipc_semaphore_release(int id)
 {
-  if ((id<0) || (id >= SIPC_MAX_SEMAPHORES))  return -1;
+  if ((id<0) || (id >= SIPC_MAX_SEMAPHORES) || (semaphore[id]==NULL))  return -1;
   sem_post(semaphore[id]);
   return 1;
 }
@@ -83,7 +84,7 @@ int sipc_semaphore_release(int id)
 int sipc_semaphore_get_value(int id)
 {
   int val;
-  if ((id<0) || (id >= SIPC_MAX_SEMAPHORES))  return -1;
+  if ((id<0) || (id >= SIPC_MAX_SEMAPHORES) || (semaphore[id]==NULL))  return -1;
   sem_getvalue(semaphore[id], &val);
   return val;
 }

-- 
an open source computer algebra system



More information about the debian-science-commits mailing list