Quit handling useless network client structures

It is useless to handle a client structure on recvfrom() or accept()
when nothing is done with this information.
Changed in Aggregator, Listener, Positioner and UDP-to-HTTP.
This commit is contained in:
Matteo Cypriani 2013-09-20 17:53:21 -04:00
parent 49066f451b
commit 75e04cfc17
4 changed files with 6 additions and 19 deletions

View File

@ -540,15 +540,11 @@ int read_loop(int sockfd)
{
int ret = 0 ; // Return value
ssize_t nread ; // recvfrom return value
struct sockaddr_in client; // UDP client structure
socklen_t client_len = sizeof(client) ; // Size of clients
owl_captured_request request ; // Message read on the socket
while (owl_run)
{
nread = recvfrom(sockfd, &request, sizeof(request), 0,
(struct sockaddr *) &client, &client_len) ;
nread = recvfrom(sockfd, &request, sizeof(request), 0, NULL, NULL) ;
if (nread <= 0)
{
if (owl_run)

View File

@ -1570,8 +1570,6 @@ void* autocalibrate_hello(void *NULL_value)
void* autocalibrate(void *NULL_value)
{
int nread ; // recvfrom return value
struct sockaddr_in client; // UDP client structure
socklen_t client_len = sizeof(client) ; // Size of clients
int listen_sockfd ;
owl_autocalibration_order message ;
@ -1599,7 +1597,7 @@ void* autocalibrate(void *NULL_value)
while (owl_run)
{
nread = recvfrom(listen_sockfd, &message, sizeof(message), 0,
(struct sockaddr *) &client, &client_len) ;
NULL, NULL) ;
if (nread <= 0 && owl_run)
{

View File

@ -98,13 +98,10 @@ bool InputUDPSocket::fill_current_request()
if (eof())
return false ;
struct sockaddr_in client; // UDP client structure
socklen_t client_len = sizeof(client) ; // Size of clients
// Read the main request data
owl_request request ;
ssize_t nread = recvfrom(sockfd, &request, sizeof(request), 0,
(struct sockaddr *) &client, &client_len) ;
NULL, NULL) ;
if (nread <= 0)
{
cerr << "InputUDPSocket: No request received!" << endl ;
@ -184,7 +181,7 @@ bool InputUDPSocket::fill_current_request()
for (int i = 0 ; i < request.nb_info ; ++i)
{
nread = recvfrom(sockfd, &request_info, sizeof(request_info), 0,
(struct sockaddr *) &client, &client_len) ;
NULL, NULL) ;
if (nread <= 0)
{
cerr << "No request info received!" << endl ;

View File

@ -306,7 +306,7 @@ int init_tcp_socket()
return OWL_ERR_SOCKET_CREATE ;
}
bzero((char *) &server_addr, sizeof(server_addr)) ;
memset(&server_addr, 0, sizeof(server_addr)) ;
server_addr.sin_family = AF_INET ;
server_addr.sin_addr.s_addr = INADDR_ANY ;
server_addr.sin_port = htons(options.http_port) ;
@ -329,15 +329,12 @@ int init_tcp_socket()
void* tcp_server(void *NULL_value)
{
int newsockfd ;
socklen_t client_len ;
struct sockaddr_in client_addr ;
ssize_t nbytes ; // recv/send return value
char client_message[CLIENT_MESSAGE_STRLEN] ;
char client_request[CLIENT_REQUEST_STRLEN] ;
int request_id ;
listen(tcp_sockfd, options.nb_connections) ;
client_len = sizeof(client_addr) ;
// Prepare the answer, assuming there is only 1 full result (an error
// message will also fit)
@ -353,8 +350,7 @@ void* tcp_server(void *NULL_value)
while (owl_run)
{
newsockfd = accept(tcp_sockfd,
(struct sockaddr*) &client_addr, &client_len) ;
newsockfd = accept(tcp_sockfd, NULL, NULL) ;
if (newsockfd < 0)
{
perror("Error accepting a connection on the TCP socket") ;