fix deadlock from rfbReleaseExtensionIterator(), fix no libz/libjpeg builds, disable tightvnc-filetransfer if no libpthread, add --without-pthread option, rm // comments, set NAME_MAX if not defined, x11vnc: throttle load if fb update requests not taking place.

pull/1/head
runge 17 years ago
parent de99644d2f
commit 8eb18f6cd8

@ -1,3 +1,20 @@
2005-11-25 Karl Runge <runge@karlrunge.com>
* configure.ac: disable tightvnc-filetransfer if no libpthread.
add --without-pthread option.
* libvncserver/Makefile.am: enable WITH_TIGHTVNC_FILETRANSFER
conditional.
* libvncserver/rfbserver.c: fix deadlock from
rfbReleaseExtensionIterator(), fix no libz/libjpeg builds.
* libvncserver/{main.c,private.h}, rfb/rfbclient.h, libvncclient/{rfbproto.c,
tight.c,vncviewer.c}: fix no libz/libjpeg builds.
* libvncserver/tightvnc-filetransfer/rfbtightserver.c: fix no
libz/libjpeg builds. rm // comments.
* libvncserver/tightvnc-filetransfer/filetransfermsg{.c,.h},
libvncserver/auth.c: rm // comments.
* libvncserver/tightvnc-filetransfer/filelistinfo.h: set NAME_MAX if not
defined.
* x11vnc: throttle load if fb update requests not taking place.
2005-10-22 Karl Runge <runge@karlrunge.com>
* x11vnc: -filexfer file transfer, -slow_fb, -blackout noptr...

@ -21,10 +21,8 @@ AH_TEMPLATE(WITH_TIGHTVNC_FILETRANSFER, [Disable TightVNCFileTransfer protocol])
AC_ARG_WITH(tightvnc-filetransfer,
[ --without-filetransfer disable TightVNC file transfer protocol],
, [ with_tightvnc_filetransfer=yes ])
if test "x$with_tightvnc_filetransfer" = "xyes"; then
AC_DEFINE(WITH_TIGHTVNC_FILETRANSFER)
fi
AM_CONDITIONAL(WITH_TIGHTVNC_FILETRANSFER, test "$with_tightvnc_filetransfer" = "yes")
# AC_DEFINE moved to after libpthread check.
AH_TEMPLATE(ALLOW24BPP, [Enable 24 bit per pixel in native framebuffer])
AC_ARG_WITH(24bpp,
[ --without-24bpp disable 24 bpp framebuffers],
@ -271,14 +269,27 @@ libz may be obtained from: http://www.gzip.org/zlib/
fi
fi
AC_CHECK_HEADER(pthread.h, HAVE_PTHREAD_H="true")
if test ! -z "$HAVE_PTHREAD_H"; then
# why twice?
AC_CHECK_LIB(pthread, pthread_mutex_lock)
AC_CHECK_LIB(pthread, pthread_mutex_lock, HAVE_LIBPTHREAD="true")
fi
AC_ARG_WITH(pthread,
[ --without-pthread disable support for libpthread],,)
if test "x$with_pthread" != "xno"; then
AC_CHECK_HEADER(pthread.h, HAVE_PTHREAD_H="true")
if test ! -z "$HAVE_PTHREAD_H"; then
AC_CHECK_LIB(pthread, pthread_mutex_lock)
AC_CHECK_LIB(pthread, pthread_mutex_lock, HAVE_LIBPTHREAD="true")
fi
fi
AM_CONDITIONAL(HAVE_LIBPTHREAD, test ! -z "$HAVE_LIBPTHREAD")
# tightvnc-filetransfer implemented using threads:
if test -z "$HAVE_LIBPTHREAD"; then
with_tightvnc_filetransfer=""
fi
if test "x$with_tightvnc_filetransfer" = "xyes"; then
AC_DEFINE(WITH_TIGHTVNC_FILETRANSFER)
fi
AM_CONDITIONAL(WITH_TIGHTVNC_FILETRANSFER, test "$with_tightvnc_filetransfer" = "yes")
AM_CONDITIONAL(HAVE_LIBZ, test ! -z "$HAVE_ZLIB_H")
AM_CONDITIONAL(HAVE_LIBJPEG, test ! -z "$HAVE_JPEGLIB_H")

@ -473,6 +473,7 @@ SetFormatAndEncodings(rfbClient* client)
encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingRaw);
} else if (strncasecmp(encStr,"copyrect",encStrLen) == 0) {
encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCopyRect);
#ifdef LIBVNCSERVER_HAVE_LIBZ
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
} else if (strncasecmp(encStr,"tight",encStrLen) == 0) {
encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingTight);
@ -481,6 +482,7 @@ SetFormatAndEncodings(rfbClient* client)
requestCompressLevel = TRUE;
if (client->appData.enableJPEG)
requestQualityLevel = TRUE;
#endif
#endif
} else if (strncasecmp(encStr,"hextile",encStrLen) == 0) {
encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingHextile);
@ -547,8 +549,10 @@ SetFormatAndEncodings(rfbClient* client)
}
encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingCopyRect);
#ifdef LIBVNCSERVER_HAVE_LIBZ
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingTight);
#endif
#endif
encs[se->nEncodings++] = rfbClientSwap32IfLE(rfbEncodingHextile);
#ifdef LIBVNCSERVER_HAVE_LIBZ

@ -17,6 +17,7 @@
* USA.
*/
#ifdef LIBVNCSERVER_HAVE_LIBZ
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
/*
@ -681,5 +682,7 @@ JpegSetSrcManager(j_decompress_ptr cinfo,
#undef CARDBPP
/* LIBVNCSERVER_HAVE_LIBZ and LIBVNCSERVER_HAVE_LIBJPEG */
#endif
#endif

@ -159,9 +159,11 @@ rfbClient* rfbGetClient(int bitsPerSample,int samplesPerPixel,
client->decompStreamInited = FALSE;
#endif
#ifdef LIBVNCSERVER_HAVE_LIBZ
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
memset(client->zlibStreamActive,0,sizeof(rfbBool)*4);
client->jpegSrcManager = NULL;
#endif
#endif
client->HandleCursorPos = DummyPoint;

@ -1,6 +1,6 @@
AM_CFLAGS=-g -Wall
#if WITH_TIGHTVNC_FILETRANSFER
if WITH_TIGHTVNC_FILETRANSFER
TIGHTVNCFILETRANSFERHDRS=tightvnc-filetransfer/filelistinfo.h \
tightvnc-filetransfer/filetransfermsg.h \
tightvnc-filetransfer/handlefiletransferrequest.h \
@ -10,7 +10,7 @@ TIGHTVNCFILETRANSFERSRCS = tightvnc-filetransfer/rfbtightserver.c \
tightvnc-filetransfer/handlefiletransferrequest.c \
tightvnc-filetransfer/filetransfermsg.c \
tightvnc-filetransfer/filelistinfo.c
#endif
endif
includedir=$(prefix)/include/rfb
#include_HEADERS=rfb.h rfbconfig.h rfbint.h rfbproto.h keysym.h rfbregion.h

@ -179,7 +179,7 @@ rfbAuthNewClient(rfbClientPtr cl)
int32_t securityType = rfbSecTypeInvalid;
if (!cl->screen->authPasswdData || cl->reverseConnection) {
// chk if this condition is valid or not.
/* chk if this condition is valid or not. */
securityType = rfbSecTypeNone;
} else if (cl->screen->authPasswdData) {
securityType = rfbSecTypeVncAuth;

@ -840,8 +840,10 @@ void rfbScreenCleanup(rfbScreenInfoPtr screen)
TINI_MUTEX(screen->cursorMutex);
if(screen->cursor && screen->cursor->cleanup)
rfbFreeCursor(screen->cursor);
#ifdef LIBVNCSERVER_HAVE_LIBZ
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
rfbTightCleanup(screen);
#endif
#endif
free(screen);
}

@ -13,7 +13,11 @@ rfbClientPtr rfbClientIteratorHead(rfbClientIteratorPtr i);
/* from tight.c */
#ifdef LIBVNCSERVER_HAVE_LIBZ
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
extern void rfbTightCleanup(rfbScreenInfoPtr screen);
#endif
#endif
/* from zrle.c */

@ -318,6 +318,7 @@ rfbNewTCPOrUDPClient(rfbScreenInfoPtr rfbScreen,
rfbScreen->clientHead = cl;
UNLOCK(rfbClientListMutex);
#ifdef LIBVNCSERVER_HAVE_LIBZ
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
cl->tightCompressLevel = TIGHT_DEFAULT_COMPRESSION;
cl->tightQualityLevel = -1;
@ -326,6 +327,7 @@ rfbNewTCPOrUDPClient(rfbScreenInfoPtr rfbScreen,
for (i = 0; i < 4; i++)
cl->zsActive[i] = FALSE;
}
#endif
#endif
cl->enableCursorShapeUpdates = FALSE;
@ -562,7 +564,7 @@ rfbProcessClientProtocolVersion(rfbClientPtr cl)
return;
}
// Chk for the minor version use either of the two standard version of RFB
/* Chk for the minor version use either of the two standard version of RFB */
cl->protocolMinorVersion = minor_;
if (minor_ > rfbProtocolMinorVersion) {
cl->protocolMinorVersion = rfbProtocolMinorVersion;
@ -949,17 +951,16 @@ rfbProcessClientNormalMessage(rfbClientPtr cl)
}
encs++;
}
rfbReleaseExtensionIterator();
if(e)
e = e->next;
}
rfbReleaseExtensionIterator();
if(!handled)
rfbLog("rfbProcessClientNormalMessage: ignoring"
" unknown encoding type %d\n",
(int)enc);
rfbLog("rfbProcessClientNormalMessage: "
"ignoring unknown encoding type %d\n",
(int)enc);
}
}
}
@ -1348,10 +1349,13 @@ rfbSendFramebufferUpdate(rfbClientPtr cl,
fu->type = rfbFramebufferUpdate;
if (nUpdateRegionRects != 0xFFFF) {
if(cl->screen->maxRectsPerUpdate>0
#ifdef LIBVNCSERVER_HAVE_LIBZ
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
/* Tight encoding counts the rectangles differently */
&& cl->preferredEncoding != rfbEncodingTight
/* XXX Should rfbEncodingCoRRE be in here? */
&& cl->preferredEncoding != rfbEncodingCoRRE
#endif
#endif
&& nUpdateRegionRects>cl->screen->maxRectsPerUpdate) {
sraRegion* newUpdateRegion = sraRgnBBox(updateRegion);

@ -28,6 +28,10 @@
#include <limits.h>
#if !defined(NAME_MAX)
#define NAME_MAX 255
#endif
#define SUCCESS 1
#define FAILURE 0

@ -292,7 +292,7 @@ GetFileDownloadLengthErrResponseMsg()
FileTransferMsg
GetFileDownloadResponseMsgInBlocks(rfbClientPtr cl, rfbTightClientPtr rtcp)
{
//const unsigned int sz_rfbBlockSize = SZ_RFBBLOCKSIZE;
/* const unsigned int sz_rfbBlockSize = SZ_RFBBLOCKSIZE; */
int numOfBytesRead = 0;
char pBuf[SZ_RFBBLOCKSIZE];
char* path = rtcp->rcft.rcfd.fName;

@ -984,5 +984,3 @@ HandleFileCreateDirRequest(rfbClientPtr cl, rfbTightClientPtr rtcp)
CreateDirectory(dirName);
}

@ -62,7 +62,7 @@ rfbVncAuthSendChallenge(cl)
rfbClientPtr cl;
{
// 4 byte header is alreay sent. Which is rfbSecTypeVncAuth (same as rfbVncAuth). Just send the challenge.
/* 4 byte header is alreay sent. Which is rfbSecTypeVncAuth (same as rfbVncAuth). Just send the challenge. */
rfbRandomBytes(cl->authChallenge);
if (rfbWriteExact(cl, (char *)cl->authChallenge, CHALLENGESIZE) < 0) {
rfbLogPerror("rfbAuthNewClient: write");
@ -165,7 +165,7 @@ rfbSendAuthCaps(cl)
return;
if (cl->screen->authPasswdData && !cl->reverseConnection) {
// chk if this condition is valid or not.
/* chk if this condition is valid or not. */
SetCapInfo(&caplist[count], rfbAuthVNC, rfbStandardVendor);
rtcp->authCaps[count++] = rfbAuthVNC;
}
@ -294,8 +294,10 @@ rfbSendInteractionCaps(cl)
SetCapInfo(&enc_list[i++], rfbEncodingRRE, rfbStandardVendor);
SetCapInfo(&enc_list[i++], rfbEncodingCoRRE, rfbStandardVendor);
SetCapInfo(&enc_list[i++], rfbEncodingHextile, rfbStandardVendor);
#ifdef LIBVNCSERVER_HAVE_LIBZ
SetCapInfo(&enc_list[i++], rfbEncodingZlib, rfbTridiaVncVendor);
SetCapInfo(&enc_list[i++], rfbEncodingTight, rfbTightVncVendor);
#endif
SetCapInfo(&enc_list[i++], rfbEncodingCompressLevel0, rfbTightVncVendor);
SetCapInfo(&enc_list[i++], rfbEncodingQualityLevel0, rfbTightVncVendor);
SetCapInfo(&enc_list[i++], rfbEncodingXCursor, rfbTightVncVendor);
@ -404,7 +406,7 @@ const rfbClientToServerMsg* msg;
/*
// We shouldn't close the connection here for unhandled msg, it should be left to libvncserver.
We shouldn't close the connection here for unhandled msg, it should be left to libvncserver.
rfbLog(" ... closing connection\n");
rfbCloseClient(cl);
@ -466,7 +468,7 @@ rfbHandleSecTypeTight(rfbClientPtr cl) {
rfbTightClientPtr rtcp = (rfbTightClientPtr) malloc(sizeof(rfbTightClientRec));
if(rtcp == NULL) {
// Error condition close socket
/* Error condition close socket */
rfbLog("Memory error has occured while handling Tight security type... closing connection.\n");
rfbCloseClient(cl);
return;

@ -157,6 +157,7 @@ typedef struct _rfbClient {
#endif
#ifdef LIBVNCSERVER_HAVE_LIBZ
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
/*
* Variables for the ``tight'' encoding implementation.
@ -183,6 +184,7 @@ typedef struct _rfbClient {
void* jpegBufferPtr;
size_t jpegBufferLen;
#endif
#endif

@ -905,7 +905,7 @@ typedef struct _rfbFileTransferMsg {
uint8_t contentType; /* See defines below */
uint16_t contentParam;/* Other possible content classification (Dir or File name, etc..) */
uint32_t size; /* FileSize or packet index or error or other */
/* uint32_t sizeH; // Additional 32Bits params to handle big values. Only for V2 (we want backward compatibility between all V1 versions) */
/* uint32_t sizeH; Additional 32Bits params to handle big values. Only for V2 (we want backward compatibility between all V1 versions) */
uint32_t length;
/* followed by data char text[length] */
} rfbFileTransferMsg;

@ -1,3 +1,7 @@
2005-11-25 Karl Runge <runge@karlrunge.com>
* x11vnc: throttle load if fb update requests not taking place.
* misc/x11vnc_pw: add utility script
2005-10-22 Karl Runge <runge@karlrunge.com>
* add tightVNC FileTransfer (-filexfer) and -DFILEXFER=1
* -slow_fb for special purpose infrequent polling.

@ -0,0 +1,24 @@
#!/bin/sh
# usage: x11vnc_pw [file] (default: ~/.vnc/passwd)
if [ "X$1" = "X" ]; then
file=$HOME/.vnc/passwd
else
file=$1
fi
stty -echo
printf "Password: "
read pw1; echo ""
printf "Verify: "
read pw2; echo ""
stty echo
if [ "X$pw1" != "X$pw2" ]; then
echo "passwords do not match."
exit 1
fi
x11vnc -help > /dev/null 2>&1
x11vnc -storepasswd "$pw1" "$file"
ls -l "$file"

@ -398,7 +398,7 @@ double xdamage_scheduled_mark = 0.0;
sraRegionPtr xdamage_scheduled_mark_region = NULL;
/* date +'lastmod: %Y-%m-%d' */
char lastmod[] = "0.7.3 lastmod: 2005-10-22";
char lastmod[] = "0.7.3 lastmod: 2005-11-25";
int hack_val = 0;
/* X display info */
@ -520,6 +520,7 @@ unsigned char *tile_has_xdamage_diff, *tile_row_has_xdamage_diff;
/* times of recent events */
time_t last_event, last_input = 0, last_client = 0;
time_t last_keyboard_input = 0, last_pointer_input = 0;
time_t last_fb_bytes_sent = 0;
double last_keyboard_time = 0.0;
double last_pointer_time = 0.0;
double last_pointer_click_time = 0.0;
@ -591,6 +592,7 @@ void blackout_tiles(void);
void solid_bg(int);
void check_connect_inputs(void);
void check_gui_inputs(void);
void record_last_fb_update(void);
void check_padded_fb(void);
void clean_up_exit(int);
void clear_modifiers(int init);
@ -1120,6 +1122,7 @@ int got_deferupdate = 0;
int screen_blank = 60; /* number of seconds of no activity to throttle */
/* down the screen polls. zero to disable. */
int no_fbu_blank = 30; /* nap if no client updates in this many secs. */
int take_naps = 1; /* -nap/-nonap */
int naptile = 4; /* tile change threshold per poll to take a nap */
int napfac = 4; /* time = napfac*waitms, cut load with extra waits */
@ -20431,7 +20434,9 @@ void initialize_screen(int *argc, char **argv, XImage *fb) {
screen->setXCutText = xcut_receive;
if (filexfer) {
#ifdef LIBVNCSERVER_WITH_TIGHTVNC_FILETRANSFER
rfbRegisterTightVNCFileTransferExtension();
#endif
}
rfbInitServer(screen);
@ -23504,6 +23509,7 @@ int copy_snap(void) {
*/
static void nap_set(int tile_cnt) {
int nap_in = nap_ok;
time_t now = time(0);
if (scan_count == 0) {
/* roll up check for all NSCAN scans */
@ -23520,14 +23526,23 @@ static void nap_set(int tile_cnt) {
nap_ok = 0;
}
}
if (! nap_ok && client_count) {
if(now > last_fb_bytes_sent + no_fbu_blank) {
if (debug_tiles > 1) {
printf("nap_set: nap_ok=1: now: %d last: %d\n",
now, last_fb_bytes_sent);
}
nap_ok = 1;
}
}
if (show_cursor) {
/* kludge for the up to 4 tiles the mouse patch could occupy */
if ( tile_cnt > 4) {
last_event = time(0);
last_event = now;
}
} else if (tile_cnt != 0) {
last_event = time(0);
last_event = now;
}
}
@ -23563,11 +23578,17 @@ static void nap_check(int tile_cnt) {
now = time(0);
if (screen_blank > 0) {
int dt = (int) (now - last_event);
int ms = 1500;
int dt_ev, dt_fbu, ms = 2000;
/* if no activity, pause here for a second or so. */
if (dt > screen_blank) {
dt_ev = (int) (now - last_event);
dt_fbu = (int) (now - last_fb_bytes_sent);
if (dt_fbu > screen_blank) {
/* sleep longer for no fb requests */
nap_sleep(2 * ms, 16);
return;
}
if (dt_ev > screen_blank) {
nap_sleep(ms, 8);
return;
}
@ -29756,6 +29777,45 @@ void rfbPE(long usec) {
}
}
void record_last_fb_update(void) {
static int rbs0 = -1;
static time_t last_call = 0;
time_t now = time(0);
int rbs;
rfbClientIteratorPtr iter;
rfbClientPtr cl;
if (last_fb_bytes_sent == 0) {
last_fb_bytes_sent = now;
last_call = now;
}
if (now <= last_call + 1) {
/* check every second or so */
return;
}
last_call = now;
if (! screen) {
return;
}
iter = rfbGetClientIterator(screen);
while( (cl = rfbClientIteratorNext(iter)) ) {
rbs += cl->rawBytesEquivalent;
}
rfbReleaseClientIterator(iter);
if (rbs != rbs0) {
rbs0 = rbs;
if (debug_tiles > 1) {
printf("record_last_fb_update: %d %d\n", now,
last_fb_bytes_sent);
}
last_fb_bytes_sent = now;
}
}
void rfbCFD(long usec) {
if (! screen) {
return;
@ -29987,6 +30047,7 @@ if (debug_scroll) fprintf(stderr, "watch_loop: LOOP-BACK: %d\n", ret);
check_keycode_state();
check_connect_inputs();
check_gui_inputs();
record_last_fb_update();
check_padded_fb();
check_fixscreen();
check_xdamage_state();
@ -30066,8 +30127,8 @@ if ((debug_tiles || debug_scroll > 1 || debug_wireframe > 1)
&& (tile_diffs > 4 || debug_tiles > 1)) {
double rate = (tile_x * tile_y * bpp/8 * tile_diffs) / dt;
fprintf(stderr, "============================= TILES: %d dt: %.4f"
" t: %.4f %.2f MB/s\n", tile_diffs, dt, tm - x11vnc_start,
rate/1000000.0);
" t: %.4f %.2f MB/s nap_ok: %d\n", tile_diffs, dt,
tm - x11vnc_start, rate/1000000.0, nap_ok);
}
}

Loading…
Cancel
Save