提交 a3504c87 编写于 作者: B bellard

removed gettimeofday usage


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1053 c046a42c-6fe2-441c-8c8c-71466251a162
上级 7143c62c
...@@ -25,13 +25,13 @@ ...@@ -25,13 +25,13 @@
#include <slirp.h> #include <slirp.h>
struct tftp_session { struct tftp_session {
int in_use; int in_use;
unsigned char filename[TFTP_FILENAME_MAX]; unsigned char filename[TFTP_FILENAME_MAX];
struct in_addr client_ip; struct in_addr client_ip;
u_int16_t client_port; u_int16_t client_port;
struct timeval timestamp; int timestamp;
}; };
struct tftp_session tftp_sessions[TFTP_SESSIONS_MAX]; struct tftp_session tftp_sessions[TFTP_SESSIONS_MAX];
...@@ -40,8 +40,8 @@ char *tftp_prefix; ...@@ -40,8 +40,8 @@ char *tftp_prefix;
static void tftp_session_update(struct tftp_session *spt) static void tftp_session_update(struct tftp_session *spt)
{ {
gettimeofday(&spt->timestamp, 0); spt->timestamp = curtime;
spt->in_use = 1; spt->in_use = 1;
} }
static void tftp_session_terminate(struct tftp_session *spt) static void tftp_session_terminate(struct tftp_session *spt)
...@@ -52,23 +52,17 @@ static void tftp_session_terminate(struct tftp_session *spt) ...@@ -52,23 +52,17 @@ static void tftp_session_terminate(struct tftp_session *spt)
static int tftp_session_allocate(struct tftp_t *tp) static int tftp_session_allocate(struct tftp_t *tp)
{ {
struct tftp_session *spt; struct tftp_session *spt;
struct timeval tv;
int k; int k;
gettimeofday(&tv, 0);
for (k = 0; k < TFTP_SESSIONS_MAX; k++) { for (k = 0; k < TFTP_SESSIONS_MAX; k++) {
spt = &tftp_sessions[k]; spt = &tftp_sessions[k];
if (!spt->in_use) { if (!spt->in_use)
goto found; goto found;
}
/* sessions time out after 5 inactive seconds */ /* sessions time out after 5 inactive seconds */
if ((int)(curtime - spt->timestamp) > 5000)
if (tv.tv_sec > (spt->timestamp.tv_sec + 5)) { goto found;
goto found;
}
} }
return -1; return -1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册