monitor: request-server: rearrange the position of the timeout value initialization
authorSung-hun Kim <sfoon.kim@samsung.com>
Mon, 21 Feb 2022 07:44:57 +0000 (16:44 +0900)
committerSung-hun Kim <sfoon.kim@samsung.com>
Mon, 21 Feb 2022 07:44:57 +0000 (16:44 +0900)
Change-Id: Iedd9c4f592ce49e387903da634f73d701974f8c1

src/monitor/request-server.c

index 775eada80d9d493f529834ad89ae5dddc03b00ae..f82e44498a3a32c6fac310e63af4552249417cc3 100644 (file)
@@ -254,7 +254,7 @@ static void handle_request_update(struct request_client *client, int resource_ty
        struct resource *resource;
 
        if (!client)
-               return NULL;
+               return;
 
        resource = find_resource_by_type(client, resource_type);
        if (!resource) {
@@ -344,8 +344,6 @@ static void handle_request_stop(struct request_client *client)
 
 static void handle_request_in_running(struct request_client *client, char *buffer)
 {
-       char response[10];
-       int response_len;
        int nr_tokens;
        char *tokens[REQUEST_TOKEN_MAX];
        int request_type;
@@ -416,9 +414,6 @@ static int request_handler_func(void *data, void **result)
        struct timeval wait;
        struct request_client *client = (struct request_client *)data;
 
-       wait.tv_sec = 1;
-       wait.tv_usec = 0;
-
        FD_ZERO(&active_fds);
        FD_SET(client->socket_fd, &active_fds);
 
@@ -426,11 +421,14 @@ static int request_handler_func(void *data, void **result)
 
        while (client->worker_running) {
                read_fds = active_fds;
+               wait.tv_sec = 1;
+               wait.tv_usec = 0;
 
                if (select(FD_SETSIZE, &read_fds, NULL, NULL, &wait) < 0) {
                        _E("select failed");
                        goto error_out;
                }
+
                if (FD_ISSET(client->socket_fd, &read_fds)) {
                        /* client submits request */
                        recv_len = recv(client->socket_fd, buffer, REQUEST_MAX, 0);
@@ -716,8 +714,6 @@ static int request_server_func(void *ctx, void **result)
        FD_ZERO(&active_fds);
        FD_SET(server_socket, &active_fds);
 
-       wait.tv_sec = 1;
-       wait.tv_usec = 0;
        _I("start server");
 
        client_list_test();
@@ -727,6 +723,8 @@ static int request_server_func(void *ctx, void **result)
        while (request_server_run) {
                /* 1. (re)initialize client sockets */
                read_fds = active_fds;
+               wait.tv_sec = 1;
+               wait.tv_usec = 0;
 
                if (select(FD_SETSIZE, &read_fds, NULL, NULL, &wait) < 0) {
                        _E("select failed");