From e39540b462c1df32b3ba0e6f71a0f010a29b91f0 Mon Sep 17 00:00:00 2001 From: Pierre Ossman Date: Thu, 7 Dec 2017 15:16:54 +0100 Subject: [PATCH] Make VNC extension startup mandatory No longer tolerate loading the VNC extension but not being able to initialize it. This avoids a lot of error prone checking to see if the extension has started fully or not. --- unix/xserver/hw/vnc/vncExt.c | 7 ++-- unix/xserver/hw/vnc/vncExtInit.cc | 60 +++++++------------------------ unix/xserver/hw/vnc/vncExtInit.h | 3 +- unix/xserver/hw/vnc/xvnc.c | 8 ----- 4 files changed, 15 insertions(+), 63 deletions(-) diff --git a/unix/xserver/hw/vnc/vncExt.c b/unix/xserver/hw/vnc/vncExt.c index 0ee32101..f7ba9fa8 100644 --- a/unix/xserver/hw/vnc/vncExt.c +++ b/unix/xserver/hw/vnc/vncExt.c @@ -57,7 +57,7 @@ struct VncInputSelect { struct VncInputSelect* next; }; -int vncAddExtension(void) +void vncAddExtension(void) { ExtensionEntry* extEntry; @@ -65,8 +65,7 @@ int vncAddExtension(void) ProcVncExtDispatch, SProcVncExtDispatch, vncResetProc, StandardMinorOpcode); if (!extEntry) { - ErrorF("vncAddExtension: AddExtension failed\n"); - return -1; + FatalError("vncAddExtension: AddExtension failed\n"); } vncErrorBase = extEntry->errorBase; @@ -75,8 +74,6 @@ int vncAddExtension(void) if (!AddCallback(&ClientStateCallback, vncClientStateChange, 0)) { FatalError("Add ClientStateCallback failed\n"); } - - return 0; } int vncNotifyQueryConnect(void) diff --git a/unix/xserver/hw/vnc/vncExtInit.cc b/unix/xserver/hw/vnc/vncExtInit.cc index 081e7feb..c47dfa72 100644 --- a/unix/xserver/hw/vnc/vncExtInit.cc +++ b/unix/xserver/hw/vnc/vncExtInit.cc @@ -137,27 +137,19 @@ static void parseOverrideList(const char *text, ParamSet &out) void vncExtensionInit(void) { - int ret; - if (vncExtGeneration == vncGetServerGeneration()) { vlog.error("vncExtensionInit: called twice in same generation?"); return; } vncExtGeneration = vncGetServerGeneration(); - if (vncGetScreenCount() > MAXSCREENS) { - vlog.error("vncExtensionInit: too many screens"); - return; - } + if (vncGetScreenCount() > MAXSCREENS) + vncFatalError("vncExtensionInit: too many screens"); - if (sizeof(ShortRect) != sizeof(struct UpdateRect)) { - vlog.error("vncExtensionInit: Incompatible ShortRect size"); - return; - } + if (sizeof(ShortRect) != sizeof(struct UpdateRect)) + vncFatalError("vncExtensionInit: Incompatible ShortRect size"); - ret = vncAddExtension(); - if (ret == -1) - return; + vncAddExtension(); vncSelectionInit(); @@ -240,17 +232,12 @@ void vncExtensionInit(void) vncHooksInit(scr); } } catch (rdr::Exception& e) { - vlog.error("vncExtInit: %s",e.str()); + vncFatalError("vncExtInit: %s",e.str()); } vncRegisterBlockHandlers(); } -int vncExtensionIsActive(int scrIdx) -{ - return (desktop[scrIdx] != NULL); -} - void vncHandleSocketEvent(int fd, int scrIdx, int read, int write) { desktop[scrIdx]->handleSocketEvent(fd, read, write); @@ -259,8 +246,7 @@ void vncHandleSocketEvent(int fd, int scrIdx, int read, int write) void vncCallBlockHandlers(int* timeout) { for (int scr = 0; scr < vncGetScreenCount(); scr++) - if (desktop[scr]) - desktop[scr]->blockHandler(timeout); + desktop[scr]->blockHandler(timeout); } int vncGetAvoidShiftNumLock(void) @@ -280,27 +266,18 @@ int vncGetSendPrimary(void) void vncUpdateDesktopName(void) { - for (int scr = 0; scr < vncGetScreenCount(); scr++) { - if (desktop[scr] == NULL) - continue; + for (int scr = 0; scr < vncGetScreenCount(); scr++) desktop[scr]->setDesktopName(desktopName); - } } void vncServerCutText(const char *text, size_t len) { - for (int scr = 0; scr < vncGetScreenCount(); scr++) { - if (desktop[scr] == NULL) - continue; + for (int scr = 0; scr < vncGetScreenCount(); scr++) desktop[scr]->serverCutText(text, len); - } } int vncConnectClient(const char *addr) { - if (desktop[0] == NULL) - return -1; - if (strlen(addr) == 0) { try { desktop[0]->disconnectClients(); @@ -332,8 +309,6 @@ void vncGetQueryConnect(uint32_t *opaqueId, const char**username, const char **address, int *timeout) { for (int scr = 0; scr < vncGetScreenCount(); scr++) { - if (desktop[scr] == NULL) - continue; desktop[scr]->getQueryConnect(opaqueId, username, address, timeout); if (opaqueId != 0) break; @@ -343,8 +318,6 @@ void vncGetQueryConnect(uint32_t *opaqueId, const char**username, void vncApproveConnection(uint32_t opaqueId, int approve) { for (int scr = 0; scr < vncGetScreenCount(); scr++) { - if (desktop[scr] == NULL) - continue; desktop[scr]->approveConnection(opaqueId, approve, "Connection rejected by local user"); } @@ -352,11 +325,8 @@ void vncApproveConnection(uint32_t opaqueId, int approve) void vncBell() { - for (int scr = 0; scr < vncGetScreenCount(); scr++) { - if (desktop[scr] == NULL) - continue; + for (int scr = 0; scr < vncGetScreenCount(); scr++) desktop[scr]->bell(); - } } void vncSetLEDState(unsigned long leds) @@ -371,11 +341,8 @@ void vncSetLEDState(unsigned long leds) if (leds & (1 << 2)) state |= ledScrollLock; - for (int scr = 0; scr < vncGetScreenCount(); scr++) { - if (desktop[scr] == NULL) - continue; + for (int scr = 0; scr < vncGetScreenCount(); scr++) desktop[scr]->setLEDState(state); - } } void vncAddChanged(int scrIdx, const struct UpdateRect *extents, @@ -402,11 +369,8 @@ void vncAddCopied(int scrIdx, const struct UpdateRect *extents, void vncSetCursor(int width, int height, int hotX, int hotY, const unsigned char *rgbaData) { - for (int scr = 0; scr < vncGetScreenCount(); scr++) { - if (desktop[scr] == NULL) - continue; + for (int scr = 0; scr < vncGetScreenCount(); scr++) desktop[scr]->setCursor(width, height, hotX, hotY, rgbaData); - } } void vncPreScreenResize(int scrIdx) diff --git a/unix/xserver/hw/vnc/vncExtInit.h b/unix/xserver/hw/vnc/vncExtInit.h index 99fee27e..e8294340 100644 --- a/unix/xserver/hw/vnc/vncExtInit.h +++ b/unix/xserver/hw/vnc/vncExtInit.h @@ -37,7 +37,7 @@ extern "C" { // vncExt.c extern int vncNoClipboard; -int vncAddExtension(void); +void vncAddExtension(void); int vncNotifyQueryConnect(void); @@ -48,7 +48,6 @@ extern int vncFbstride[]; extern int vncInetdSock; void vncExtensionInit(void); -int vncExtensionIsActive(int scrIdx); void vncHandleSocketEvent(int fd, int scrIdx, int read, int write); void vncCallBlockHandlers(int* timeout); diff --git a/unix/xserver/hw/vnc/xvnc.c b/unix/xserver/hw/vnc/xvnc.c index 288ea5e6..b80863ab 100644 --- a/unix/xserver/hw/vnc/xvnc.c +++ b/unix/xserver/hw/vnc/xvnc.c @@ -1781,16 +1781,8 @@ void ProcessInputEvents(void) mieqProcessInputEvents(); } -// InitInput is called after InitExtensions, so we're guaranteed that -// vncExtensionInit() has already been called. - void InitInput(int argc, char *argv[]) { - int i; - for (i = 0;i < screenInfo.numScreens;i++) { - if (!vncExtensionIsActive(i)) - FatalError("failed to activate VNC extension for one or more screens"); - } mieqInit (); } -- 2.39.5