sgwdynspeed: clear the cached timestamp when the speed file can't be read
authorFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 14 Oct 2015 11:28:19 +0000 (13:28 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Thu, 15 Oct 2015 12:47:56 +0000 (14:47 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/sgwdynspeed/src/speedFile.c

index 0937da2..db04cc1 100644 (file)
@@ -181,6 +181,7 @@ void readSpeedFile(char * fileName) {
        unsigned int lineNumber = 0;
        char * name = NULL;
        char * value = NULL;
+
        unsigned long uplink = DEF_UPLINK_SPEED;
        unsigned long downlink = DEF_DOWNLINK_SPEED;
        bool uplinkSet = false;
@@ -189,12 +190,14 @@ void readSpeedFile(char * fileName) {
 
        fd = open(fileName, O_RDONLY);
        if (fd < 0) {
-               /* could not access the file */
+               /* could not open the file */
+               memset(&cachedStat.timeStamp, 0, sizeof(cachedStat.timeStamp));
                goto out;
        }
 
        if (fstat(fd, &statBuf)) {
-               /* could not access the file */
+               /* could not stat the file */
+               memset(&cachedStat.timeStamp, 0, sizeof(cachedStat.timeStamp));
                goto out;
        }
 
@@ -205,6 +208,7 @@ void readSpeedFile(char * fileName) {
 
        fp = fdopen(fd, "r");
        if (!fp) {
+               /* could not open the file */
                goto out;
        }