X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=ossec-hids.git;a=blobdiff_plain;f=src%2Fshared%2Fmq_op.c;h=3f1d03708576e8bf8fd998b16eaefeec32d79436;hp=81c27721cf15749d6f5430e45fcf45b6ef179a0c;hb=6ef2f786c6c8ead94841b5f93baf9f43421f08c8;hpb=301048b51990573e58a30dc4a5bb4ec285cad554 diff --git a/src/shared/mq_op.c b/src/shared/mq_op.c index 81c2772..3f1d037 100755 --- a/src/shared/mq_op.c +++ b/src/shared/mq_op.c @@ -1,4 +1,5 @@ -/* @(#) $Id$ */ +/* @(#) $Id: ./src/shared/mq_op.c, 2011/09/08 dcid Exp $ + */ /* Copyright (C) 2009 Trend Micro Inc. * All rights reserved. @@ -21,12 +22,12 @@ */ int StartMQ(char * path, short int type) { - + if(type == READ) { return(OS_BindUnixDomain(path, 0660, OS_MAXSTR + 512)); } - + /* We give up to 21 seconds for the other end to * start */ @@ -62,7 +63,7 @@ int StartMQ(char * path, short int type) sleep(2); if((rc = OS_ConnectUnixDomain(path, OS_MAXSTR + 256)) < 0) { - merror(QUEUE_ERROR, __local_name, path, + merror(QUEUE_ERROR, __local_name, path, strerror(errno)); return(-1); } @@ -88,8 +89,8 @@ int SendMSG(int queue, char *message, char *locmsg, char loc) /* Checking for global locks */ os_wait(); - - + + if(loc == SECURE_MQ) { loc = message[0]; @@ -100,9 +101,14 @@ int SendMSG(int queue, char *message, char *locmsg, char loc) merror(FORMAT_ERROR, __local_name); return(0); } - + message++; /* Pointing now to the location */ - + + if(strncmp(message, "keepalive",9) == 0) + { + return(0); + } + snprintf(tmpstr,OS_MAXSTR,"%c:%s->%s",loc, locmsg, message); } else @@ -113,7 +119,7 @@ int SendMSG(int queue, char *message, char *locmsg, char loc) if(queue < 0) return(-1); - + /* We attempt 5 times to send the message if * the receiver socket is busy. * After the first error, we wait 1 second. @@ -134,7 +140,7 @@ int SendMSG(int queue, char *message, char *locmsg, char loc) return(-1); } - + /* Unable to send. Socket busy */ sleep(1); if(OS_SendUnix(queue, tmpstr, 0) < 0) @@ -157,10 +163,10 @@ int SendMSG(int queue, char *message, char *locmsg, char loc) { /* Message is going to be lost * if the application does not care - * about checking the error - */ + * about checking the error + */ close(queue); - queue = -1; + queue = -1; return(-1); } }