[lib-client] send_request(): test owl_run

Stop sending packets if owl_run is false.
This commit is contained in:
Matteo Cypriani 2011-10-25 11:32:14 +02:00
parent ac6d5d7854
commit c84df6d8a8
1 changed files with 6 additions and 1 deletions

View File

@ -63,6 +63,9 @@ void owl_use_iface(const int sockfd, const char *const iface)
/*
* Transmits a request.
* No packet will be transmitted if the variable owl_run is (or
* becomes) false.
* nb_pkt: number of packets to transmit.
* delay: delay between two transmissions, in milliseconds.
*/
@ -75,7 +78,7 @@ void owl_send_request(const int sockfd,
{
uint_fast16_t i ;
if (nb_pkt == 0)
if (nb_pkt == 0 || !owl_run)
return ;
#ifdef DEBUG
@ -89,6 +92,8 @@ void owl_send_request(const int sockfd,
for (i = 0 ; i < nb_pkt - 1 ; ++i)
{
owl_msleep(delay) ; // Wait during the wanted delay
if (! owl_run)
break ;
owl_send_packet(sockfd, server, packet, packet_size) ;
}