X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=ossec-hids.git;a=blobdiff_plain;f=src%2Fremoted%2Fsendmsg.c;h=0c6e2ad06607313abc34199c56a597b41d8ae0a7;hp=12556dbab72888889fdd7555f130dd15eaf67a8b;hb=6ef2f786c6c8ead94841b5f93baf9f43421f08c8;hpb=301048b51990573e58a30dc4a5bb4ec285cad554 diff --git a/src/remoted/sendmsg.c b/src/remoted/sendmsg.c index 12556db..0c6e2ad 100755 --- a/src/remoted/sendmsg.c +++ b/src/remoted/sendmsg.c @@ -1,4 +1,5 @@ -/* @(#) $Id$ */ +/* @(#) $Id: ./src/remoted/sendmsg.c, 2011/09/08 dcid Exp $ + */ /* Copyright (C) 2009 Trend Micro Inc. * All right reserved. @@ -64,9 +65,9 @@ int check_keyupdate() { return(0); } - + key_lock(); - + /* Locking before using */ if(pthread_mutex_lock(&sendmsg_mutex) != 0) { @@ -74,7 +75,7 @@ int check_keyupdate() merror(MUTEX_ERROR, ARGV0); return(0); } - + if(OS_UpdateKeys(&keys)) { if(pthread_mutex_unlock(&sendmsg_mutex) != 0) @@ -90,7 +91,7 @@ int check_keyupdate() merror(MUTEX_ERROR, ARGV0); } key_unlock(); - + return(0); } @@ -105,7 +106,7 @@ void send_msg_init() } -/* send_msg() +/* send_msg() * Send message to an agent. * Returns -1 on error */ @@ -121,7 +122,7 @@ int send_msg(int agentid, char *msg) return(-1); } - + msg_size = CreateSecMSG(&keys, msg, crypt_msg, agentid); if(msg_size == 0) { @@ -129,7 +130,7 @@ int send_msg(int agentid, char *msg) return(-1); } - + /* Locking before using */ if(pthread_mutex_lock(&sendmsg_mutex) != 0) { @@ -141,19 +142,19 @@ int send_msg(int agentid, char *msg) /* Sending initial message */ if(sendto(logr.sock, crypt_msg, msg_size, 0, (struct sockaddr *)&keys.keyentries[agentid]->peer_info, - logr.peer_size) < 0) + logr.peer_size) < 0) { merror(SEND_ERROR,ARGV0, keys.keyentries[agentid]->id); } - - + + /* Unlocking mutex */ if(pthread_mutex_unlock(&sendmsg_mutex) != 0) { merror(MUTEX_ERROR, ARGV0); return(-1); } - + return(0); }