mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
Using recv instead of read, for slightly non-blocking reads, without losing blocking writes
This commit is contained in:
@@ -18,17 +18,11 @@ char __GUACIO_BAS64_CHARACTERS[64] = {
|
|||||||
|
|
||||||
GUACIO* guac_open(int fd) {
|
GUACIO* guac_open(int fd) {
|
||||||
|
|
||||||
int flags;
|
|
||||||
|
|
||||||
GUACIO* io = malloc(sizeof(GUACIO));
|
GUACIO* io = malloc(sizeof(GUACIO));
|
||||||
io->ready = 0;
|
io->ready = 0;
|
||||||
io->written = 0;
|
io->written = 0;
|
||||||
io->fd = fd;
|
io->fd = fd;
|
||||||
|
|
||||||
/* Set O_NONBLOCK */
|
|
||||||
flags = fcntl(io->fd, F_GETFL, 0);
|
|
||||||
fcntl(io->fd, F_SETFL, flags | O_NONBLOCK);
|
|
||||||
|
|
||||||
/* Allocate instruction buffer */
|
/* Allocate instruction buffer */
|
||||||
io->instructionbuf_size = 1024;
|
io->instructionbuf_size = 1024;
|
||||||
io->instructionbuf = malloc(io->instructionbuf_size);
|
io->instructionbuf = malloc(io->instructionbuf_size);
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
typedef struct GUACIO {
|
typedef struct GUACIO {
|
||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
int ready;
|
int ready;
|
||||||
int ready_buf[3];
|
int ready_buf[3];
|
||||||
|
@@ -4,6 +4,9 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <png.h>
|
#include <png.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
|
|
||||||
#include "guacio.h"
|
#include "guacio.h"
|
||||||
#include "protocol.h"
|
#include "protocol.h"
|
||||||
|
|
||||||
@@ -181,10 +184,11 @@ int __guac_fill_instructionbuf(GUACIO* io) {
|
|||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
/* Attempt to fill buffer */
|
/* Attempt to fill buffer */
|
||||||
retval = read(
|
retval = recv(
|
||||||
io->fd,
|
io->fd,
|
||||||
io->instructionbuf + io->instructionbuf_used_length,
|
io->instructionbuf + io->instructionbuf_used_length,
|
||||||
io->instructionbuf_size - io->instructionbuf_used_length
|
io->instructionbuf_size - io->instructionbuf_used_length,
|
||||||
|
0
|
||||||
);
|
);
|
||||||
|
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
|
Reference in New Issue
Block a user