mirror of
https://gitlab.com/qemu-project/qemu
synced 2024-11-05 20:35:44 +00:00
removed gettimeofday usage
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1053 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
7143c62c95
commit
a3504c87ca
1 changed files with 13 additions and 19 deletions
14
slirp/tftp.c
14
slirp/tftp.c
|
@ -31,7 +31,7 @@ struct tftp_session {
|
|||
struct in_addr client_ip;
|
||||
u_int16_t client_port;
|
||||
|
||||
struct timeval timestamp;
|
||||
int timestamp;
|
||||
};
|
||||
|
||||
struct tftp_session tftp_sessions[TFTP_SESSIONS_MAX];
|
||||
|
@ -40,7 +40,7 @@ char *tftp_prefix;
|
|||
|
||||
static void tftp_session_update(struct tftp_session *spt)
|
||||
{
|
||||
gettimeofday(&spt->timestamp, 0);
|
||||
spt->timestamp = curtime;
|
||||
spt->in_use = 1;
|
||||
}
|
||||
|
||||
|
@ -52,24 +52,18 @@ static void tftp_session_terminate(struct tftp_session *spt)
|
|||
static int tftp_session_allocate(struct tftp_t *tp)
|
||||
{
|
||||
struct tftp_session *spt;
|
||||
struct timeval tv;
|
||||
int k;
|
||||
|
||||
gettimeofday(&tv, 0);
|
||||
|
||||
for (k = 0; k < TFTP_SESSIONS_MAX; k++) {
|
||||
spt = &tftp_sessions[k];
|
||||
|
||||
if (!spt->in_use) {
|
||||
if (!spt->in_use)
|
||||
goto found;
|
||||
}
|
||||
|
||||
/* sessions time out after 5 inactive seconds */
|
||||
|
||||
if (tv.tv_sec > (spt->timestamp.tv_sec + 5)) {
|
||||
if ((int)(curtime - spt->timestamp) > 5000)
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
||||
|
|
Loading…
Reference in a new issue