Commit a3504c87cac0248996bc07d732761ad37ba45f34

Authored by bellard
1 parent 7143c62c

removed gettimeofday usage


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1053 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 13 additions and 19 deletions
slirp/tftp.c
@@ -25,13 +25,13 @@ @@ -25,13 +25,13 @@
25 #include <slirp.h> 25 #include <slirp.h>
26 26
27 struct tftp_session { 27 struct tftp_session {
28 - int in_use;  
29 - unsigned char filename[TFTP_FILENAME_MAX];  
30 -  
31 - struct in_addr client_ip;  
32 - u_int16_t client_port;  
33 -  
34 - struct timeval timestamp; 28 + int in_use;
  29 + unsigned char filename[TFTP_FILENAME_MAX];
  30 +
  31 + struct in_addr client_ip;
  32 + u_int16_t client_port;
  33 +
  34 + int timestamp;
35 }; 35 };
36 36
37 struct tftp_session tftp_sessions[TFTP_SESSIONS_MAX]; 37 struct tftp_session tftp_sessions[TFTP_SESSIONS_MAX];
@@ -40,8 +40,8 @@ char *tftp_prefix; @@ -40,8 +40,8 @@ char *tftp_prefix;
40 40
41 static void tftp_session_update(struct tftp_session *spt) 41 static void tftp_session_update(struct tftp_session *spt)
42 { 42 {
43 - gettimeofday(&spt->timestamp, 0);  
44 - spt->in_use = 1; 43 + spt->timestamp = curtime;
  44 + spt->in_use = 1;
45 } 45 }
46 46
47 static void tftp_session_terminate(struct tftp_session *spt) 47 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)
52 static int tftp_session_allocate(struct tftp_t *tp) 52 static int tftp_session_allocate(struct tftp_t *tp)
53 { 53 {
54 struct tftp_session *spt; 54 struct tftp_session *spt;
55 - struct timeval tv;  
56 int k; 55 int k;
57 56
58 - gettimeofday(&tv, 0);  
59 -  
60 for (k = 0; k < TFTP_SESSIONS_MAX; k++) { 57 for (k = 0; k < TFTP_SESSIONS_MAX; k++) {
61 spt = &tftp_sessions[k]; 58 spt = &tftp_sessions[k];
62 59
63 - if (!spt->in_use) {  
64 - goto found;  
65 - } 60 + if (!spt->in_use)
  61 + goto found;
66 62
67 /* sessions time out after 5 inactive seconds */ 63 /* sessions time out after 5 inactive seconds */
68 -  
69 - if (tv.tv_sec > (spt->timestamp.tv_sec + 5)) {  
70 - goto found;  
71 - } 64 + if ((int)(curtime - spt->timestamp) > 5000)
  65 + goto found;
72 } 66 }
73 67
74 return -1; 68 return -1;