File x11vnc-thread-auth.diff of Package x11vnc
--- x11vnc/screen.c.orig 2009-12-21 05:58:10.000000000 +0100
+++ x11vnc/screen.c 2009-12-21 23:17:28.000000000 +0100
@@ -4201,6 +4201,37 @@
return msec;
}
+/*
+ * Terrible hack for the multithreaded x11vnc ...
+ * But we get the client confused if we start sending stuff in our
+ * main loop prior to it being initialized properly. So wait.
+ * It's polling :-(
+ */
+static void _mt_wait_for_client() {
+ time_t start = time(0);
+ while (!client_count) {
+ if (first_conn_timeout && time(0) - start > first_conn_timeout)
+ return;
+ usleep(100*1000);
+ }
+ while (1) {
+ rfbClientIteratorPtr iter;
+ rfbClientPtr cl;
+ iter = rfbGetClientIterator(screen);
+ while( (cl = rfbClientIteratorNext(iter)) ) {
+ //ClientData *cd = (ClientData *) cl->clientData;
+ if (cl->state == RFB_NORMAL) {
+ rfbReleaseClientIterator(iter);
+ return;
+ }
+ }
+ rfbReleaseClientIterator(iter);
+ if (first_conn_timeout && time(0) - start > first_conn_timeout)
+ return;
+ usleep(100*1000);
+ }
+}
+
/*
* main x11vnc loop: polls, checks for events, iterate libvncserver, etc.
*/
@@ -4212,6 +4243,7 @@
if (use_threads && !started_rfbRunEventLoop) {
started_rfbRunEventLoop = 1;
rfbRunEventLoop(screen, -1, TRUE);
+ _mt_wait_for_client();
}
while (1) {