#include <TFTP_Timeout.hpp>
Inheritance diagram for TFTP_Timeout::
Public Methods | |
TFTP_Timeout () | |
virtual void | timedRun (int signalNo) |
virtual | ~TFTP_Timeout () |
Private Methods | |
TFTP_Timeout (const TFTP_Timeout &src) | |
const TFTP_Timeout & | operator= (const TFTP_Timeout &src) |
Private Attributes | |
TFTP_Packet * | packet |
double | elapsed |
ULONG | timeout |
int | dataEmpty |
int | waitEmpty |
|
Definition at line 10 of file TFTP_Timeout.cpp. 00010 : Timer( 0000000, 10 ) 00011 { 00012 dataEmpty = 0; 00013 waitEmpty = 0; 00014 elapsed = 10.000; // 1/4 sec 00015 packet = NULL; 00016 timeout = option.getTimeOutValue(); 00017 00018 // This is logic time 0 00019 option.currentTime = 0; 00020 00021 // Start the timer NOW ! 00022 // Timer::start(); 00023 } |
|
Definition at line 15 of file TFTP_Timeout.hpp. 00015 { } |
|
|
|
|
|
Definition at line 25 of file TFTP_Timeout.cpp. 00026 { 00027 option.currentTime += elapsed; 00028 00029 // printf("Timer[%0.001f]\n", option.currentTime ); 00030 00031 option.rwlock6_wait_queue.write(); 00032 option.waitingAck_queue->setFirst(); 00033 long rc = 0; 00034 while ( rc >= 0 ) { 00035 // printf("timedRun: rc is equal to %d\n",rc); 00036 00037 // Not Found = -1, Empty = -50, Invalid = -100 - position 00038 rc = option.waitingAck_queue->findTimeStamp( option.currentTime ); 00039 00040 // printf("timedRun: rc is returning %d after findTimeStamp\n", rc); 00041 00042 if ( rc < 0 ) 00043 { 00044 00045 //option.waitingAck_queue->display(); 00046 } 00047 00048 if ( rc >= 0 ) { 00049 // TIMEOUT for packet on waitingAck_queue->curr 00050 packet = option.waitingAck_queue->remove(); 00051 00052 // Resend it, anything else to do ?!?!!? 00053 // Do we resent the hole thing ?! 00054 packet->resent++; 00055 00056 // After 10 timeout on the same data packet 00057 if ( packet->resent > 10 ) 00058 { 00059 SendNotDefinedError( "ERROR: 10 Timeouts. Connection closed.\n" ); 00060 exit( 1 ); 00061 } 00062 00063 printf( "Resending Data, packet Timed out! \n" ); 00064 fflush(stdout); 00065 packet->send(); 00066 packet->setTimeStamp( option.currentTime + timeout ); 00067 option.waitingAck_queue->enqueue( packet ); 00068 fflush(stdout); 00069 } 00070 } 00071 00072 if ( option.waitingAck_queue->isEmpty() ) 00073 { 00074 waitEmpty++; 00075 } else { 00076 waitEmpty = 0; 00077 } 00078 00079 option.rwlock6_wait_queue.releaseWrite(); 00080 00081 option.rwlock5_data_queue.read(); 00082 if ( option.data_queue->isEmpty() ) 00083 { 00084 dataEmpty++; 00085 } else { 00086 dataEmpty = 0; 00087 } 00088 00089 option.rwlock5_data_queue.releaseRead(); 00090 00091 if ( ( dataEmpty > DEAD || waitEmpty > DEAD ) && ( option.isReading() || option.isWriting() ) ) 00092 { 00093 exit( 0 ); 00094 } 00095 } |
|
Definition at line 21 of file TFTP_Timeout.hpp. |
|
Definition at line 19 of file TFTP_Timeout.hpp. |
|
Definition at line 18 of file TFTP_Timeout.hpp. |
|
Definition at line 20 of file TFTP_Timeout.hpp. |
|
Definition at line 22 of file TFTP_Timeout.hpp. |