Commit 974fc5f2 authored by Claes's avatar Claes Committed by Esteban Blanc

remote rabbitmq, startup and timeout bugfix

parent 73a09ad5
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <amqp_tcp_socket.h> #include <amqp_tcp_socket.h>
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <unistd.h>
#include "pwr_baseclasses.h" #include "pwr_baseclasses.h"
#include "pwr_class.h" #include "pwr_class.h"
...@@ -151,11 +152,16 @@ int rmq_connect() ...@@ -151,11 +152,16 @@ int rmq_connect()
return 0; return 0;
} }
sts = amqp_socket_open(ctx->socket, ctx->op->Server, ctx->op->Port); while (1) {
if (sts) { sts = amqp_socket_open(ctx->socket, ctx->op->Server, ctx->op->Port);
printf("Socket open error %d\n", sts); if (sts) {
ctx->socket = 0; errh_Error("Socket open error %d", sts);
return 0; sleep(10);
}
else {
errh_Info("Socket opened");
break;
}
} }
} }
...@@ -265,7 +271,7 @@ unsigned int rmq_receive() ...@@ -265,7 +271,7 @@ unsigned int rmq_receive()
remtrans_item* remtrans; remtrans_item* remtrans;
amqp_rpc_reply_t ret; amqp_rpc_reply_t ret;
amqp_envelope_t envelope; amqp_envelope_t envelope;
struct timeval t = { 2, 0 }; struct timeval t = {0, 0};
rabbit_header header; rabbit_header header;
int msg_received = 0; int msg_received = 0;
...@@ -373,6 +379,7 @@ unsigned int rmq_receive() ...@@ -373,6 +379,7 @@ unsigned int rmq_receive()
} }
if (search_remtrans) { if (search_remtrans) {
rn_rmq->ErrCount++; rn_rmq->ErrCount++;
msg_received = 1;
errh_Info("No remtrans for received message, queue %s, class %d, type %d", errh_Info("No remtrans for received message, queue %s, class %d, type %d",
rn_rmq->ReceiveQueue, header.msg_id[0], header.msg_id[1]); rn_rmq->ReceiveQueue, header.msg_id[0], header.msg_id[1]);
} }
...@@ -591,10 +598,8 @@ int main(int argc, char* argv[]) ...@@ -591,10 +598,8 @@ int main(int argc, char* argv[])
} }
aproc_TimeStamp(TIME_INCR, 5); aproc_TimeStamp(TIME_INCR, 5);
if (ctx->is_consumer) sts = rmq_receive();
sts = rmq_receive(); RemoteSleep(TIME_INCR);
else
RemoteSleep(TIME_INCR);
time_since_scan += TIME_INCR; time_since_scan += TIME_INCR;
if (time_since_scan >= rn_rmq->ScanTime) { if (time_since_scan >= rn_rmq->ScanTime) {
......
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