Hey folks,

I noticed the following problem. When starting a dfb app as a normal
user the _fusion_check_msgmni and _fusion_check_sem functions in
src/core/fusion.c report errors via perror but do not propagate those
errors to the calling init functions. This results in the thread hanging
on a semop and the app not properly exiting. 

Attached is a patch which fixes this, although I have not looked deeply
enough into fusion to be sure that this is the right place for it.

Just wanted to point out the problem.

Cheers,

Till

-- 
mailto: [EMAIL PROTECTED]        
http://www.adam-lilienthal.de/till
? patch
Index: src/core/fusion/fusion.c
===================================================================
RCS file: /cvs/directfb/DirectFB/src/core/fusion/fusion.c,v
retrieving revision 1.1
diff -u -r1.1 fusion.c
--- src/core/fusion/fusion.c    20 Nov 2001 12:59:37 -0000      1.1
+++ src/core/fusion/fusion.c    8 Dec 2001 22:07:41 -0000
@@ -64,7 +64,7 @@
 } Fusion;
 
 
-static void _fusion_check_limits();
+static int _fusion_check_limits();
 
 /*******************
  *  Internal data  *
@@ -88,7 +88,8 @@
   if (fusion)
     return -1;
 
-  _fusion_check_limits();
+  if (_fusion_check_limits()<0)
+     return -1;
 
   /* allocate local Fusion data */
   fusion = (Fusion*)calloc (1, sizeof(Fusion));
@@ -212,7 +213,7 @@
  *  File internal functions  *
  *******************************/
 
-static void _fusion_check_msgmni()
+static int _fusion_check_msgmni()
 {
   int     fd;
   int     msgmni;
@@ -223,7 +224,7 @@
   if (fd < 0)
     {
       perror ("opening /proc/sys/kernel/msgmni");
-      return;
+      return -1;
     }
 
   len = read (fd, buf, 19);
@@ -231,7 +232,7 @@
     {
       perror ("reading /proc/sys/kernel/msgmni");
       close (fd);
-      return;
+      return -1;
     }
 
   if (sscanf (buf, "%d", &msgmni))
@@ -239,19 +240,24 @@
       if (msgmni >= FUSION_MSGMNI)
         {
           close (fd);
-          return;
+          return 1;
         }
     }
 
   snprintf (buf, 19, "%d\n", FUSION_MSGMNI);
 
   if (write (fd, buf, strlen (buf) + 1) < 0)
+  {
     perror ("writing /proc/sys/kernel/msgmni");
+    close (fd);
+    return -1;
+  }
 
   close (fd);
+  return 1;
 }
 
-static void _fusion_check_sem()
+static int _fusion_check_sem()
 {
   int     fd;
   int     per, sys, ops, num;
@@ -262,7 +268,7 @@
   if (fd < 0)
     {
       perror ("opening /proc/sys/kernel/sem");
-      return;
+      return -1;
     }
 
   len = read (fd, buf, 39);
@@ -270,20 +276,20 @@
     {
       perror ("reading /proc/sys/kernel/sem");
       close (fd);
-      return;
+      return -1;
     }
 
   if (sscanf (buf, "%d %d %d %d", &per, &sys, &ops, &num) < 4)
     {
       fprintf (stderr, "could not parse /proc/sys/kernel/sem\n");
       close (fd);
-      return;
+      return -1;
     }
 
   if (num >= FUSION_SEM_ARRAYS)
     {
       close (fd);
-      return;
+      return 1;
     }
   else
     num = FUSION_SEM_ARRAYS;
@@ -291,15 +297,24 @@
   snprintf (buf, 39, "%d %d %d %d\n", per, per * num, ops, num);
 
   if (write (fd, buf, strlen (buf) + 1) < 0)
+  {
     perror ("writing /proc/sys/kernel/sem");
+    close (fd);
+    return -1;
+  }
 
   close (fd);
+  return 1;
 }
 
-static void _fusion_check_limits()
+static int _fusion_check_limits()
 {
-     _fusion_check_msgmni();
-     _fusion_check_sem();
+     if (_fusion_check_msgmni() < 0)
+       return -1;
+     if (_fusion_check_sem() < 0 )
+       return -1;
+
+     return 1;
 }
 
 #endif /* !FUSION_FAKE */

Reply via email to