Mixe for Privacy and Anonymity in the Internet
Functions | Variables
proxytest.cpp File Reference
#include "StdAfx.h"
#include "CACmdLnOptions.hpp"
#include "CAMsg.hpp"
#include "CALocalProxy.hpp"
#include "CAQueue.hpp"
#include "CAThreadList.hpp"
#include "CAStatusManager.hpp"
#include "CALibProxytest.hpp"
#include "CACryptoBenchmark.hpp"
#include "UDPMix/CAUDPMixMiddle.hpp"
#include "CAMiddleMix.hpp"
#include "xml/DOM_Output.hpp"
#include "CAMix.hpp"
#include "TypeA/CAFirstMixA.hpp"
#include "TypeA/CALastMixA.hpp"
#include "CALogPacketStats.hpp"
#include "CATLSClientSocket.hpp"
Include dependency graph for proxytest.cpp:

Go to the source code of this file.

Functions

void removePidFile ()
 Removes the stored PID (file) More...
 
void init ()
 do necessary initialisations of libraries etc. More...
 
void cleanup ()
 do necessary cleanups of libraries etc. More...
 
void my_terminate (void)
 Remark: terminate() might be already defined by the c lib – do not use this name... More...
 
void signal_segv (int)
 
void signal_term (int)
 
void signal_interrupt (int)
 
void signal_hup (int)
 
void checkSizesOfTypes ()
 Check what the sizes of (base) types are as expected – if not kill the programm. More...
 
int main (int argc, const char *argv[])
 

Variables

CAMixpMix =NULL
 
bool bTriedTermination = false
 

Function Documentation

◆ checkSizesOfTypes()

void checkSizesOfTypes ( )

Check what the sizes of (base) types are as expected – if not kill the programm.

Definition at line 262 of file proxytest.cpp.

263  {
264 #ifdef _MSC_VER
265  #pragma warning( push )
266  #pragma warning( disable : 4127 ) //Disable: Bedingter Ausdruck ist konstant
267 #endif
268  if(sizeof(SINT8)!=1)
269  {
270  CAMsg::printMsg(LOG_CRIT,"sizeof(SINT8) != 1 --> maybe a compiler (optimization) problem!\n");
271  exit(-1);
272  }
273  if(sizeof(UINT8)!=1)
274  {
275  CAMsg::printMsg(LOG_CRIT,"sizeof(UINT8) != 1 --> maybe a compiler (optimization) problem!\n");
276  exit(-1);
277  }
278  if(sizeof(SINT16)!=2)
279  {
280  CAMsg::printMsg(LOG_CRIT,"sizeof(SINT16) != 2 --> maybe a compiler (optimization) problem!\n");
281  exit(-1);
282  }
283  if(sizeof(UINT16)!=2)
284  {
285  CAMsg::printMsg(LOG_CRIT,"sizeof(UINT16) != 2 --> maybe a compiler (optimization) problem!\n");
286  exit(-1);
287  }
288  if(sizeof(SINT32)!=4)
289  {
290  CAMsg::printMsg(LOG_CRIT,"sizeof(SINT32) != 4 --> maybe a compiler (optimization) problem!\n");
291  exit(-1);
292  }
293  if(sizeof(UINT32)!=4)
294  {
295  CAMsg::printMsg(LOG_CRIT,"sizeof(UINT32) != 4 --> maybe a compiler (optimization) problem!\n");
296  exit(-1);
297  }
298  #ifdef HAVE_NATIVE_UINT64
299  if(sizeof(UINT64)!=8)
300  {
301  CAMsg::printMsg(LOG_CRIT,"sizeof(UINT64) != 8 --> maybe a compiler (optimization) problem!\n");
302  exit(-1);
303  }
304  #endif
305 
306 #ifdef _MSC_VER
307  #pragma warning( pop )
308 #endif
309 
310  #ifndef NEW_MIX_TYPE
311  if (MIXPACKET_SIZE != sizeof(MIXPACKET))
312  {
313  CAMsg::printMsg(LOG_CRIT, "MIXPACKET_SIZE [%u] != sizeof(MUXPACKET) [%u] --> maybe a compiler (optimization) problem!\n", MIXPACKET_SIZE, sizeof(MIXPACKET));
314  CAMsg::printMsg(LOG_CRIT, "Offsets:\n");
315  MIXPACKET oPacket;
316  UINT8 *p = (UINT8 *)&oPacket;
317  UINT32 soffsets[7] = { 0, 4, 6, 6, 6, 8, 9 };
318  UINT32 hoffsets[7];
319  CAMsg::printMsg(LOG_CRIT, ".channel %u (should be 0)\n", hoffsets[0] = (UINT8 *)&(oPacket.channel) - p);
320  CAMsg::printMsg(LOG_CRIT, ".flags: %u (should be 4)\n", hoffsets[1] = (UINT8 *)&oPacket.flags - p);
321  CAMsg::printMsg(LOG_CRIT, ".data: %u (should be 6)\n", hoffsets[2] = (UINT8 *)&oPacket.data - p);
322  CAMsg::printMsg(LOG_CRIT, ".payload: %u (should be 6)\n", hoffsets[3] = (UINT8 *)&oPacket.payload - p);
323  CAMsg::printMsg(LOG_CRIT, ".payload.len: %u (should be 6)\n", hoffsets[4] = (UINT8 *)&oPacket.payload.len - p);
324  CAMsg::printMsg(LOG_CRIT, ".payload.type: %u (should be 8)\n", hoffsets[5] = (UINT8 *)&oPacket.payload.type - p);
325  CAMsg::printMsg(LOG_CRIT, ".payload.data: %u (should be 9)\n", hoffsets[6] = (UINT8 *)&oPacket.payload.data - p);
326  for (int i = 0; i < 7; i++)
327  if (soffsets[i] != hoffsets[i])
328  exit(EXIT_FAILURE);
329  CAMsg::printMsg(LOG_CRIT, "Hm, The Offsets seams to be ok - so we try to continue - hope that works...\n");
330  }
331 #endif
332  if (UDPMIXPACKET_SIZE != sizeof(UDPMIXPACKET))
333  {
334  CAMsg::printMsg(LOG_CRIT, "UDPMIXPACKET_SIZE [%u] != sizeof(UDPMUXPACKET) [%u] --> maybe a compiler (optimization) problem!\n", UDPMIXPACKET_SIZE, sizeof(UDPMIXPACKET));
335  }
336  if (UDPMIXPACKET_LINKHEADER_TYPE_SIZE != sizeof(UDPMIXPACKET_LINKHEADER))
337  {
338  CAMsg::printMsg(LOG_CRIT, "UDPMIXPACKET_LINKHEADER_TYPE_SIZE [%u] != sizeof(UDPMIXPACKET_LINKHEADER) [%u] --> maybe a compiler (optimization) problem!\n", UDPMIXPACKET_LINKHEADER_TYPE_SIZE, sizeof(UDPMIXPACKET_LINKHEADER));
339  }
340 
341  }
unsigned short UINT16
Definition: basetypedefs.h:133
signed short SINT16
Definition: basetypedefs.h:134
signed int SINT32
Definition: basetypedefs.h:132
signed char SINT8
Definition: basetypedefs.h:136
unsigned char UINT8
Definition: basetypedefs.h:135
unsigned int UINT32
Definition: basetypedefs.h:131
static SINT32 printMsg(UINT32 typ, const char *format,...)
Writes a given message to the log.
Definition: CAMsg.cpp:251
HCHANNEL channel
Definition: typedefs.hpp:117
struct t_MixPacketPayload payload
Definition: typedefs.hpp:122
UINT8 data[DATA_SIZE]
Definition: typedefs.hpp:121
UINT16 flags
Definition: typedefs.hpp:118
UINT8 data[PAYLOAD_SIZE]
Definition: typedefs.hpp:113
#define MIXPACKET_SIZE
Definition: typedefs.hpp:40

References t_MixPacket::channel, t_MixPacket::data, t_MixPacketPayload::data, t_MixPacket::flags, t_MixPacketPayload::len, MIXPACKET_SIZE, t_MixPacket::payload, CAMsg::printMsg(), and t_MixPacketPayload::type.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup()

void cleanup ( )

do necessary cleanups of libraries etc.

Definition at line 151 of file proxytest.cpp.

152  {
153 #ifdef ENABLE_GPERFTOOLS_CPU_PROFILER
154  ProfilerFlush();
155  ProfilerStop();
156 #endif
157 // delete pRTT;
158 #ifndef ONLY_LOCAL_PROXY
159  if(pMix!=NULL)
160  delete pMix;
161  pMix=NULL;
162 #endif
163  CAMsg::printMsg(LOG_CRIT,"Terminating Programm!\n");
164  removePidFile();
166 #if defined(HAVE_CRTDBG)
167  _CrtMemCheckpoint( &s2 );
168  if ( _CrtMemDifference( &s3, s1, &s2 ) )
169  _CrtMemDumpStatistics( &s3 );
170  else
171  {
172  printf("Memory leak check clean!\n");
173  }
174  delete s1;
175 #endif
176 #ifdef CWDEBUG
177  Debug(list_allocations_on(libcw_do));
178 #endif
179  }
static SINT32 cleanup()
do necessary cleanups of libraries etc.
CAMix * pMix
Definition: proxytest.cpp:75
void removePidFile()
Removes the stored PID (file)
Definition: proxytest.cpp:122

References CALibProxytest::cleanup(), pMix, CAMsg::printMsg(), and removePidFile().

Referenced by CAAccountingInstance::__newSettlementTransaction(), CALibProxytest::cleanup(), main(), and my_terminate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init()

void init ( )

do necessary initialisations of libraries etc.

Definition at line 145 of file proxytest.cpp.

146  {
148  }
static SINT32 init()
do necessary initialisations of libraries etc.

References CALibProxytest::init().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
const char *  argv[] 
)

Definition at line 519 of file proxytest.cpp.

520  {
521  SINT32 exitCode=0;
522 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_MIDDLE_MIX || defined INLUDE_LAST_MIX|| defined INLUDE_FIRST_MIX
523  pMix=NULL;
524 #endif
525 #if defined(HAVE_CRTDBG)
526 // _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE );
527  _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDOUT );
528 // _CrtSetReportMode( _CRT_ERROR, _CRTDBG_MODE_FILE );
529  _CrtSetReportFile( _CRT_ERROR, _CRTDBG_FILE_STDOUT );
530 // _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_FILE );
531  _CrtSetReportFile( _CRT_ASSERT, _CRTDBG_FILE_STDOUT );
532 
533  UINT32 tmpDbgFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
534  tmpDbgFlag |= _CRTDBG_ALLOC_MEM_DF;
535  tmpDbgFlag |=_CRTDBG_LEAK_CHECK_DF;
536  _CrtSetDbgFlag(tmpDbgFlag);
537  s1=new _CrtMemState;
538  _CrtMemCheckpoint( s1 );
539 #endif
540 //Switch on debug infos
541 #ifdef CWDEBUG
542  Debug(libcw_do.on());
543  Debug(dc::malloc.on());
544 #endif
545  init();
547 #ifdef LOG_CRIME
548 // testTre();
549 #endif
550 
551 #ifdef REPLAY_DATABASE_PERFORMANCE_TEST
552  CAReplayDatabase::measurePerformance((UINT8*)"dbperformace.log",1,10000001,500000,10,100000);
553  exit(0);
554 #endif
555 
556 
557 #ifdef DATA_RETENTION_LOG
558  if(sizeof(t_dataretentionLogEntry)!=18)
559  {
560  CAMsg::printMsg(LOG_CRIT,"sizeof(tDataRetentionLogEntry) [%u] != 18 --> maybe a compiler (optimization) problem!\n",sizeof(t_dataretentionLogEntry));
561  exit(EXIT_FAILURE);
562  }
563 #endif
564 
565 #ifdef _DEBUG
566  UINT32 start;
567 #endif
568  /*
569  CAUDPMiddleMix *pM = new CAUDPMiddleMix();
570 pM->start();
571 exit(0);
572 */
573  if(CALibProxytest::getOptions()->parse(argc,argv) != E_SUCCESS)
574  {
575  CAMsg::printMsg(LOG_CRIT,"An error occurred before we could finish parsing the configuration file. Exiting...\n");
576  exitCode=EXIT_FAILURE;
577  goto EXIT;
578  }
579 
580  if (CALibProxytest::getOptions()->getCryptoBenchmark())
581  {
582  CACryptoBenchmark* pCryptoBenchmark = new CACryptoBenchmark();
583  pCryptoBenchmark->doBenchmark();
584  exit(0);
585  }
586 
587 
588 
589  if(!( CALibProxytest::getOptions()->isFirstMix()||
590  CALibProxytest::getOptions()->isMiddleMix()||
591  CALibProxytest::getOptions()->isLastMix()||
592  CALibProxytest::getOptions()->isLocalProxy()))
593  {
594  CAMsg::printMsg(LOG_CRIT,"You must specify which kind of Mix you want to run!\n");
595  CAMsg::printMsg(LOG_CRIT,"Use -j or -c\n");
596  CAMsg::printMsg(LOG_CRIT,"Or try --help for more options.\n");
597  CAMsg::printMsg(LOG_CRIT,"Exiting...\n");
598  exitCode=EXIT_FAILURE;
599  goto EXIT;
600  }
601 
602 #ifndef _WIN32
603  if(CALibProxytest::getOptions()->getDaemon())
604  {
605  CAMsg::printMsg(LOG_DEBUG,"Starting mix process as daemon...\n");
606  CAMsg::cleanup();
607  CAMsg::init();
608  pid_t pid;
609  pid=fork();
610  if(pid!=0)
611  {
612  CAMsg::printMsg(LOG_INFO,"Exiting parent shell process...\n");
613  exit(EXIT_SUCCESS);
614  }
615  setsid();
616  #ifndef DO_TRACE
617  chdir("/");
618  umask(0);
619  #endif
620  // Close out the standard file descriptors
621  close(STDIN_FILENO);
622  close(STDOUT_FILENO);
623  close(STDERR_FILENO);
624  }
625 #endif
626 
627 
628  if (CALibProxytest::getOptions()->initLogging() != E_SUCCESS)
629  {
630  exitCode=EXIT_FAILURE;
631  goto EXIT;
632  }
633 
634 
635 
636  CAMsg::printMsg(LOG_CRIT,"Anon proxy started!\n");
637  CAMsg::printMsg(LOG_CRIT, "LogLevel: %s\n", CAMsg::getLogLevelStr());
638 
639 #ifdef ENABLE_GPERFTOOLS_CPU_PROFILER
640  ProfilerStart("gperf.cpuprofiler.data");
641  ProfilerRegisterThread();
642 #endif
643 
644 #ifndef _WIN32
645  #ifdef _DEBUG
646  signal(SIGPIPE,signal_broken_pipe);
647  #else
648  signal(SIGPIPE,SIG_IGN);
649  #endif
650  #ifndef ONLY_LOCAL_PROXY
651  struct sigaction newAction;
652  memset(&newAction,0,sizeof(newAction));
653  newAction.sa_handler=signal_hup;
654  newAction.sa_flags=0;
655  sigaction(SIGHUP,&newAction,NULL);
656  #endif
657 #endif
658  signal(SIGINT,signal_interrupt);
659  signal(SIGTERM,signal_term);
660 #if !defined (_DEBUG) && !defined(NO_SIGSEV_CATCH)
661  signal(SIGSEGV,signal_segv);
662 #endif
663  //Try to write pidfile....
664  UINT8 strPidFile[512];
665  if(CALibProxytest::getOptions()->getPidFile(strPidFile,512)==E_SUCCESS)
666  {
667  #ifndef _WIN32
668  int old_uid=geteuid(); //old uid... stored if we have to switch to root
669  #endif
670  pid_t pid=getpid();
671  UINT8 thePid[10];
672  sprintf((char*)thePid,"%i",pid);
673  int len=strlen((char*)thePid);
674  int hFile=open((char*)strPidFile,O_TRUNC|O_CREAT|O_WRONLY,S_IREAD|S_IWRITE);
675 #ifndef _WIN32
676  if(hFile==-1&&seteuid(0)!=-1) //probably we do not have enough rights (because we have already switch to an other uid --> try to go back temporaly..
677  {
678  hFile=open((char*)strPidFile,O_TRUNC|O_CREAT|O_WRONLY,S_IREAD|S_IWRITE);
679  }
680 #endif
681  if(hFile==-1||len!=write(hFile,thePid,len))
682  {
683  #ifndef _WIN32
684  seteuid(old_uid);
685  #endif
686  CAMsg::printMsg(LOG_CRIT,"Could not write pidfile - exiting!\n");
687  exitCode=EXIT_FAILURE;
688  goto EXIT;
689  }
690  close(hFile);
691 #ifndef _WIN32
692  seteuid(old_uid);
693 #endif
694  }
695 
696  if(CALibProxytest::getOptions()->isLocalProxy())
697  {
698  #ifndef NEW_MIX_TYPE
699  CALocalProxy* pProxy=new CALocalProxy();
700  CAMsg::printMsg(LOG_INFO,"Starting LocalProxy...\n");
701  if(pProxy->start()!=E_SUCCESS)
702  CAMsg::printMsg(LOG_CRIT,"Error during MIX-Startup!\n");
703  delete pProxy;
704  pProxy = NULL;
705  #else
706  CAMsg::printMsg(LOG_CRIT,"Compiled without LocalProxy support!\n");
707  exit(EXIT_FAILURE);
708  #endif
709  }
710  else
711  {
712 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_MIDDLE_MIX || defined INCLUDE_LAST_MIX
713  SINT32 s32MaxSockets=10000;//CASocket::getMaxOpenSockets();
714  CAMsg::printMsg(LOG_INFO,"Max Number of sockets we can open: %i\n",s32MaxSockets);
715 
716 #ifdef SERVER_MONITORING
718 #endif
719 
720  if(s32MaxSockets>100&&s32MaxSockets<10000)
721  {
722  CASocket::setMaxNormalSockets(s32MaxSockets-10);
723  }
725 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_FIRST_MIX
726  if(CALibProxytest::getOptions()->isFirstMix())
727  {
728  CAMsg::printMsg(LOG_INFO,"I am the First MIX...\n");
729  #if !defined(NEW_MIX_TYPE)
730  pMix=new CAFirstMixA();
731  #else
732  pMix=new CAFirstMixB();
733  #endif
735  }
736  else
737 #endif
738 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_MIDDLE_MIX
739  if(CALibProxytest::getOptions()->isMiddleMix())
740  {
741  CAMsg::printMsg(LOG_INFO,"I am a Middle MIX...\n");
742  pMix=new CAMiddleMix();
744  }
745 #endif
746 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_LAST_MIX
747  if (CALibProxytest::getOptions()->isLastMix())
748  {
749  CAMsg::printMsg(LOG_INFO,"I am the Last MIX...\n");
750  #if !defined(NEW_MIX_TYPE)
751  pMix=new CALastMixA();
752  #else
753  pMix=new CALastMixB();
754  #endif
756  }
757 #endif
758 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_LAST_MIX
759  if (CALibProxytest::getOptions()->isLastMix())
760  {
761  CAMsg::printMsg(LOG_INFO,"I am the Last MIX...\n");
762  #if !defined(NEW_MIX_TYPE)
763  pMix=new CALastMixA();
764  #else
765  pMix=new CALastMixB();
766  #endif
768  }
769 #else
770  CAMsg::printMsg(LOG_ERR,"this Mix is compiled to work only as local proxy!\n");
771  exit(EXIT_FAILURE);
772 #endif
773  }
774 #ifdef DO_MIDDLE_MIX_BENCHMARK
775  pMix = new CAMiddleMixBenchmarkDummy();
776 #endif
777 #ifndef DYNAMIC_MIX
778  CAMsg::printMsg(LOG_INFO,"Starting MIX...\n");
779  if(pMix->start()!=E_SUCCESS)
780  {
781  CAMsg::printMsg(LOG_CRIT,"Error during MIX-Startup!\n");
782  exitCode=EXIT_FAILURE;
783  goto EXIT;
784  }
785 #else
786  // LERNGRUPPE
787 while(true)
788 {
789  CAMsg::printMsg(LOG_INFO,"Starting MIX...\n");
790  if(pMix->start()!=E_SUCCESS)
791  {
793  CAMsg::printMsg(LOG_CRIT,"Error during MIX-Startup!\n");
794  exit(EXIT_FAILURE);
795  }
796 
798  delete pMix;
799  pMix = NULL;
800 
801  if(CALibProxytest::getOptions()->isFirstMix())
802  {
803  CAMsg::printMsg(LOG_INFO,"I am now the First MIX..\n");
804 #if !defined(NEW_MIX_TYPE)
805  pMix=new CAFirstMixA();
806 #else
807  pMix=new CAFirstMixB();
808 #endif
809  }
810  else if(CALibProxytest::getOptions()->isMiddleMix())
811  {
812  CAMsg::printMsg(LOG_INFO,"I am now a Middle MIX..\n");
813  pMix=new CAMiddleMix();
814  }
815  else
816  {
818  CAMsg::printMsg( LOG_ERR, "Tried to reconfigure a former first/middle-Mix to a LastMix -> impossible!\n");
819  exit(EXIT_FAILURE);
820  }
821 }
822 #endif //DYNAMIC_MIX
823 #endif //ONLY_LOCAL_PROXY
824 EXIT:
825  cleanup();
826 
827  return exitCode;
828  }
#define MONITORING_FIRE_SYS_EVENT(e_type)
#define MONITORING_FIRE_NET_EVENT(e_type)
#define S_IWRITE
Definition: StdAfx.h:491
#define S_IREAD
Definition: StdAfx.h:488
static CACmdLnOptions * getOptions()
SINT32 start()
SINT32 start()
Definition: CAMix.cpp:104
static SINT32 init()
Definition: CAMsg.hpp:69
static const char *const getLogLevelStr()
Definition: CAMsg.cpp:143
static SINT32 cleanup()
Definition: CAMsg.hpp:77
static SINT32 measurePerformance(UINT8 *strLogFile, UINT32 lowerBoundEntries, UINT32 upperBoundEntries, UINT32 stepBy, UINT32 meassuresPerStep, UINT32 insertsPerMeasure)
This mehtod can be used to measure the performance of the Replay database.
static SINT32 setMaxNormalSockets(UINT32 u)
Sets the max number of allowed "normal" sockets.
Definition: CASocket.hpp:116
const SINT32 E_SUCCESS
Definition: errorcodes.hpp:2
@ ev_net_middleMixInited
@ ev_sys_start
@ ev_net_lastMixInited
@ ev_net_firstMixInited
void init()
do necessary initialisations of libraries etc.
Definition: proxytest.cpp:145
void signal_interrupt(int)
Definition: proxytest.cpp:241
void checkSizesOfTypes()
Check what the sizes of (base) types are as expected – if not kill the programm.
Definition: proxytest.cpp:262
void cleanup()
do necessary cleanups of libraries etc.
Definition: proxytest.cpp:151
void signal_segv(int)
Definition: proxytest.cpp:204
void signal_term(int)
Definition: proxytest.cpp:233
void signal_hup(int)
Definition: proxytest.cpp:254
UINT16 len
Definition: typedefs.hpp:0

References checkSizesOfTypes(), CAMsg::cleanup(), cleanup(), CACryptoBenchmark::doBenchmark(), E_SUCCESS, ev_net_firstMixInited, ev_net_lastMixInited, ev_net_middleMixInited, ev_sys_start, CAMsg::getLogLevelStr(), CALibProxytest::getOptions(), CAMsg::init(), init(), len, CAReplayDatabase::measurePerformance(), MONITORING_FIRE_NET_EVENT, MONITORING_FIRE_SYS_EVENT, pMix, CAMsg::printMsg(), S_IREAD, S_IWRITE, CASocket::setMaxNormalSockets(), signal_hup(), signal_interrupt(), signal_segv(), signal_term(), CALocalProxy::start(), and CAMix::start().

Here is the call graph for this function:

◆ my_terminate()

void my_terminate ( void  )

Remark: terminate() might be already defined by the c lib – do not use this name...

Definition at line 182 of file proxytest.cpp.

183 {
184  if(!bTriedTermination)
185  {
186  bTriedTermination = true;
187 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_MIDDLE_MIX
188  if(pMix!=NULL)
189  {
190  pMix->shutDown();
191  for (UINT32 i = 0; i < 200 && !(pMix->isShutDown()); i++)
192  {
193  msSleep(1000);
194  }
195  delete pMix;
196  pMix=NULL;
197  }
198 #endif
199  cleanup();
200  }
201 }
SINT32 msSleep(UINT32 ms)
Sleeps ms milliseconds.
Definition: CAUtil.cpp:406
virtual void shutDown()
Definition: CAMix.hpp:71
virtual bool isShutDown()
Definition: CAMix.hpp:77
bool bTriedTermination
Definition: proxytest.cpp:103

References bTriedTermination, cleanup(), CAMix::isShutDown(), msSleep(), pMix, and CAMix::shutDown().

Referenced by signal_interrupt(), and signal_term().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removePidFile()

void removePidFile ( )

Removes the stored PID (file)

Definition at line 122 of file proxytest.cpp.

123  {
124  if(CALibProxytest::getOptions()==NULL)
125  {
126  return;
127  }
128  UINT8 strPidFile[512];
129  if(CALibProxytest::getOptions()->getPidFile(strPidFile,512)==E_SUCCESS)
130  {
131  if(::remove((char*)strPidFile)!=0)
132  {
133 #ifndef _WIN32
134  int old_uid=geteuid(); //old uid... stored if we have to switch to root
135  seteuid(0);
136  ::remove((char*)strPidFile);
137  seteuid(old_uid);
138 #endif
139  }
140  }
141  }

References E_SUCCESS, and CALibProxytest::getOptions().

Referenced by cleanup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ signal_hup()

void signal_hup ( int  )

Definition at line 254 of file proxytest.cpp.

255  {
257  }
SINT32 reread(CAMix *pMix)
Rereads the configuration file (if one was given on startup) and reconfigures the mix according to th...

References CALibProxytest::getOptions(), pMix, and CACmdLnOptions::reread().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ signal_interrupt()

void signal_interrupt ( int  )

Definition at line 241 of file proxytest.cpp.

242  {
244  CAMsg::printMsg(LOG_INFO,"Hm.. Strg+C pressed... exiting!\n");
245 #if defined _DEBUG && ! defined (ONLY_LOCAL_PROXY)
246  CAMsg::printMsg(LOG_INFO,"%d threads listed.\n",CALibProxytest::getThreadList()->getSize());
247  CALibProxytest::getThreadList()->showAll();
248 #endif
249  my_terminate();
250  exit(0);
251  }
@ ev_sys_sigInt
void my_terminate(void)
Remark: terminate() might be already defined by the c lib – do not use this name.....
Definition: proxytest.cpp:182

References ev_sys_sigInt, MONITORING_FIRE_SYS_EVENT, my_terminate(), and CAMsg::printMsg().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ signal_segv()

void signal_segv ( int  )

Definition at line 204 of file proxytest.cpp.

205 {
206  signal(SIGSEGV,SIG_DFL); //otherwise we might end up in endless loops...
207 
209  CAMsg::printMsg(LOG_CRIT,"Oops ... caught SIG_SEGV! Exiting...\n");
210 
211  // wait 1 second so that log files may still be written
212  sSleep(1);
213 
214 #ifdef PRINT_THREAD_STACK_TRACE
215  METHOD_STACK* stack = CAThread::getCurrentStack();
216  if (stack != NULL)
217  {
218  CAMsg::printMsg( LOG_CRIT, "Stack trace: %s, \"%s\"\n", stack->strMethodName, stack->strPosition);
219 
220  }
221  else
222  {
223  CAMsg::printMsg( LOG_CRIT, "Stack trace: none available\n");
224  }
225 #endif
226  // my_terminate(); temporarily disabled
227  exit(1);
228 }
SINT32 sSleep(UINT32 sec)
Sleeps sec Seconds.
Definition: CAUtil.cpp:425
@ ev_sys_sigSegV

References ev_sys_sigSegV, MONITORING_FIRE_SYS_EVENT, CAMsg::printMsg(), and sSleep().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ signal_term()

void signal_term ( int  )

Definition at line 233 of file proxytest.cpp.

234  {
236  CAMsg::printMsg(LOG_INFO,"Hm.. Signal SIG_TERM received... exiting!\n");
237  my_terminate();
238  exit(0);
239  }
@ ev_sys_sigTerm

References ev_sys_sigTerm, MONITORING_FIRE_SYS_EVENT, my_terminate(), and CAMsg::printMsg().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ bTriedTermination

bool bTriedTermination = false

Definition at line 103 of file proxytest.cpp.

Referenced by my_terminate().

◆ pMix

CAMix* pMix =NULL