summaryrefslogtreecommitdiffstats
path: root/x11vnc/scan.c
diff options
context:
space:
mode:
Diffstat (limited to 'x11vnc/scan.c')
-rw-r--r--x11vnc/scan.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/x11vnc/scan.c b/x11vnc/scan.c
index a89e1c8..12b94d9 100644
--- a/x11vnc/scan.c
+++ b/x11vnc/scan.c
@@ -341,12 +341,17 @@ static int shm_create(XShmSegmentInfo *shm, XImage **ximg_ptr, int w, int h,
void shm_delete(XShmSegmentInfo *shm) {
#if LIBVNCSERVER_HAVE_XSHM
+ if (getenv("X11VNC_SHM_DEBUG")) fprintf(stderr, "shm_delete: 0x%x\n", shm);
if (shm != NULL && shm->shmaddr != (char *) -1) {
shmdt(shm->shmaddr);
}
if (shm != NULL && shm->shmid != -1) {
shmctl(shm->shmid, IPC_RMID, 0);
}
+ if (shm != NULL) {
+ shm->shmaddr = (char *) -1;
+ shm->shmid = -1;
+ }
#else
if (!shm) {}
#endif
@@ -2664,6 +2669,27 @@ void nap_sleep(int ms, int split) {
}
}
+static char *get_load(void) {
+ static char tmp[64];
+ static int count = 0;
+
+ if (count++ % 5 == 0) {
+ struct stat sb;
+ memset(tmp, 0, sizeof(tmp));
+ if (stat("/proc/loadavg", &sb) == 0) {
+ int d = open("/proc/loadavg", O_RDONLY);
+ if (d >= 0) {
+ read(d, tmp, 60);
+ close(d);
+ }
+ }
+ if (tmp[0] == '\0') {
+ strcat(tmp, "unknown");
+ }
+ }
+ return tmp;
+}
+
/*
* see if we should take a nap of some sort between polls
*/
@@ -2687,14 +2713,14 @@ static void nap_check(int tile_cnt) {
if (dt_fbu > screen_blank) {
/* sleep longer for no fb requests */
if (debug_tiles > 1) {
- fprintf(stderr, "screen blank sleep1: %d ms / 16\n", 2 * ms);
+ fprintf(stderr, "screen blank sleep1: %d ms / 16, load: %s\n", 2 * ms, get_load());
}
nap_sleep(2 * ms, 16);
return;
}
if (dt_ev > screen_blank) {
if (debug_tiles > 1) {
- fprintf(stderr, "screen blank sleep2: %d ms / 8\n", ms);
+ fprintf(stderr, "screen blank sleep2: %d ms / 8, load: %s\n", ms, get_load());
}
nap_sleep(ms, 8);
return;
@@ -2709,7 +2735,7 @@ static void nap_check(int tile_cnt) {
nap_ok = 0;
} else {
if (debug_tiles > 1) {
- fprintf(stderr, "nap_check sleep: %d ms / 1\n", ms);
+ fprintf(stderr, "nap_check sleep: %d ms / 1, load: %s\n", ms, get_load());
}
nap_sleep(ms, 1);
}
@@ -3198,7 +3224,8 @@ int scan_for_updates(int count_only) {
static int bad = 0;
if (xd_misses > (5 * xd_samples) / 100) {
rfbLog("XDAMAGE is not working well... misses: %d/%d\n", xd_misses, xd_samples);
- rfbLog("Maybe a OpenGL app like Beryl is the problem? Use -noxdamage\n");
+ rfbLog("Maybe an OpenGL app like Beryl or Compiz is the problem?\n");
+ rfbLog("Use x11vnc -noxdamage or disable the Beryl/Compiz app.\n");
rfbLog("To disable this check and warning specify -xdamage twice.\n");
if (++bad >= 10) {
rfbLog("XDAMAGE appears broken (OpenGL app?), turning it off.\n");