-/* @(#) $Id: mq_op.c,v 1.25 2009/06/24 18:53:08 dcid Exp $ */
+/* @(#) $Id: ./src/shared/mq_op.c, 2011/09/08 dcid Exp $
+ */
/* Copyright (C) 2009 Trend Micro Inc.
* All rights reserved.
*
* This program is a free software; you can redistribute it
* and/or modify it under the terms of the GNU General Public
- * License (version 3) as published by the FSF - Free Software
+ * License (version 2) as published by the FSF - Free Software
* Foundation
*/
*/
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
*/
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);
}
/* Checking for global locks */
os_wait();
-
-
+
+
if(loc == SECURE_MQ)
{
loc = message[0];
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
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.
return(-1);
}
-
+
/* Unable to send. Socket busy */
sleep(1);
if(OS_SendUnix(queue, tmpstr, 0) < 0)
{
/* 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);
}
}