00001 /* SVN FILE INFO 00002 * $Revision: 402 $ : Last Committed Revision 00003 * $Date: 2009-08-23 13:44:39 -0700 (Sun, 23 Aug 2009) $ : Last Committed Date */ 00004 /*[ 00005 * Copyright (c) 2007 Integration Engineering Laboratory 00006 University of California, Davis 00007 * 00008 * Permission to use, copy, and distribute this software and its 00009 * documentation for any purpose with or without fee is hereby granted, 00010 * provided that the above copyright notice appear in all copies and 00011 * that both that copyright notice and this permission notice appear 00012 * in supporting documentation. 00013 * 00014 * Permission to modify the software is granted, but not the right to 00015 * distribute the complete modified source code. Modifications are to 00016 * be distributed as patches to the released version. Permission to 00017 * distribute binaries produced by compiling modified sources is granted, 00018 * provided you 00019 * 1. distribute the corresponding source modifications from the 00020 * released version in the form of a patch file along with the binaries, 00021 * 2. add special version identification to distinguish your version 00022 * in addition to the base release version number, 00023 * 3. provide your name and address as the primary contact for the 00024 * support of your modified version, and 00025 * 4. retain our contact information in regard to use of the base 00026 * software. 00027 * Permission to distribute the released version of the source code along 00028 * with corresponding source modifications in the form of a patch file is 00029 * granted with same provisions 2 through 4 for binary distributions. 00030 * 00031 * This software is provided "as is" without express or implied warranty 00032 * to the extent permitted by applicable law. 00033 ]*/ 00034 #ifndef _WIN32 00035 #include "config.h" 00036 #else 00037 #include "winconfig.h" 00038 #endif 00039 00040 #include <stdio.h> 00041 #include <stdlib.h> 00042 #ifdef _WIN32 00043 #include <windows.h> 00044 #elif defined (HPUX) 00045 #else 00046 #include <pthread.h> 00047 #endif 00048 #include "include/data_structures.h" 00049 #include "include/mc_platform.h" 00050 00051 /********************************************************************** 00052 * Function Name : MessgQueueSendOutgoingMessg 00053 * purpose : parses throught the outoig messg list and sends the messages 00054 * returns : void 00055 * 00056 **********************************************************************/ 00057 void message_queue_SendOutgoing( 00058 struct mc_platform_s* mc_platform, 00059 message_queue_p mqueue 00060 ) 00061 { 00062 /* variables */ 00063 int index = 0; 00064 message_p message; 00065 char* local_address; 00066 local_address = (char*)malloc 00067 ( 00068 sizeof(char) * 00069 (strlen(mc_platform->hostname)+10) 00070 ); 00071 CHECK_NULL(local_address, exit(0)); 00072 sprintf 00073 ( 00074 local_address, 00075 "%s:%d", 00076 mc_platform->hostname, 00077 mc_platform->port 00078 ); 00079 00080 MUTEX_LOCK(mqueue->lock); 00081 while ((message = (message_p)ListSearch(mqueue->list, index))) { 00082 MUTEX_UNLOCK(mqueue->lock); 00083 if (strcmp(message->to_address, local_address)) { 00084 message_Send(mc_platform, message, mc_platform -> private_key); 00085 message_queue_RemoveIndex(mqueue, index); 00086 } else { 00087 index++; 00088 } 00089 MUTEX_LOCK(mqueue->lock); /* Lock again for eval of while statement */ 00090 } 00091 00092 MUTEX_UNLOCK(mqueue->lock); 00093 free(local_address); 00094 return ; 00095 } 00096