[mythtv] PATCH: small shm problem

James Knight foom at fuhm.net
Sat Jun 7 21:42:27 EDT 2003


This patch makes sure that the shared memory is always deallocated, 
even if myth crashes while playing video, by marking the shm segment as 
to-be-destroyed right after the memory is first attached. Thus, when 
the process exits the memory always will be freed.

You may want to check if your box has a bunch of wasted shm segments on 
it from prior myth crashes with the command "ipcs -a". This will go 
away if you reboot, or via the "ipcrm" command. I had a bunch.

James

Index: XJ.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythtv/libs/libmythtv/XJ.cpp,v
retrieving revision 1.59
diff -u -p -r1.59 XJ.cpp
--- XJ.cpp      3 Jun 2003 03:30:59 -0000       1.59
+++ XJ.cpp      7 Jun 2003 22:20:46 -0000
@@ -410,6 +410,9 @@ bool XvVideoOutput::Init(int width, int

              image->data = (data->XJ_SHMInfo)[i].shmaddr =
                               (char 
*)shmat((data->XJ_SHMInfo)[i].shmid, 0, 0);
+                       // mark for delete immediately - it won't be 
removed until detach
+                       shmctl((data->XJ_SHMInfo)[i].shmid, IPC_RMID, 
0);
+
              data->buffers[(unsigned char *)image->data] = image;
              out_buffers[i] = (unsigned char *)image->data;

@@ -440,6 +443,9 @@ bool XvVideoOutput::Init(int width, int

              image->data = (data->XJ_SHMInfo)[i].shmaddr =
                               (char 
*)shmat((data->XJ_SHMInfo)[i].shmid, 0, 0);
+                       // mark for delete immediately - it won't be 
removed until detach
+                       shmctl((data->XJ_SHMInfo)[i].shmid, IPC_RMID, 
0);
+
              data->xbuffers[(unsigned char *)image->data] = image;
              out_buffers[i] = (unsigned char *)image->data;

@@ -509,8 +515,6 @@ void XvVideoOutput::Exit(void)
                  XShmDetach(data->XJ_disp, &(data->XJ_SHMInfo)[i]);
                  if ((data->XJ_SHMInfo)[i].shmaddr)
                      shmdt((data->XJ_SHMInfo)[i].shmaddr);
-                if ((data->XJ_SHMInfo)[i].shmid > 0)
-                    shmctl((data->XJ_SHMInfo)[i].shmid, IPC_RMID, 0);
                  XFree(iter->second);
              }



More information about the mythtv-dev mailing list