parent
61703ad8b1
commit
00abd9e6c8
|
@ -109,6 +109,10 @@ lease_file_add(unsigned short eport,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* convert our time to unix time */
|
||||||
|
timestamp -= upnp_time();
|
||||||
|
timestamp += time(NULL);
|
||||||
|
|
||||||
fprintf(fd, "%s:%hu:%s:%hu:%u:%s\n",
|
fprintf(fd, "%s:%hu:%s:%hu:%u:%s\n",
|
||||||
proto_itoa(proto), eport, iaddr, iport,
|
proto_itoa(proto), eport, iaddr, iport,
|
||||||
timestamp, desc);
|
timestamp, desc);
|
||||||
|
@ -190,6 +194,7 @@ int reload_from_lease_file()
|
||||||
unsigned int leaseduration;
|
unsigned int leaseduration;
|
||||||
unsigned int timestamp;
|
unsigned int timestamp;
|
||||||
time_t current_time;
|
time_t current_time;
|
||||||
|
time_t current_unix_time;
|
||||||
char line[128];
|
char line[128];
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
|
@ -204,6 +209,7 @@ int reload_from_lease_file()
|
||||||
}
|
}
|
||||||
|
|
||||||
current_time = upnp_time();
|
current_time = upnp_time();
|
||||||
|
current_unix_time = time(NULL);
|
||||||
while(fgets(line, sizeof(line), fd)) {
|
while(fgets(line, sizeof(line), fd)) {
|
||||||
syslog(LOG_DEBUG, "parsing lease file line '%s'", line);
|
syslog(LOG_DEBUG, "parsing lease file line '%s'", line);
|
||||||
proto = line;
|
proto = line;
|
||||||
|
@ -251,11 +257,12 @@ int reload_from_lease_file()
|
||||||
*(p--) = '\0';
|
*(p--) = '\0';
|
||||||
|
|
||||||
if(timestamp > 0) {
|
if(timestamp > 0) {
|
||||||
if(timestamp <= (unsigned int)current_time) {
|
if(timestamp <= (unsigned int)current_unix_time) {
|
||||||
syslog(LOG_NOTICE, "already expired lease in lease file");
|
syslog(LOG_NOTICE, "already expired lease in lease file");
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
leaseduration = timestamp - current_time;
|
leaseduration = timestamp - current_unix_time;
|
||||||
|
timestamp = lease_duration + current_time;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
leaseduration = 0; /* default value */
|
leaseduration = 0; /* default value */
|
||||||
|
|
Loading…
Reference in New Issue