Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4StatusRunnable.h"
00015
00016 #include <signal.h>
00017
00018 #include "TGo4Log.h"
00019 #include "TGo4ThreadManager.h"
00020 #include "TGo4Thread.h"
00021 #include "TGo4BufferQueue.h"
00022 #include "TGo4Socket.h"
00023 #include "TGo4SocketSignalHandler.h"
00024 #include "TGo4TaskHandler.h"
00025 #include "TGo4TaskHandlerAbortException.h"
00026
00027 TGo4StatusRunnable::TGo4StatusRunnable(const char* name, TGo4ThreadManager* man, TGo4TaskHandler* hand, Bool_t receivermode) :
00028 TGo4TaskHandlerRunnable(name,man,hand,receivermode)
00029 {
00030 fxBufferQueue = dynamic_cast<TGo4BufferQueue*> (fxTaskHandler->GetStatusQueue() );
00031 fxTransport = fxTaskHandler->GetStatusTransport();
00032 }
00033
00034
00035 TGo4StatusRunnable::~TGo4StatusRunnable()
00036 {
00037 }
00038
00039 Int_t TGo4StatusRunnable::Run(void* ptr)
00040 {
00041 if(!CheckTransportOpen()) return 0;
00042 if(fbReceiverMode)
00043 {
00044
00045 Int_t rev = fxTransport->ReceiveBuffer();
00046 if(rev>=0)
00047 {
00048 TBuffer* buf=const_cast<TBuffer*> (fxTransport->GetBuffer());
00049 if(CheckStopBuffer(buf)) return 0;
00050 fxBufferQueue->AddBuffer(buf, kTRUE);
00051 }
00052 else
00053 {
00054 if (TGo4SocketSignalHandler::IsLastSignalWINCH())
00055 {
00056
00057 TGo4Log::Debug(" %s: caught SIGWINCH ",GetName());
00058 TGo4SocketSignalHandler::SetLastSignal(0);
00059 }
00060 else if(fxManager->IsTerminating())
00061 {
00062
00063 TGo4Log::Debug("Receive Error in %s during threadmanager termination. Ignored.",GetName());
00064 GetThread()->Stop();
00065 }
00066 else
00067 {
00068 TGo4Log::Debug(" !!!Receive Error in %s!!!",
00069 GetName());
00070
00071 throw TGo4TaskHandlerAbortException(this);
00072 }
00073 }
00074
00075 }
00076 else
00077 {
00078
00079
00080 TBuffer* buf= fxBufferQueue->WaitBuffer();
00081 if (buf)
00082
00083 {
00084 CheckStopBuffer(buf);
00085 fxTransport->SendBuffer(buf);
00086 fxBufferQueue->FreeBuffer(buf);
00087 }
00088 }
00089
00090
00091 return 0;
00092 }
00093