summaryrefslogtreecommitdiff
path: root/agni.c
diff options
context:
space:
mode:
Diffstat (limited to 'agni.c')
-rw-r--r--agni.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/agni.c b/agni.c
index 968ea45..9ad547c 100644
--- a/agni.c
+++ b/agni.c
@@ -447,13 +447,11 @@ int th_start_client(void *data)
//if (token_cmp(itok,3,":join") == 1)
if (strncmp(":join",msg,5)==0)
{
- //PNL();
//lets check if one more argument is there
-
{
char *chan_name=NULL;
int iter=0;
- char *sep_chan = strchr(msg,' ')+1;
+ char *sep_chan = strchr(msg,' ')+1; //small hack
//check if channel in allowed list, if yes then continue
iter=0;
@@ -466,11 +464,9 @@ int th_start_client(void *data)
//lets join channel
memset(cmd_buf, 0, TH_CONN_BUF_SZ);
int fret = snprintf(cmd_buf, TH_CONN_BUF_SZ, ":%s JOIN %s\r\n", dest_name, sep_chan);
- PRINT("cmd_buf %s\n", cmd_buf);
write(conn, cmd_buf, fret);
break;
}
- PNL();
iter++;
if (cfg->channels[iter]==NULL)
{
@@ -583,7 +579,8 @@ int th_event_manager(void *data)
{
event_handler_cfg *cfg = data;
atomic_fetch_add(&cfg->running,1);
- mq_ntf_mdt *mq=NULL;
+ mq_ntf_mdt *mq=NULL,*mq_cur=NULL;
+ int i_mq=0; //to iter trought mqueue
char *out_buf = NULL;
int run;
int mq_event;
@@ -656,6 +653,7 @@ int th_event_manager(void *data)
while(run)
{
//check if there is some message and save it to buffer
+ /*
run += 1;
mq_event = mq_ntf_select(mq, MQ_OUT);
switch(mq_event)
@@ -678,6 +676,31 @@ int th_event_manager(void *data)
default:
printf("Unknown event type\n");
}
+ */
+ run += 1;
+
+ for (i_mq=0;i_mq<cfg->mq_num;i_mq++)
+ {
+ mq = cfg->mq_listen;
+ mq_event = mq_ntf_select(&mq[i_mq], MQ_OUT);
+ mq_cur = &mq[i_mq];
+ if (mq_event == 1)
+ {
+ PRINT("MQ_EVENT OUT\n");
+ memset(out_buf, 0, out_attr.mq_msgsize);
+ //will fail if some of queue have different buffer size param
+ if (mq_ntf_read(&mq[i_mq], MQ_OUT, out_buf, out_attr.mq_msgsize) == -1)
+ {
+ printf("Cant read output message\n");
+ } else
+ {
+ out_buf[out_attr.mq_msgsize-1] = 0x0;
+ printf("Recieve %s\n", out_buf);
+ }
+ break;
+ }
+ } //mq_cur have currently queue where message comes from, need to make some buffer that gona pass/save this info
+
//if QUIT then quit the thread
if (mq_event == 1)
@@ -722,7 +745,7 @@ int th_event_manager(void *data)
);
char *cmdBuf = mq_cmd_buf(privcmd);
- mq_ntf_write(mq, MQ_IN, cmdBuf, strlen(cmdBuf));
+ mq_ntf_write(mq_cur, MQ_IN, cmdBuf, strlen(cmdBuf));
mq_cmd_free(privcmd);
}