render_list was not blocking on requests and would swamp renderd with requests

This commit is contained in:
Kai Krueger
2013-12-24 01:03:20 +01:00
parent 949fdc16c7
commit 13da3afe70
4 changed files with 10 additions and 10 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;
}

View File

@ -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);