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