sensord: change log level from error to warning for the warning case 35/96535/4
authorkibak.yoon <kibak.yoon@samsung.com>
Wed, 9 Nov 2016 08:41:46 +0000 (17:41 +0900)
committerkibak.yoon <kibak.yoon@samsung.com>
Wed, 9 Nov 2016 12:26:13 +0000 (21:26 +0900)
- when applications access not-supported sensors, it doesn't need to
  print error level logs.

Change-Id: I1d98d0ebd85bf3d12a673e320a39d2942d53cc9a
Signed-off-by: kibak.yoon <kibak.yoon@samsung.com>
17 files changed:
src/client/client.cpp
src/client/command_channel.cpp
src/client/sensor_client_info.cpp
src/sensor/auto_rotation/auto_rotation_sensor.cpp
src/sensor/gesture/face_down_sensor.cpp
src/sensor/gravity/gravity_sensor.cpp
src/sensor/linear_accel/linear_accel_sensor.cpp
src/sensor/orientation/orientation_sensor.cpp
src/sensor/rotation_vector/gyro_rv_sensor.cpp
src/sensor/rotation_vector/magnetic_rv_sensor.cpp
src/sensor/rotation_vector/rv_sensor.cpp
src/sensor/tilt/tilt_sensor.cpp
src/server/command_worker.cpp
src/server/sensor_loader.cpp
src/server/server.cpp
src/server/worker_thread.cpp
src/shared/csocket.cpp

index 0f69a1d..7d22d9f 100644 (file)
@@ -612,9 +612,7 @@ API int sensord_connect(sensor_t sensor)
        bool first_connection = false;
 
        sensor_info* info = sensor_to_sensor_info(sensor);
-
-       retvm_if(!sensor_info_manager::get_instance().is_valid(info),
-               OP_ERROR, "Invalid param: sensor (%p)", sensor);
+       retv_if(!sensor_info_manager::get_instance().is_valid(info), OP_ERROR);
 
        sensor_id_t sensor_id = info->get_id();
 
@@ -783,7 +781,7 @@ static bool register_event(int handle, unsigned int event_type, unsigned int int
        AUTOLOCK(lock);
 
        if (!sensor_client_info::get_instance().get_sensor_id(handle, sensor_id)) {
-               _E("client %s failed to get handle information", get_client_name());
+               _W("client %s failed to get handle information", get_client_name());
                return false;
        }
 
index 319c960..683c017 100644 (file)
@@ -212,7 +212,7 @@ bool command_channel::cmd_hello(sensor_id_t sensor)
        }
 
        if (cmd_done->value < 0) {
-               _E("client %s got error[%d] from server with sensor [%s]",
+               _W("client %s got value[%d] from server with sensor [%s]",
                        get_client_name(), cmd_done->value, get_sensor_name(sensor));
 
                delete[] (char *)cmd_done;
index d027d8a..743cd29 100644 (file)
@@ -53,7 +53,7 @@ int sensor_client_info::create_handle(sensor_id_t sensor)
                handle++;
 
        if (handle == MAX_HANDLE) {
-               _E("Handles of client %s are full", get_client_name());
+               _W("Handles of client %s are full", get_client_name());
                return MAX_HANDLE_REACHED;
        }
 
@@ -77,7 +77,7 @@ bool sensor_client_info::delete_handle(int handle)
        auto it_handle = m_sensor_handle_infos.find(handle);
 
        if (it_handle == m_sensor_handle_infos.end()) {
-               _E("Handle[%d] is not found for client %s", handle, get_client_name());
+               _W("Handle[%d] is not found for client %s", handle, get_client_name());
                return false;
        }
 
@@ -100,7 +100,7 @@ bool sensor_client_info::register_event(int handle, unsigned int event_type,
        auto it_handle = m_sensor_handle_infos.find(handle);
 
        if (it_handle == m_sensor_handle_infos.end()) {
-               _E("Handle[%d] is not found for client %s", handle, get_client_name());
+               _W("Handle[%d] is not found for client %s", handle, get_client_name());
                return false;
        }
 
@@ -117,7 +117,7 @@ bool sensor_client_info::unregister_event(int handle, unsigned int event_type)
        auto it_handle = m_sensor_handle_infos.find(handle);
 
        if (it_handle == m_sensor_handle_infos.end()) {
-               _E("Handle[%d] is not found for client %s", handle, get_client_name());
+               _W("Handle[%d] is not found for client %s", handle, get_client_name());
                return false;
        }
 
@@ -134,7 +134,7 @@ bool sensor_client_info::register_accuracy_cb(int handle, sensor_accuracy_change
        auto it_handle = m_sensor_handle_infos.find(handle);
 
        if (it_handle == m_sensor_handle_infos.end()) {
-               _E("Handle[%d] is not found for client %s", handle, get_client_name());
+               _W("Handle[%d] is not found for client %s", handle, get_client_name());
                return false;
        }
 
@@ -152,7 +152,7 @@ bool sensor_client_info::unregister_accuracy_cb(int handle)
        auto it_handle = m_sensor_handle_infos.find(handle);
 
        if (it_handle == m_sensor_handle_infos.end()) {
-               _E("Handle[%d] is not found for client %s", handle, get_client_name());
+               _W("Handle[%d] is not found for client %s", handle, get_client_name());
                return false;
        }
 
@@ -170,7 +170,7 @@ bool sensor_client_info::set_sensor_params(int handle, int sensor_state, int pau
        auto it_handle = m_sensor_handle_infos.find(handle);
 
        if (it_handle == m_sensor_handle_infos.end()) {
-               _E("Handle[%d] is not found for client %s", handle, get_client_name());
+               _W("Handle[%d] is not found for client %s", handle, get_client_name());
                return false;
        }
 
@@ -187,7 +187,7 @@ bool sensor_client_info::get_sensor_params(int handle, int &sensor_state, int &p
        auto it_handle = m_sensor_handle_infos.find(handle);
 
        if (it_handle == m_sensor_handle_infos.end()) {
-               _E("Handle[%d] is not found for client %s", handle, get_client_name());
+               _W("Handle[%d] is not found for client %s", handle, get_client_name());
                return false;
        }
 
@@ -204,7 +204,7 @@ bool sensor_client_info::set_sensor_state(int handle, int sensor_state)
        auto it_handle = m_sensor_handle_infos.find(handle);
 
        if (it_handle == m_sensor_handle_infos.end()) {
-               _E("Handle[%d] is not found for client %s", handle, get_client_name());
+               _W("Handle[%d] is not found for client %s", handle, get_client_name());
                return false;
        }
 
@@ -220,7 +220,7 @@ bool sensor_client_info::get_passive_mode(int handle)
        auto it_handle = m_sensor_handle_infos.find(handle);
 
        if (it_handle == m_sensor_handle_infos.end()) {
-               _E("Handle[%d] is not found for client %s", handle, get_client_name());
+               _W("Handle[%d] is not found for client %s", handle, get_client_name());
                return false;
        }
 
@@ -234,7 +234,7 @@ bool sensor_client_info::set_passive_mode(int handle, bool passive)
        auto it_handle = m_sensor_handle_infos.find(handle);
 
        if (it_handle == m_sensor_handle_infos.end()) {
-               _E("Handle[%d] is not found for client %s", handle, get_client_name());
+               _W("Handle[%d] is not found for client %s", handle, get_client_name());
                return false;
        }
 
@@ -250,7 +250,7 @@ bool sensor_client_info::set_sensor_pause_policy(int handle, int pause_policy)
        auto it_handle = m_sensor_handle_infos.find(handle);
 
        if (it_handle == m_sensor_handle_infos.end()) {
-               _E("Handle[%d] is not found for client %s", handle, get_client_name());
+               _W("Handle[%d] is not found for client %s", handle, get_client_name());
                return false;
        }
 
@@ -266,7 +266,7 @@ bool sensor_client_info::set_event_batch(int handle, unsigned int event_type, un
        auto it_handle = m_sensor_handle_infos.find(handle);
 
        if (it_handle == m_sensor_handle_infos.end()) {
-               _E("Handle[%d] is not found for client %s", handle, get_client_name());
+               _W("Handle[%d] is not found for client %s", handle, get_client_name());
                return false;
        }
 
@@ -283,7 +283,7 @@ bool sensor_client_info::set_accuracy(int handle, int accuracy)
        auto it_handle = m_sensor_handle_infos.find(handle);
 
        if (it_handle == m_sensor_handle_infos.end()) {
-               _E("Handle[%d] is not found for client %s", handle, get_client_name());
+               _W("Handle[%d] is not found for client %s", handle, get_client_name());
                return false;
        }
 
@@ -299,7 +299,7 @@ bool sensor_client_info::set_bad_accuracy(int handle, int bad_accuracy)
        auto it_handle = m_sensor_handle_infos.find(handle);
 
        if (it_handle == m_sensor_handle_infos.end()) {
-               _E("Handle[%d] is not found for client %s", handle, get_client_name());
+               _W("Handle[%d] is not found for client %s", handle, get_client_name());
                return false;
        }
 
@@ -315,7 +315,7 @@ bool sensor_client_info::get_event_info(int handle, unsigned int event_type, uns
        auto it_handle = m_sensor_handle_infos.find(handle);
 
        if (it_handle == m_sensor_handle_infos.end()) {
-               _E("Handle[%d] is not found for client %s", handle, get_client_name());
+               _W("Handle[%d] is not found for client %s", handle, get_client_name());
                return false;
        }
 
@@ -367,7 +367,7 @@ bool sensor_client_info::add_command_channel(sensor_id_t sensor, command_channel
        auto it_channel = m_command_channels.find(sensor);
 
        if (it_channel != m_command_channels.end()) {
-               _E("%s alreay has command_channel for %s", get_client_name(), get_sensor_name(sensor));
+               _W("%s alreay has command_channel for %s", get_client_name(), get_sensor_name(sensor));
                return false;
        }
 
@@ -381,7 +381,7 @@ bool sensor_client_info::get_command_channel(sensor_id_t sensor, command_channel
        auto it_channel = m_command_channels.find(sensor);
 
        if (it_channel == m_command_channels.end()) {
-               _E("%s doesn't have command_channel for %s", get_client_name(), get_sensor_name(sensor));
+               _W("%s doesn't have command_channel for %s", get_client_name(), get_sensor_name(sensor));
                return false;
        }
 
@@ -409,7 +409,7 @@ bool sensor_client_info::close_command_channel(sensor_id_t sensor_id)
        auto it_channel = m_command_channels.find(sensor_id);
 
        if (it_channel == m_command_channels.end()) {
-               _E("%s doesn't have command_channel for %s", get_client_name(), get_sensor_name(sensor_id));
+               _W("%s doesn't have command_channel for %s", get_client_name(), get_sensor_name(sensor_id));
                return false;
        }
 
@@ -501,7 +501,7 @@ bool sensor_client_info::get_sensor_id(int handle, sensor_id_t &sensor)
        auto it_handle = m_sensor_handle_infos.find(handle);
 
        if (it_handle == m_sensor_handle_infos.end()) {
-               _E("Handle[%d] is not found for client %s", handle, get_client_name());
+               _W("Handle[%d] is not found for client %s", handle, get_client_name());
                return false;
        }
 
@@ -517,7 +517,7 @@ bool sensor_client_info::get_sensor_state(int handle, int &sensor_state)
        auto it_handle = m_sensor_handle_infos.find(handle);
 
        if (it_handle == m_sensor_handle_infos.end()) {
-               _E("Handle[%d] is not found for client %s", handle, get_client_name());
+               _W("Handle[%d] is not found for client %s", handle, get_client_name());
                return false;
        }
 
@@ -673,7 +673,7 @@ bool sensor_client_info::set_attribute(int handle, int attribute, int value)
        auto it_handle = m_sensor_handle_infos.find(handle);
 
        if (it_handle == m_sensor_handle_infos.end()) {
-               _E("Handle[%d] is not found for client %s", handle, get_client_name());
+               _W("Handle[%d] is not found for client %s", handle, get_client_name());
                return false;
        }
 
@@ -689,7 +689,7 @@ bool sensor_client_info::set_attribute(int handle, int attribute, const char *va
        auto it_handle = m_sensor_handle_infos.find(handle);
 
        if (it_handle == m_sensor_handle_infos.end()) {
-               _E("Handle[%d] is not found for client %s", handle, get_client_name());
+               _W("Handle[%d] is not found for client %s", handle, get_client_name());
                return false;
        }
 
index 470d5d8..c3bd18e 100644 (file)
@@ -59,7 +59,7 @@ bool auto_rotation_sensor::init(void)
        m_accel_sensor = sensor_loader::get_instance().get_sensor(ACCELEROMETER_SENSOR);
 
        if (!m_accel_sensor) {
-               _E("cannot load accel sensor_hal from %s", get_name());
+               _W("cannot load accel sensor_hal from %s", get_name());
                return false;
        }
 
index 9aca0f4..03ddf7c 100644 (file)
@@ -57,7 +57,7 @@ bool face_down_sensor::init(void)
        m_gravity_sensor = sensor_loader::get_instance().get_sensor(GRAVITY_SENSOR);
 
        if (!m_gravity_sensor) {
-               _E("cannot load gravity sensor sensor[%s]", SENSOR_NAME);
+               _W("cannot load gravity sensor sensor[%s]", SENSOR_NAME);
                return false;
        }
 
index 931940a..d4c74ce 100644 (file)
@@ -77,7 +77,7 @@ bool gravity_sensor::init(void)
        m_accel_sensor = sensor_loader::get_instance().get_sensor(ACCELEROMETER_SENSOR);
 
        if (!m_accel_sensor) {
-               _E("cannot load accelerometer sensor_hal[%s]", get_name());
+               _W("cannot load accelerometer sensor_hal[%s]", get_name());
                return false;
        }
 
@@ -150,7 +150,7 @@ void gravity_sensor::synthesize_rv(const sensor_event_t& event)
        int accuracy;
 
        if (!m_fusion->get_rotation_vector(x, y, z, w, heading_accuracy, accuracy)) {
-               _E("Failed to get rotation vector");
+               _W("Failed to get rotation vector");
                return;
        }
 
index f5ad037..56af7b6 100644 (file)
@@ -63,14 +63,14 @@ bool linear_accel_sensor::init(void)
        m_accel_sensor = sensor_loader::get_instance().get_sensor(ACCELEROMETER_SENSOR);
 
        if (!m_accel_sensor) {
-               _E("cannot load accelerometer sensor_hal[%s]", get_name());
+               _W("cannot load accelerometer sensor_hal[%s]", get_name());
                return false;
        }
 
        m_gravity_sensor = sensor_loader::get_instance().get_sensor(GRAVITY_SENSOR);
 
        if (!m_gravity_sensor) {
-               _E("cannot load gravity sensor_hal[%s]", get_name());
+               _W("cannot load gravity sensor_hal[%s]", get_name());
                return false;
        }
 
index 8f4bd79..c9cad8b 100644 (file)
@@ -57,7 +57,7 @@ bool orientation_sensor::init(void)
        m_rotation_vector_sensor = sensor_loader::get_instance().get_sensor(ROTATION_VECTOR_SENSOR);
 
        if (!m_rotation_vector_sensor) {
-               _E("cannot load sensor[%s]", SENSOR_NAME);
+               _W("cannot load sensor[%s]", SENSOR_NAME);
                return false;
        }
        _I("%s is created!", SENSOR_NAME);
index 1af3da1..7c7c9b3 100644 (file)
@@ -60,7 +60,7 @@ bool gyro_rv_sensor::init(void)
        m_gyro_sensor = sensor_loader::get_instance().get_sensor(GYROSCOPE_SENSOR);
 
        if (!m_accel_sensor || !m_gyro_sensor) {
-               _E("cannot load sensors[%s]", SENSOR_NAME);
+               _W("cannot load sensors[%s]", SENSOR_NAME);
                return false;
        }
 
index 6700230..61001c1 100644 (file)
@@ -60,7 +60,7 @@ bool magnetic_rv_sensor::init(void)
        m_mag_sensor = sensor_loader::get_instance().get_sensor(GEOMAGNETIC_SENSOR);
 
        if (!m_accel_sensor || !m_mag_sensor) {
-               _E("cannot load sensors[%s]", SENSOR_NAME);
+               _W("cannot load sensors[%s]", SENSOR_NAME);
                return false;
        }
 
index 0e9db8e..9fb42c7 100644 (file)
@@ -63,7 +63,7 @@ bool rv_sensor::init(void)
        m_mag_sensor = sensor_loader::get_instance().get_sensor(GEOMAGNETIC_SENSOR);
 
        if (!m_accel_sensor || !m_gyro_sensor|| !m_mag_sensor) {
-               _E("cannot load sensors[%s]", SENSOR_NAME);
+               _W("cannot load sensors[%s]", SENSOR_NAME);
                return false;
        }
 
index b60f337..6691978 100644 (file)
@@ -61,35 +61,35 @@ tilt_sensor::tilt_sensor()
        register_supported_event(TILT_RAW_DATA_EVENT);
 
        if (!config.get(SENSOR_TYPE_TILT, ELEMENT_VENDOR, m_vendor)) {
-               _E("[VENDOR] is empty\n");
+               _W("[VENDOR] is empty\n");
                throw ENXIO;
        }
 
        _I("m_vendor = %s", m_vendor.c_str());
 
        if (!config.get(SENSOR_TYPE_TILT, ELEMENT_RAW_DATA_UNIT, m_raw_data_unit)) {
-               _E("[RAW_DATA_UNIT] is empty\n");
+               _W("[RAW_DATA_UNIT] is empty\n");
                throw ENXIO;
        }
 
        _I("m_raw_data_unit = %s", m_raw_data_unit.c_str());
 
        if (!config.get(SENSOR_TYPE_TILT, ELEMENT_DEFAULT_SAMPLING_TIME, &m_default_sampling_time)) {
-               _E("[DEFAULT_SAMPLING_TIME] is empty\n");
+               _W("[DEFAULT_SAMPLING_TIME] is empty\n");
                throw ENXIO;
        }
 
        _I("m_default_sampling_time = %d", m_default_sampling_time);
 
        if (!config.get(SENSOR_TYPE_TILT, ELEMENT_PITCH_ROTATION_COMPENSATION, &m_pitch_rotation_compensation)) {
-               _E("[PITCH_ROTATION_COMPENSATION] is empty\n");
+               _W("[PITCH_ROTATION_COMPENSATION] is empty\n");
                throw ENXIO;
        }
 
        _I("m_pitch_rotation_compensation = %d", m_pitch_rotation_compensation);
 
        if (!config.get(SENSOR_TYPE_TILT, ELEMENT_ROLL_ROTATION_COMPENSATION, &m_roll_rotation_compensation)) {
-               _E("[ROLL_ROTATION_COMPENSATION] is empty\n");
+               _W("[ROLL_ROTATION_COMPENSATION] is empty\n");
                throw ENXIO;
        }
 
@@ -109,7 +109,7 @@ bool tilt_sensor::init(void)
        m_fusion_sensor = sensor_loader::get_instance().get_sensor(FUSION_SENSOR);
 
        if (!m_accel_sensor || !m_fusion_sensor) {
-               _E("Failed to load sensors,  accel: %#x, fusion: %#x",
+               _W("Failed to load sensors,  accel: %#x, fusion: %#x",
                        m_accel_sensor, m_fusion_sensor);
                return false;
        }
index d978481..8d57968 100644 (file)
@@ -336,6 +336,12 @@ bool command_worker::send_cmd_get_sensor_list_done(void)
                return false;
        }
 
+       /*
+        * TODO: get_sensor_list() command is processed on one-time connection in the current architecture.
+        *       but it doesn't need to use one-time connection.
+        */
+       m_socket.close();
+
        return true;
 }
 
@@ -397,7 +403,7 @@ bool command_worker::cmd_hello(void *payload)
        m_module = (sensor_base *)sensor_loader::get_instance().get_sensor(cmd->sensor);
 
        if (!m_module) {
-               _E("Sensor type[%d] is not supported", cmd->sensor);
+               _W("Sensor type[%d] is not supported", cmd->sensor);
                if (!get_client_info_manager().has_sensor_record(m_client_id))
                        get_client_info_manager().remove_client_record(m_client_id);
 
index f606d29..c25d07a 100644 (file)
@@ -251,7 +251,7 @@ void sensor_loader::create_virtual_sensors(const char *name)
        }
 
        if (!instance->init()) {
-               _E("Failed to init %s", name);
+               _W("Failed to init %s", name);
                delete instance;
                return;
        }
index 14e24fe..3e30174 100755 (executable)
@@ -342,7 +342,8 @@ void server::run(void)
 
 void server::stop(void)
 {
-       _I("Sensord server stopped");
+       if (!m_running)
+               return;
 
        m_running = false;
 
@@ -351,6 +352,8 @@ void server::stop(void)
                g_main_loop_unref(m_mainloop);
                m_mainloop = NULL;
        }
+
+       _I("Sensord server stopped");
 }
 
 server& server::get_instance(void)
index 9f88a24..9108016 100644 (file)
@@ -41,7 +41,7 @@ bool worker_thread::transition_function(trans_func_index index)
 {
        if (m_trans_func[index] != NULL) {
                if (!m_trans_func[index](m_context)) {
-                       _E("Transition[%d] function returning false", index);
+                       _W("Transition[%d] function returning false", index);
                        return false;
                }
        }
index 3b55107..46033ea 100644 (file)
@@ -83,10 +83,8 @@ bool csocket::bind(const char *sock_path)
        int length;
        mode_t socket_mode;
 
-       if (!is_valid()) {
-               _E("%s's socket is invalid", get_client_name());
+       if (!is_valid())
                return false;
-       }
 
        if (!access(sock_path, F_OK)) {
                unlink(sock_path);
@@ -116,10 +114,8 @@ bool csocket::bind(const char *sock_path)
 
 bool csocket::listen(const int max_connections)
 {
-       if (!is_valid()) {
-               _E("Socket(%d) is invalid", m_sock_fd);
+       if (!is_valid())
                return false;
-       }
 
        if (::listen(m_sock_fd, max_connections) < 0) {
                _ERRNO(errno, _E, "Failed to listen for socket[%d]", m_sock_fd);
@@ -309,10 +305,8 @@ ssize_t csocket::recv_for_stream(void* buffer, size_t size) const
 
 ssize_t csocket::send(const void *buffer, size_t size) const
 {
-       if (!is_valid()) {
-               _E("Socket(%d) is invalid", m_sock_fd);
+       if (!is_valid())
                return -EINVAL;
-       }
 
        if (m_sock_type == SOCK_STREAM)
                return send_for_stream(buffer, size);
@@ -322,10 +316,8 @@ ssize_t csocket::send(const void *buffer, size_t size) const
 
 ssize_t csocket::recv(void* buffer, size_t size) const
 {
-       if (!is_valid()) {
-               _E("Socket(%d) is invalid", m_sock_fd);
+       if (!is_valid())
                return -EINVAL;
-       }
 
        if (m_sock_type == SOCK_STREAM)
                return recv_for_stream(buffer, size);
@@ -341,10 +333,8 @@ bool csocket::connect(const char *sock_path)
        int addr_len;
        bool prev_blocking_mode;
 
-       if (!is_valid()) {
-               _E("%s's socket is invalid", get_client_name());
+       if (!is_valid())
                return false;
-       }
 
        prev_blocking_mode = is_blocking_mode();
 
@@ -413,10 +403,8 @@ bool csocket::set_blocking_mode(bool blocking)
 {
        int flags;
 
-       if (!is_valid()) {
-               _E("Socket(%d) is invalid", m_sock_fd);
+       if (!is_valid())
                return false;
-       }
 
        flags = fcntl(m_sock_fd, F_GETFL);
 
@@ -444,10 +432,8 @@ bool csocket::set_sock_type(void)
 
        opt_len = sizeof(sock_type);
 
-       if (!is_valid()) {
-               _E("Socket(%d) is invalid", m_sock_fd);
+       if (!is_valid())
                return false;
-       }
 
        if (getsockopt(m_sock_fd, SOL_SOCKET, SO_TYPE, &sock_type, &opt_len) < 0) {
           _ERRNO(errno, _E, "getsockopt(SOL_SOCKET, SO_TYPE) failed for %s, m_sock_fd: %d",
@@ -469,10 +455,8 @@ bool csocket::set_connection_mode(void)
        tv.tv_sec = TIMEOUT;
        tv.tv_usec = 0;
 
-       if (!is_valid()) {
-               _E("Socket(%d) is invalid", m_sock_fd);
+       if (!is_valid())
                return false;
-       }
 
        if (setsockopt(m_sock_fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0) {
                _ERRNO(errno, _E, "Set SO_RCVTIMEO failed for %s, m_sock_fd : %d", get_client_name(), m_sock_fd);
@@ -500,10 +484,8 @@ bool csocket::is_blocking_mode(void)
 {
        int flags;
 
-       if (!is_valid()) {
-               _E("Socket(%d) is invalid", m_sock_fd);
+       if (!is_valid())
                return false;
-       }
 
        flags = fcntl(m_sock_fd, F_GETFL);
 
@@ -529,7 +511,7 @@ bool csocket::close(void)
 {
        if (m_sock_fd >= 0) {
                if (::close(m_sock_fd) < 0) {
-                       _ERRNO(errno, _E, "Failed to close socket[%d]", m_sock_fd);
+                       _ERRNO(errno, _W, "Failed to close socket[%d]", m_sock_fd);
                        return false;
                }
                m_sock_fd = -1;