void rmq_process(int rank) { /* init blocking reader */ rmq_init_reader(); rmq_send_t * rmqs; /* waiting for commands */ for (;;) { rmqs = rmq_receive(); if (!rmqs || !rmqs->sock) { LM_ERR("invalid receive sock info received\n"); goto end; } /* check if we should disconnect it */ if (!rmqs->msg[0]) { rmq_destroy(rmqs->sock); goto end; } /* check if we should reconnect */ if (rmq_reconnect(rmqs->sock) < 0) { LM_ERR("cannot reconnect socket\n"); goto end; } /* send msg */ if (rmq_sendmsg(rmqs)) LM_ERR("cannot send message\n"); end: if (rmqs) shm_free(rmqs); } }
static void rmq_free(evi_reply_sock *sock) { rmq_send_t *rmqs = shm_malloc(sizeof(rmq_send_t) + 1); if (!rmqs) { LM_ERR("no more shm memory\n"); goto destroy; } rmqs->sock = sock; rmqs->msg[0] = 0; if (rmq_send(rmqs) < 0) { LM_ERR("cannot send message\n"); goto destroy; } return; destroy: if (rmqs) shm_free(rmqs); rmq_destroy(sock); }