Commit 4d9178dc authored by Gernot Tenchio's avatar Gernot Tenchio

websockets: restore errno after logging an error

parent 9e090406
...@@ -527,7 +527,10 @@ webSocketsDecodeHixie(rfbClientPtr cl, char *dst, int len) ...@@ -527,7 +527,10 @@ webSocketsDecodeHixie(rfbClientPtr cl, char *dst, int len)
n = ws_peek(cl, buf, len*2+2); n = ws_peek(cl, buf, len*2+2);
if (n <= 0) { if (n <= 0) {
/* save errno because rfbErr() will tamper it */
int olderrno = errno;
rfbErr("%s: peek (%d) %m\n", __func__, errno); rfbErr("%s: peek (%d) %m\n", __func__, errno);
errno = olderrno;
return n; return n;
} }
...@@ -642,14 +645,20 @@ webSocketsDecodeHybi(rfbClientPtr cl, char *dst, int len) ...@@ -642,14 +645,20 @@ webSocketsDecodeHybi(rfbClientPtr cl, char *dst, int len)
buf = wsctx->codeBuf; buf = wsctx->codeBuf;
header = (ws_header_t *)wsctx->codeBuf; header = (ws_header_t *)wsctx->codeBuf;
if (-1 == (ret = ws_peek(cl, buf, B64LEN(len) + WSHLENMAX))) { ret = ws_peek(cl, buf, B64LEN(len) + WSHLENMAX);
rfbErr("%s: peek; %m\n", __func__);
goto spor;
}
if (ret < 2) { if (ret < 2) {
rfbErr("%s: peek; got %d bytes\n", __func__, ret); /* save errno because rfbErr() will tamper it */
goto spor; /* Incomplete frame header */ if (-1 == ret) {
int olderrno = errno;
rfbErr("%s: peek; %m\n", __func__);
errno = olderrno;
} else if (0 == ret) {
result = 0;
} else {
errno = EAGAIN;
}
goto spor;
} }
opcode = header->b0 & 0x0f; opcode = header->b0 & 0x0f;
...@@ -691,7 +700,9 @@ webSocketsDecodeHybi(rfbClientPtr cl, char *dst, int len) ...@@ -691,7 +700,9 @@ webSocketsDecodeHybi(rfbClientPtr cl, char *dst, int len)
payload = buf + fhlen + 4; /* header length + mask */ payload = buf + fhlen + 4; /* header length + mask */
if (-1 == (ret = ws_read(cl, buf, total))) { if (-1 == (ret = ws_read(cl, buf, total))) {
int olderrno = errno;
rfbErr("%s: read; %m", __func__); rfbErr("%s: read; %m", __func__);
errno = olderrno;
return ret; return ret;
} else if (ret < total) { } else if (ret < total) {
/* GT TODO: hmm? */ /* GT TODO: hmm? */
......
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