diff options
-rw-r--r-- | client.c | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -272,19 +272,16 @@ void client_close_all_connections() | |||
272 | } | 272 | } |
273 | } | 273 | } |
274 | 274 | ||
275 | void client_connected_loop_iteration(uint32_t friendnumber) | 275 | void client_connected_loop_iteration(uint32_t friendnumber, struct tox_timer *t) |
276 | { | 276 | { |
277 | static unsigned char tox_packet_buf[PROTOCOL_MAX_PACKET_SIZE]; | 277 | static unsigned char tox_packet_buf[PROTOCOL_MAX_PACKET_SIZE]; |
278 | static fd_set fds; | 278 | static fd_set fds; |
279 | static struct timeval tv; | ||
280 | 279 | ||
281 | int accept_fd = 0; | 280 | int accept_fd = 0; |
282 | int select_rv = 0; | 281 | int select_rv = 0; |
283 | tunnel *tmp = NULL; | 282 | tunnel *tmp = NULL; |
284 | tunnel *tun = NULL; | 283 | tunnel *tun = NULL; |
285 | 284 | ||
286 | tv.tv_sec = 0; | ||
287 | tv.tv_usec = 20000; | ||
288 | fds = client_master_fdset; | 285 | fds = client_master_fdset; |
289 | 286 | ||
290 | /* Handle accepting new connections */ | 287 | /* Handle accepting new connections */ |
@@ -303,7 +300,7 @@ void client_connected_loop_iteration(uint32_t friendnumber) | |||
303 | } | 300 | } |
304 | 301 | ||
305 | /* Handle reading from sockets */ | 302 | /* Handle reading from sockets */ |
306 | select_rv = select(select_nfds, &fds, NULL, NULL, &tv); | 303 | select_rv = select(select_nfds, &fds, NULL, NULL, &(t->tv)); |
307 | if(select_rv == -1 || select_rv == 0) | 304 | if(select_rv == -1 || select_rv == 0) |
308 | { | 305 | { |
309 | if(select_rv == -1) | 306 | if(select_rv == -1) |
@@ -415,6 +412,7 @@ int do_client_loop(uint8_t *tox_id_str) | |||
415 | { | 412 | { |
416 | /* Let tox do its stuff */ | 413 | /* Let tox do its stuff */ |
417 | tox_iterate(tox, NULL); | 414 | tox_iterate(tox, NULL); |
415 | struct tox_timer t = init_tox_timer(tox); | ||
418 | 416 | ||
419 | switch(state) | 417 | switch(state) |
420 | { | 418 | { |
@@ -531,11 +529,11 @@ int do_client_loop(uint8_t *tox_id_str) | |||
531 | case CLIENT_STATE_AWAIT_PONG: | 529 | case CLIENT_STATE_AWAIT_PONG: |
532 | break; | 530 | break; |
533 | case CLIENT_STATE_CONNECTED: | 531 | case CLIENT_STATE_CONNECTED: |
534 | client_connected_loop_iteration(friendnumber); | 532 | client_connected_loop_iteration(friendnumber, &t); |
535 | break; | 533 | break; |
536 | } | 534 | } |
537 | 535 | ||
538 | usleep(tox_iteration_interval(tox) * 1000); | 536 | run_tox_timer(tox, t); |
539 | } | 537 | } |
540 | } | 538 | } |
541 | 539 | ||