Commit 7e7ef1b4 authored by runge's avatar runge

x11vnc: during speeds estimate, guard against client disconnecting.

parent c17aef31
2008-01-31 Karl Runge <runge@karlrunge.com>
* x11vnc: during speeds estimate, guard against client
disconnecting. ssvnc sync.
2008-01-14 Karl Runge <runge@karlrunge.com> 2008-01-14 Karl Runge <runge@karlrunge.com>
* x11vnc: -ping option, fix memory corruption in copy_tiles * x11vnc: -ping option, fix memory corruption in copy_tiles
after xrandr resize. after xrandr resize.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -672,6 +672,7 @@ void client_gone(rfbClientPtr client) { ...@@ -672,6 +672,7 @@ void client_gone(rfbClientPtr client) {
speeds_net_latency_measured = 0; speeds_net_latency_measured = 0;
rfbLog("client_count: %d\n", client_count); rfbLog("client_count: %d\n", client_count);
last_client_gone = dnow();
if (unixpw_in_progress && unixpw_client) { if (unixpw_in_progress && unixpw_client) {
if (client == unixpw_client) { if (client == unixpw_client) {
......
...@@ -342,7 +342,7 @@ void print_help(int mode) { ...@@ -342,7 +342,7 @@ void print_help(int mode) {
" background, for example, usage of -display WAIT:..,\n" " background, for example, usage of -display WAIT:..,\n"
" -svc, and -connect can make use of this \"poor man's\"\n" " -svc, and -connect can make use of this \"poor man's\"\n"
" inetd mode. The default wait time is 500ms in this\n" " inetd mode. The default wait time is 500ms in this\n"
" mode. This usage could use useful: -svc -loopbg\n" " mode. This usage could use useful: -svc -bg -loopbg\n"
"\n" "\n"
"-timeout n Exit unless a client connects within the first n seconds\n" "-timeout n Exit unless a client connects within the first n seconds\n"
" after startup.\n" " after startup.\n"
...@@ -3189,7 +3189,8 @@ void print_help(int mode) { ...@@ -3189,7 +3189,8 @@ void print_help(int mode) {
" If there is trouble with mmap, use \"file:/...\"\n" " If there is trouble with mmap, use \"file:/...\"\n"
" for slower lseek(2) based reading. Use \"snap:...\"\n" " for slower lseek(2) based reading. Use \"snap:...\"\n"
" to imply -snapfb mode and the \"file:\" access (this\n" " to imply -snapfb mode and the \"file:\" access (this\n"
" is for devices that only provide the fb all at once).\n" " is for unseekable devices that only provide the fb all\n"
" at once, e.g. a video camera provides the whole frame).\n"
"\n" "\n"
" For shared memory segments string is of the form:\n" " For shared memory segments string is of the form:\n"
" \"shm:N@WxHxB\" which specifies a shmid N and with\n" " \"shm:N@WxHxB\" which specifies a shmid N and with\n"
...@@ -4854,7 +4855,7 @@ void print_license(void) { ...@@ -4854,7 +4855,7 @@ void print_license(void) {
"\n" "\n"
"x11vnc: a VNC server for X displays. %s\n" "x11vnc: a VNC server for X displays. %s\n"
"\n" "\n"
"Copyright (c) 2002-2006 Karl J. Runge <runge@karlrunge.com>\n" "Copyright (c) 2002-2008 Karl J. Runge <runge@karlrunge.com>\n"
"All rights reserved.\n" "All rights reserved.\n"
"\n" "\n"
; ;
......
Enhanced TightVNC Viewer (SSVNC: SSL/SSH VNC viewer) Enhanced TightVNC Viewer (SSVNC: SSL/SSH VNC viewer)
Copyright (c) 2006-2007 Karl J. Runge <runge@karlrunge.com> Copyright (c) 2006-2008 Karl J. Runge <runge@karlrunge.com>
All rights reserved. All rights reserved.
These bundles provide 1) An enhanced TightVNC Viewer on Unix, 2) Binaries These bundles provide 1) An enhanced TightVNC Viewer on Unix, 2) Binaries
...@@ -338,6 +338,14 @@ on a USB flash drive that you carry around for mobile use and you want ...@@ -338,6 +338,14 @@ on a USB flash drive that you carry around for mobile use and you want
the profiles you create to stay with the drive (otherwise you'd have to the profiles you create to stay with the drive (otherwise you'd have to
browse to the drive directory each time you load or save). browse to the drive directory each time you load or save).
One user on Windows created a BAT file to launch SSVNC and needed to
do this to get the Home directory correct:
cd \ssvnc\Windows
start \ssvnc\Windows\ssvnc.exe
(an optional profile name can be supplied to the ssvnc.exe line)
WARNING: if you use ssvnc from an "Internet Cafe", i.e. an untrusted WARNING: if you use ssvnc from an "Internet Cafe", i.e. an untrusted
computer, an intruder may be capturing keystrokes etc. computer, an intruder may be capturing keystrokes etc.
......
...@@ -354,7 +354,9 @@ disp=`echo "$orig" | awk -F: '{print $2}'` ...@@ -354,7 +354,9 @@ disp=`echo "$orig" | awk -F: '{print $2}'`
if [ "X$host" = "X" ]; then if [ "X$host" = "X" ]; then
host=localhost host=localhost
fi fi
if [ $disp -lt 0 ]; then if [ "X$disp" = "X" ]; then
port="" # probably -listen mode.
elif [ $disp -lt 0 ]; then
# negative means use |n| without question: # negative means use |n| without question:
port=`expr 0 - $disp` port=`expr 0 - $disp`
elif [ $disp -lt 200 ]; then elif [ $disp -lt 200 ]; then
......
...@@ -734,6 +734,12 @@ proc help {} { ...@@ -734,6 +734,12 @@ proc help {} {
directory you want. It can be set after starting ssvnc by putting directory you want. It can be set after starting ssvnc by putting
HOME=/path/to/dir in the Host:Display box and clicking "Connect". HOME=/path/to/dir in the Host:Display box and clicking "Connect".
For a Windows BAT file to get the "Home" directory correct
something like this might be needed:
cd \ssvnc\Windows
start \ssvnc\Windows\ssvnc.exe
11) Dynamic VNC Server Port determination and redirection: If you 11) Dynamic VNC Server Port determination and redirection: If you
are running SSVNC on Unix and are using SSH to start the remote are running SSVNC on Unix and are using SSH to start the remote
VNC server and the VNC server prints out the line "PORT=NNNN" VNC server and the VNC server prints out the line "PORT=NNNN"
......
...@@ -305,10 +305,9 @@ void measure_send_rates(int init) { ...@@ -305,10 +305,9 @@ void measure_send_rates(int init) {
double lat_min = .0005; /* 0.5 ms */ double lat_min = .0005; /* 0.5 ms */
int min_cmp = 10000, nclients; int min_cmp = 10000, nclients;
rfbClientIteratorPtr iter; rfbClientIteratorPtr iter;
rfbClientPtr cl; rfbClientPtr cl0, cl;
int db = 0, msg = 0; int msg = 0, clcnt0 = 0, cc;
int db = 0, ouch_db = 0, ouch = 0;
db = 0;
if (! measure_speeds) { if (! measure_speeds) {
return; return;
...@@ -316,6 +315,9 @@ db = 0; ...@@ -316,6 +315,9 @@ db = 0;
if (speeds_net_rate && speeds_net_latency) { if (speeds_net_rate && speeds_net_latency) {
return; return;
} }
if (!client_count) {
return;
}
if (! orig_display_hook) { if (! orig_display_hook) {
orig_display_hook = screen->displayHook; orig_display_hook = screen->displayHook;
...@@ -324,7 +326,11 @@ db = 0; ...@@ -324,7 +326,11 @@ db = 0;
if (start == 0.0) { if (start == 0.0) {
dtime(&start); dtime(&start);
} }
dtime0(&now); dtime0(&now);
if (now < last_client_gone+4.0) {
return;
}
now = now - start; now = now - start;
nclients = 0; nclients = 0;
...@@ -333,13 +339,9 @@ db = 0; ...@@ -333,13 +339,9 @@ db = 0;
return; return;
} }
cl0 = NULL;
iter = rfbGetClientIterator(screen); iter = rfbGetClientIterator(screen);
while( (cl = rfbClientIteratorNext(iter)) ) { while( (cl = rfbClientIteratorNext(iter)) ) {
int defer, i, cbs, rbs;
char *httpdir;
double dt, dt1 = 0.0, dt2, dt3;
double tm, spin_max = 15.0, spin_lat_max = 1.5;
int got_t2 = 0, got_t3 = 0;
ClientData *cd = (ClientData *) cl->clientData; ClientData *cd = (ClientData *) cl->clientData;
if (! cd) { if (! cd) {
...@@ -348,8 +350,26 @@ db = 0; ...@@ -348,8 +350,26 @@ db = 0;
if (cd->send_cmp_rate > 0.0) { if (cd->send_cmp_rate > 0.0) {
continue; continue;
} }
if (cl->onHold) {
continue;
}
nclients++; nclients++;
if (cl0 == NULL) {
cl0 = cl;
}
}
rfbReleaseClientIterator(iter);
cl = cl0;
cc = 0;
while (cl != NULL && cc++ == 0) {
int defer, i, cbs, rbs;
char *httpdir;
double dt, dt1 = 0.0, dt2, dt3;
double tm, spin_max = 15.0, spin_lat_max = 1.5;
int got_t2 = 0, got_t3 = 0;
ClientData *cd = (ClientData *) cl->clientData;
#if 0 #if 0
for (i=0; i<MAX_ENCODINGS; i++) { for (i=0; i<MAX_ENCODINGS; i++) {
...@@ -393,9 +413,18 @@ if (db) fprintf(stderr, "%d client num rects req: %d mod: %d cbs: %d " ...@@ -393,9 +413,18 @@ if (db) fprintf(stderr, "%d client num rects req: %d mod: %d cbs: %d "
continue; continue;
} }
if (ouch_db) fprintf(stderr, "START-OUCH: %d\n", client_count);
clcnt0 = client_count;
#define OUCH ( ouch || (ouch = (!client_count || client_count != clcnt0 || dnow() < last_client_gone+4.0)) )
rfbPE(1000); rfbPE(1000);
if (OUCH && ouch_db) fprintf(stderr, "***OUCH-A\n");
if (OUCH) continue;
if (sraRgnCountRects(cl->modifiedRegion)) { if (sraRgnCountRects(cl->modifiedRegion)) {
rfbPE(1000); rfbPE(1000);
if (OUCH && ouch_db) fprintf(stderr, "***OUCH-B\n");
if (OUCH) continue;
} }
defer = screen->deferUpdateTime; defer = screen->deferUpdateTime;
...@@ -419,6 +448,10 @@ if (db) fprintf(stderr, "%d client num rects req: %d mod: %d cbs: %d " ...@@ -419,6 +448,10 @@ if (db) fprintf(stderr, "%d client num rects req: %d mod: %d cbs: %d "
/* when req1 = 1 mod1 == 0, end of 2nd part of bulk transfer */ /* when req1 = 1 mod1 == 0, end of 2nd part of bulk transfer */
while (1) { while (1) {
int req0, req1, mod0, mod1; int req0, req1, mod0, mod1;
if (OUCH && ouch_db) fprintf(stderr, "***OUCH-C1\n");
if (OUCH) break;
req0 = sraRgnCountRects(cl->requestedRegion); req0 = sraRgnCountRects(cl->requestedRegion);
mod0 = sraRgnCountRects(cl->modifiedRegion); mod0 = sraRgnCountRects(cl->modifiedRegion);
if (use_threads) { if (use_threads) {
...@@ -435,6 +468,10 @@ if (db) fprintf(stderr, "%d client num rects req: %d mod: %d cbs: %d " ...@@ -435,6 +468,10 @@ if (db) fprintf(stderr, "%d client num rects req: %d mod: %d cbs: %d "
if (dt2 > spin_max) { if (dt2 > spin_max) {
break; break;
} }
if (OUCH && ouch_db) fprintf(stderr, "***OUCH-C2\n");
if (OUCH) break;
req1 = sraRgnCountRects(cl->requestedRegion); req1 = sraRgnCountRects(cl->requestedRegion);
mod1 = sraRgnCountRects(cl->modifiedRegion); mod1 = sraRgnCountRects(cl->modifiedRegion);
...@@ -452,6 +489,8 @@ if (db) fprintf(stderr, "dt2 calc: num rects req: %d/%d mod: %d/%d " ...@@ -452,6 +489,8 @@ if (db) fprintf(stderr, "dt2 calc: num rects req: %d/%d mod: %d/%d "
break; break;
} }
} }
if (OUCH && ouch_db) fprintf(stderr, "***OUCH-D\n");
if (OUCH) goto ouch;
if (! got_t2) { if (! got_t2) {
dt2 = 0.0; dt2 = 0.0;
...@@ -498,6 +537,8 @@ if (db) fprintf(stderr, "dt2 calc: num rects req: %d/%d mod: %d/%d " ...@@ -498,6 +537,8 @@ if (db) fprintf(stderr, "dt2 calc: num rects req: %d/%d mod: %d/%d "
rfbCFD(1000*1000); rfbCFD(1000*1000);
} }
} }
if (OUCH && ouch_db) fprintf(stderr, "***OUCH-E\n");
if (OUCH) goto ouch;
dt = dtime(&tm); dt = dtime(&tm);
i++; i++;
...@@ -550,10 +591,15 @@ if (db) fprintf(stderr, "dt3 calc: num rects req: %d/%d mod: %d/%d " ...@@ -550,10 +591,15 @@ if (db) fprintf(stderr, "dt3 calc: num rects req: %d/%d mod: %d/%d "
} }
} }
} }
ouch:
screen->deferUpdateTime = defer; screen->deferUpdateTime = defer;
screen->httpDir = httpdir; screen->httpDir = httpdir;
if (OUCH && ouch_db) fprintf(stderr, "***OUCH-F\n");
if (OUCH) break;
dt = dt1 + dt2; dt = dt1 + dt2;
...@@ -591,7 +637,6 @@ if (db) fprintf(stderr, "dt3 calc: num rects req: %d/%d mod: %d/%d " ...@@ -591,7 +637,6 @@ if (db) fprintf(stderr, "dt3 calc: num rects req: %d/%d mod: %d/%d "
dt1, dt2, dt3, cbs); dt1, dt2, dt3, cbs);
msg = 1; msg = 1;
} }
rfbReleaseClientIterator(iter);
if (msg) { if (msg) {
int link, latency, netrate; int link, latency, netrate;
......
...@@ -1639,7 +1639,11 @@ char create_display[] = ...@@ -1639,7 +1639,11 @@ char create_display[] =
" cookie=`(echo $r; date; uptime; ps -ealf 2>&1) | md5sum | awk '{print $1}'`\n" " cookie=`(echo $r; date; uptime; ps -ealf 2>&1) | md5sum | awk '{print $1}'`\n"
" fi\n" " fi\n"
" elif [ \"X$have_xauth\" != \"X\" ]; then\n" " elif [ \"X$have_xauth\" != \"X\" ]; then\n"
" cookie=`$have_xauth list | awk '{print $NF}' | tail -n 1`\n" " if uname | grep SunOS > /dev/null; then\n"
" cookie=`$have_xauth list | awk '{print $NF}' | tail -1`\n"
" else\n"
" cookie=`$have_xauth list | awk '{print $NF}' | tail -n 1`\n"
" fi\n"
" fi\n" " fi\n"
" if [ \"X$cookie\" = \"X\" ]; then\n" " if [ \"X$cookie\" = \"X\" ]; then\n"
" # oh well..\n" " # oh well..\n"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
.TH X11VNC "1" "January 2008" "x11vnc " "User Commands" .TH X11VNC "1" "January 2008" "x11vnc " "User Commands"
.SH NAME .SH NAME
x11vnc - allow VNC connections to real X11 displays x11vnc - allow VNC connections to real X11 displays
version: 0.9.4, lastmod: 2008-01-14 version: 0.9.4, lastmod: 2008-01-24
.SH SYNOPSIS .SH SYNOPSIS
.B x11vnc .B x11vnc
[OPTION]... [OPTION]...
...@@ -396,7 +396,7 @@ is already connected before the process goes into the ...@@ -396,7 +396,7 @@ is already connected before the process goes into the
background, for example, usage of \fB-display\fR WAIT:.., background, for example, usage of \fB-display\fR WAIT:..,
\fB-svc,\fR and \fB-connect\fR can make use of this "poor man's" \fB-svc,\fR and \fB-connect\fR can make use of this "poor man's"
inetd mode. The default wait time is 500ms in this inetd mode. The default wait time is 500ms in this
mode. This usage could use useful: \fB-svc\fR \fB-loopbg\fR mode. This usage could use useful: \fB-svc\fR \fB-bg\fR \fB-loopbg\fR
.PP .PP
\fB-timeout\fR \fIn\fR \fB-timeout\fR \fIn\fR
.IP .IP
...@@ -3773,7 +3773,8 @@ for slower ...@@ -3773,7 +3773,8 @@ for slower
.IR lseek (2) .IR lseek (2)
based reading. Use "snap:..." based reading. Use "snap:..."
to imply \fB-snapfb\fR mode and the "file:" access (this to imply \fB-snapfb\fR mode and the "file:" access (this
is for devices that only provide the fb all at once). is for unseekable devices that only provide the fb all
at once, e.g. a video camera provides the whole frame).
.IP .IP
For shared memory segments string is of the form: For shared memory segments string is of the form:
"shm:N@WxHxB" which specifies a shmid N and with "shm:N@WxHxB" which specifies a shmid N and with
......
...@@ -483,6 +483,7 @@ extern int hack_val; ...@@ -483,6 +483,7 @@ extern int hack_val;
/* last client to move pointer */ /* last client to move pointer */
extern rfbClientPtr last_pointer_client; extern rfbClientPtr last_pointer_client;
extern rfbClientPtr latest_client; extern rfbClientPtr latest_client;
extern double last_client_gone;
extern int waited_for_client; extern int waited_for_client;
extern int findcreatedisplay; extern int findcreatedisplay;
......
...@@ -15,7 +15,7 @@ int xtrap_base_event_type = 0; ...@@ -15,7 +15,7 @@ int xtrap_base_event_type = 0;
int xdamage_base_event_type = 0; int xdamage_base_event_type = 0;
/* date +'lastmod: %Y-%m-%d' */ /* date +'lastmod: %Y-%m-%d' */
char lastmod[] = "0.9.4 lastmod: 2008-01-14"; char lastmod[] = "0.9.4 lastmod: 2008-01-24";
/* X display info */ /* X display info */
...@@ -146,6 +146,7 @@ int hack_val = 0; ...@@ -146,6 +146,7 @@ int hack_val = 0;
/* last client to move pointer */ /* last client to move pointer */
rfbClientPtr last_pointer_client = NULL; rfbClientPtr last_pointer_client = NULL;
rfbClientPtr latest_client = NULL; rfbClientPtr latest_client = NULL;
double last_client_gone = 0.0;
int waited_for_client = 0; int waited_for_client = 0;
int findcreatedisplay = 0; int findcreatedisplay = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment