mirror of
https://github.com/openstreetmap/mod_tile.git
synced 2025-07-29 11:44:17 +00:00
render_list was not blocking on requests and would swamp renderd with requests
This commit is contained in:
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user