diff options
Diffstat (limited to 'src/testspdy/test_session_timeout.c')
-rw-r--r-- | src/testspdy/test_session_timeout.c | 54 |
1 files changed, 44 insertions, 10 deletions
diff --git a/src/testspdy/test_session_timeout.c b/src/testspdy/test_session_timeout.c index c5d29dc9..66872d72 100644 --- a/src/testspdy/test_session_timeout.c +++ b/src/testspdy/test_session_timeout.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <sys/stat.h> | 33 | #include <sys/stat.h> |
34 | 34 | ||
35 | #define TIMEOUT 2 | 35 | #define TIMEOUT 2 |
36 | #define SELECT_MS_TIMEOUT 20 | ||
36 | 37 | ||
37 | int port; | 38 | int port; |
38 | 39 | ||
@@ -95,13 +96,16 @@ parentproc() | |||
95 | int childstatus; | 96 | int childstatus; |
96 | unsigned long long timeoutlong=0; | 97 | unsigned long long timeoutlong=0; |
97 | struct timeval timeout; | 98 | struct timeval timeout; |
99 | struct timespec ts; | ||
98 | int ret; | 100 | int ret; |
99 | fd_set read_fd_set; | 101 | fd_set read_fd_set; |
100 | fd_set write_fd_set; | 102 | fd_set write_fd_set; |
101 | fd_set except_fd_set; | 103 | fd_set except_fd_set; |
102 | int maxfd = -1; | 104 | int maxfd = -1; |
103 | struct SPDY_Daemon *daemon; | 105 | struct SPDY_Daemon *daemon; |
104 | 106 | unsigned long long beginning = 0; | |
107 | unsigned long long now; | ||
108 | |||
105 | SPDY_init(); | 109 | SPDY_init(); |
106 | 110 | ||
107 | daemon = SPDY_start_daemon(port, | 111 | daemon = SPDY_start_daemon(port, |
@@ -120,8 +124,6 @@ parentproc() | |||
120 | printf("no daemon\n"); | 124 | printf("no daemon\n"); |
121 | return 1; | 125 | return 1; |
122 | } | 126 | } |
123 | |||
124 | timeout.tv_usec = 0; | ||
125 | 127 | ||
126 | do | 128 | do |
127 | { | 129 | { |
@@ -138,10 +140,32 @@ parentproc() | |||
138 | { | 140 | { |
139 | killchild("SPDY_get_timeout returned wrong SPDY_NO"); | 141 | killchild("SPDY_get_timeout returned wrong SPDY_NO"); |
140 | } | 142 | } |
141 | if(timeoutlong) | 143 | /*if(timeoutlong) |
142 | { | 144 | { |
143 | killchild("SPDY_get_timeout returned wrong timeout"); | 145 | killchild("SPDY_get_timeout returned wrong timeout"); |
144 | } | 146 | }*/ |
147 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) | ||
148 | now = ts.tv_nsec / 1000000 + ts.tv_sec*1000; | ||
149 | else | ||
150 | killchild("clock_gettime returned wrong value"); | ||
151 | if(now - beginning > TIMEOUT*1000 + SELECT_MS_TIMEOUT) | ||
152 | { | ||
153 | printf("Started at: %ims\n",beginning); | ||
154 | printf("Now is: %ims\n",now); | ||
155 | printf("Timeout is: %i\n",TIMEOUT); | ||
156 | printf("Select Timeout is: %ims\n",SELECT_MS_TIMEOUT); | ||
157 | printf("SPDY_get_timeout gave: %ims\n",timeoutlong); | ||
158 | killchild("Timeout passed but session was not closed"); | ||
159 | } | ||
160 | if(timeoutlong > beginning + TIMEOUT *1000) | ||
161 | { | ||
162 | printf("Started at: %ims\n",beginning); | ||
163 | printf("Now is: %ims\n",now); | ||
164 | printf("Timeout is: %i\n",TIMEOUT); | ||
165 | printf("Select Timeout is: %ims\n",SELECT_MS_TIMEOUT); | ||
166 | printf("SPDY_get_timeout gave: %ims\n",timeoutlong); | ||
167 | killchild("SPDY_get_timeout returned wrong timeout"); | ||
168 | } | ||
145 | } | 169 | } |
146 | else | 170 | else |
147 | { | 171 | { |
@@ -151,14 +175,20 @@ parentproc() | |||
151 | } | 175 | } |
152 | } | 176 | } |
153 | 177 | ||
154 | if(SPDY_NO == ret || timeoutlong > 1) | 178 | if(SPDY_NO == ret || timeoutlong >= 1000) |
155 | { | 179 | { |
156 | timeout.tv_sec = 1; | 180 | timeout.tv_sec = 1; |
181 | timeout.tv_usec = 0; | ||
157 | } | 182 | } |
158 | else | 183 | else |
159 | { | 184 | { |
160 | timeout.tv_sec = timeoutlong; | 185 | timeout.tv_sec = timeoutlong / 1000; |
186 | timeout.tv_usec = (timeoutlong % 1000) * 1000; | ||
161 | } | 187 | } |
188 | |||
189 | //ignore values | ||
190 | timeout.tv_sec = 0; | ||
191 | timeout.tv_usec = SELECT_MS_TIMEOUT * 1000; | ||
162 | 192 | ||
163 | maxfd = SPDY_get_fdset (daemon, | 193 | maxfd = SPDY_get_fdset (daemon, |
164 | &read_fd_set, | 194 | &read_fd_set, |
@@ -179,12 +209,16 @@ parentproc() | |||
179 | break; | 209 | break; |
180 | default: | 210 | default: |
181 | SPDY_run(daemon); | 211 | SPDY_run(daemon); |
182 | if(do_sleep) | 212 | if(0 == beginning) |
213 | if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0) | ||
214 | beginning = ts.tv_nsec / 1000000 + ts.tv_sec*1000; | ||
215 | else | ||
216 | killchild("clock_gettime returned wrong number"); | ||
217 | /*if(do_sleep) | ||
183 | { | 218 | { |
184 | sleep(TIMEOUT); | 219 | sleep(TIMEOUT); |
185 | do_sleep = 0; | 220 | do_sleep = 0; |
186 | } | 221 | }*/ |
187 | |||
188 | break; | 222 | break; |
189 | } | 223 | } |
190 | } | 224 | } |