Skip to content

Commit 36413f2

Browse files
authored
libvncserver/httpd: tape on mutex init/deinit
A workaround to the very awkward static rfbClient usage in httpd.c Closes #656
1 parent eae4f70 commit 36413f2

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/libvncserver/httpd.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ static size_t buf_filled=0;
8989
* httpInitSockets sets up the TCP socket to listen for HTTP connections.
9090
*/
9191

92+
static rfbClientRec cl;
93+
9294
void
9395
rfbHttpInitSockets(rfbScreenInfoPtr rfbScreen)
9496
{
@@ -125,6 +127,9 @@ rfbHttpInitSockets(rfbScreenInfoPtr rfbScreen)
125127
rfbLog("Listening for HTTP connections on TCP6 port %d\n", rfbScreen->http6Port);
126128
rfbLog(" URL http://%s:%d\n",rfbScreen->thisHost,rfbScreen->http6Port);
127129
#endif
130+
INIT_MUTEX(cl.outputMutex);
131+
INIT_MUTEX(cl.refCountMutex);
132+
INIT_MUTEX(cl.sendMutex);
128133
}
129134

130135
void rfbHttpShutdownSockets(rfbScreenInfoPtr rfbScreen) {
@@ -145,6 +150,17 @@ void rfbHttpShutdownSockets(rfbScreenInfoPtr rfbScreen) {
145150
rfbCloseSocket(rfbScreen->httpListen6Sock);
146151
rfbScreen->httpListen6Sock=RFB_INVALID_SOCKET;
147152
}
153+
LOCK(cl.outputMutex);
154+
UNLOCK(cl.outputMutex);
155+
TINI_MUTEX(cl.outputMutex);
156+
157+
LOCK(cl.sendMutex);
158+
UNLOCK(cl.sendMutex);
159+
TINI_MUTEX(cl.sendMutex);
160+
161+
LOCK(cl.refCountMutex);
162+
UNLOCK(cl.refCountMutex);
163+
TINI_MUTEX(cl.refCountMutex);
148164
}
149165

150166
/*
@@ -257,8 +273,6 @@ httpCloseSock(rfbScreenInfoPtr rfbScreen)
257273
buf_filled = 0;
258274
}
259275

260-
static rfbClientRec cl;
261-
262276
/*
263277
* httpProcessInput is called when input is received on the HTTP socket.
264278
*/

0 commit comments

Comments
 (0)