[Client] Improve the request loop

In flood mode, avoid sending a last request when the program is stopped.
This commit is contained in:
Matteo Cypriani 2011-08-24 13:19:46 +02:00
parent d2f0ad78e5
commit 8bec37c4ad
1 changed files with 20 additions and 17 deletions

View File

@ -104,15 +104,11 @@ int main(int argc, char *argv[])
create_socket() ; create_socket() ;
request_transmission: while (owl_run)
make_packet() ;
send_request() ;
free(packet) ;
if (options.flood_delay >= 0 && owl_run)
{ {
usleep(options.flood_delay * 1000) ; send_request() ;
goto request_transmission ; if (options.flood_delay >= 0 && owl_run)
usleep(options.flood_delay * 1000) ;
} }
close(sockfd) ; close(sockfd) ;
@ -379,7 +375,22 @@ void create_socket()
/* Creates the packet to send. */ /*
* Prepares a new request and sends it.
*/
void send_request()
{
make_packet() ;
owl_send_request(sockfd, &server, packet, packet_size,
options.nb_pkt, options.delay) ;
free(packet) ;
}
/*
* Creates the packet to send.
*/
void make_packet() void make_packet()
{ {
uint_fast16_t offset ; // Index used to create the packet uint_fast16_t offset ; // Index used to create the packet
@ -441,14 +452,6 @@ void make_packet()
void send_request()
{
owl_send_request(sockfd, &server, packet, packet_size,
options.nb_pkt, options.delay) ;
}
void receive_position() void receive_position()
{ {
// Position of the mobile as computed by the infrastructure: // Position of the mobile as computed by the infrastructure: