diff --git a/includes/protocol_helper.h b/includes/protocol_helper.h index 38933d8..62f3323 100644 --- a/includes/protocol_helper.h +++ b/includes/protocol_helper.h @@ -8,7 +8,7 @@ extern "C" { #include "protocol.h" int send_cmd(struct protocol * cmd, int fd); -int recv_cmd(struct protocol * cmd, int fd); +int recv_cmd(struct protocol * cmd, int fd, int block); #ifdef __cplusplus diff --git a/src/daemon.c b/src/daemon.c index b99c336..4cdcb3f 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -212,7 +212,7 @@ void process_loop(int listen_fd) memset(&cmd,0,sizeof(cmd)); // TODO: to get highest performance we should loop here until we get EAGAIN - ret = recv_cmd(&cmd, fd); + ret = recv_cmd(&cmd, fd, 0); if (ret < 1) { int j; diff --git a/src/protocol_helper.c b/src/protocol_helper.c index 7505b71..2deada6 100644 --- a/src/protocol_helper.c +++ b/src/protocol_helper.c @@ -7,7 +7,7 @@ int send_cmd(struct protocol * cmd, int fd) { int ret; - syslog(LOG_DEBUG, "DEBUG: Sending render cmd with protocol version %i\n", cmd->ver); + syslog(LOG_DEBUG, "DEBUG: Sending render cmd(%i) with protocol version %i\n", cmd->cmd, cmd->ver); if ((cmd->ver > 3) || (cmd->ver < 1)) { syslog(LOG_WARNING, "WARNING: Failed to send render cmd with unknown protocol version %i\n", cmd->ver); return -1; @@ -29,10 +29,10 @@ int send_cmd(struct protocol * cmd, int fd) { return ret; } -int recv_cmd(struct protocol * cmd, int fd) { +int recv_cmd(struct protocol * cmd, int fd, int block) { int ret, ret2; memset(cmd,0,sizeof(*cmd)); - ret = recv(fd, cmd, sizeof(struct protocol_v1), MSG_DONTWAIT); + ret = recv(fd, cmd, sizeof(struct protocol_v1), block?MSG_WAITALL:MSG_DONTWAIT); if (ret < 1) { return -1; } else if (ret < sizeof(struct protocol_v1)) { @@ -47,9 +47,9 @@ int recv_cmd(struct protocol * cmd, int fd) { case 1: ret2 = 0; break; - case 2: ret2 = recv(fd, ((void*)cmd) + sizeof(struct protocol_v1), sizeof(struct protocol_v2) - sizeof(struct protocol_v1), MSG_DONTWAIT); + case 2: ret2 = recv(fd, ((void*)cmd) + sizeof(struct protocol_v1), sizeof(struct protocol_v2) - sizeof(struct protocol_v1), block?MSG_WAITALL:MSG_DONTWAIT); break; - case 3: ret2 = recv(fd, ((void*)cmd) + sizeof(struct protocol_v1), sizeof(struct protocol) - sizeof(struct protocol_v1), MSG_DONTWAIT); + case 3: ret2 = recv(fd, ((void*)cmd) + sizeof(struct protocol_v1), sizeof(struct protocol) - sizeof(struct protocol_v1), block?MSG_WAITALL:MSG_DONTWAIT); break; } diff --git a/src/render_submit_queue.c b/src/render_submit_queue.c index 376bf4f..5d63987 100644 --- a/src/render_submit_queue.c +++ b/src/render_submit_queue.c @@ -77,13 +77,13 @@ static int process(struct protocol * cmd, int fd) //printf("Waiting for response\n"); bzero(&rsp, sizeof(rsp)); - ret = recv_cmd(&rsp, fd); + ret = recv_cmd(&rsp, fd,1); if (ret < 1) return 0; - //printf("Got response\n"); + //printf("Got response %i\n", rsp.cmd); if (rsp.cmd != cmdDone) { - printf("rendering failed, pausing\n"); + printf("rendering failed with command %i, pausing.\n", rsp.cmd); sleep(10); } else { gettimeofday(&tim, NULL);