<div class="gmail_quote">On Mon, May 31, 2010 at 10:59 AM, Alexander Larsson <span dir="ltr">&lt;<a href="mailto:alexl@redhat.com">alexl@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im">On Sat, 2010-05-29 at 20:39 +0200, Attila Sukosd wrote:<br>
&gt; Hi guys,<br>
&gt;<br>
&gt; I have spent the last day or two doing some porting so that spicec<br>
&gt; would use kqueue on bsd instead of epoll. I have disabled audio for<br>
&gt; now, but once the current version works as it should, I will do a port<br>
&gt; to CoreAudio aswell.<br>
<br>
</div>For the client, i&#39;m not sure using kqueue is the best way. It seems like<br>
a better idea to just move both linux and bsd to use regular poll. There<br>
is no way we&#39;ll have enough file descriptors on the client side to get<br>
any kind of scaling problems that epoll/kqueue are meant to solve, so we<br>
just get portability complexity for no gain.<br>
<br>
So, a better way forward is probably to drop both epoll and kqueue and<br>
switch to a normal poll or select.<br>
<div class="im"><br>
&gt; I now have a working version, however I had to disable the shm stuff<br>
&gt; in order to get it to work since I have been getting the following<br>
&gt; error:<br>
&gt;<br>
&gt; 1275161751 ERROR spice : x_error_handler: x error on display :0.0<br>
&gt; error (code 10)  BadAccess (attempt to access private resource denied)<br>
&gt; major 139 minor 1 request 139<br>
&gt;<br>
&gt; Since the major code (139) is outside the 125? which is the standard<br>
&gt; codes in X, I guessed that 139 is an Xorg extension,<br>
&gt; $ xdpyinfo -display :0 -queryExtensions |grep 139<br>
&gt;     MIT-SHM  (opcode: 139, base event: 76, base error: 145)<br>
&gt;<br>
&gt; So my wild guess is that it tries to write outside the available<br>
&gt; buffer?<br>
&gt; Any help would be much appriciated!<br>
<br>
</div>No. A BadAccess is an xserver message is an error return from an X call,<br>
saying some argument was wrong in some way related to access rights. My<br>
immediate guess is that some access rights on the shared memory segment<br>
was wrong.<br>
<br>
To debug this, add a call to<br>
    XSynchronize (x_display, True);<br>
<br>
in Platform::init() in client/x11/platform.cpp<br>
<br>
Then you&#39;ll get the error on the actual X message that caused it and you<br>
can figure out what happens in the debugger.<br>
<font color="#888888"><br>
<br>
<br>
--<br>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=<br>
 Alexander Larsson                                            Red Hat, Inc<br>
       <a href="mailto:alexl@redhat.com">alexl@redhat.com</a>            <a href="mailto:alexander.larsson@gmail.com">alexander.larsson@gmail.com</a><br>
He&#39;s a one-legged day-dreaming barbarian on the run. She&#39;s an artistic psychic<br>
bodyguard with an incredible destiny. They fight crime!<br>
<br>
</font></blockquote></div><br><br>Hi Alex,<br><br>Thanks for your help! It turns out the issue was that shmctl(shminfo-&gt;shmid, IPC_RMID, NULL) was called before XShmAttach() and apparently thats what cause the issue. I moved it under XShmAttach in red_pixmap_cairo.cpp and now it works almost perfectly.<br>
<br>Also, the kqueue implementation in OS X 10.6 seem to have been broken, so I went with your suggestion and reimplemented the event handler using select(). One thing I noticed though was that the epoll implementation watched the fds for both read and write (add_to_poll()), but since it is edge triggered, it only fires once per change, but my select() implementation is level triggered, which meant it would never block and use up 100% CPU (for example monitoring a File fd, it always triggers). After playing a bit around with it, i decided to drop watching write for fds all together, and the client seem to work fine. Is there a need to check it or am I safe with monitoring only reads?<br>
<br>Now on to the audio, I have been implementing audio using CoreAudio Framework for OS X (another idea could be OpenAL which is also cross-platform?),  which pulls in a lot of extra headers, including MacTypes.h which unfortunately defines a &quot;Rect&quot; and &quot;Point&quot; struct which causes issues with the definitions inside common/draw.h. I can hack around it, but its not very nice, or I could rename the ones in spice, but that would break any compatibility with my patches to the current upstream code. <br>
<br>And another thing I have noticed was that sometimes when I try to play back video (local or youtube), the video picture does not get updated (however I see that the event handler is handling all the incoming frames) and sometimes a square in the middle of the video gets updated but not the rest. And, if I scroll the page or move the window while watching the video, it refreshes fine. So I have no idea what goes on there :)<br>
<br><br>Anyway, otherwise it seem to perform pretty well.<br><br>Best Regards,<br><br>Attila<br><br>