Permalink
Browse files

stronger zmq messages check

  • Loading branch information...
Roberto De Ioris
Roberto De Ioris committed Aug 21, 2012
1 parent 8cb5231 commit bdc6e81d7977b8cec5bcbb9f2ed75adabfa38b2e
Showing with 6 additions and 2 deletions.
  1. +1 −0 blastbeat.ini
  2. +5 −2 src/zmq.c
View
@@ -40,6 +40,7 @@ alias = 192.168.173.5:8083
; 1 MB cache
cache = 1
;timeout = 3
zmq = tcp://192.168.173.5:5001
; 100 kbit/s
bandwidth = 100
View
@@ -136,18 +136,21 @@ static void bb_zmq_manage_messages() {
if (i != 4) goto next;
// manage "pong" messages
if (!strncmp(zmq_msg_data(&msg[2]), "pong", zmq_msg_size(&msg[2]))) {
if (!bb_strcmp(zmq_msg_data(&msg[2]), zmq_msg_size(&msg[2]), "pong", 4)) {
manage_ping(zmq_msg_data(&msg[0]), zmq_msg_size(&msg[0]));
goto next;
}
// message with uuid ?
if (zmq_msg_size(&msg[1]) != BB_UUID_LEN) goto next;
// dead/invalid session ?
// dead/invalid session/dealer ?
struct bb_session *bbs = bb_sht_get(zmq_msg_data(&msg[1]));
if (!bbs) goto next;
if (!bbs->dealer) goto next;
if (bb_strcmp(zmq_msg_data(&msg[0]), zmq_msg_size(&msg[0]), bbs->dealer->identity, bbs->dealer->len)) goto next;
// update dealer activity
ev_tstamp now = bb_now;
bbs->last_seen = now;
update_dealer(bbs->dealer, now);

0 comments on commit bdc6e81

Please sign in to comment.