Fix daemon get stuck at 100% CPU when no log file
authorNeutron Soutmun <neo.neutron@gmail.com>
Fri, 18 Sep 2009 10:29:58 +0000 (17:29 +0700)
committerNeutron Soutmun <neo.neutron@gmail.com>
Fri, 18 Sep 2009 10:29:58 +0000 (17:29 +0700)
  * Fix daemon get stuck when the log file does not exists, requested access
    to the file is not allowed or any errors. (Thanks Theppitak for the issue
    of this case)

src/rahunasd.c

index 37bb683..ec6b229 100644 (file)
@@ -182,7 +182,7 @@ void rh_reload()
            rh_main_server->main_config->log_file);
     rh_main_server->log_fd = rh_openlog(rh_main_server->main_config->log_file);
 
-    if (!rh_main_server->log_fd) {
+    if (rh_main_server->log_fd == -1) {
       syslog(LOG_ERR, "Could not open log file %s\n", 
              rh_main_server->main_config->log_file);
       exit(EXIT_FAILURE);
@@ -346,7 +346,7 @@ int main(int argc, char **argv)
            rh_main_server->main_config->log_file);
     rh_main_server->log_fd = rh_openlog(rh_main_server->main_config->log_file);
 
-    if (!rh_main_server->log_fd) {
+    if (rh_main_server->log_fd == -1) {
       syslog(LOG_ERR, "Could not open log file %s\n", 
              rh_main_server->main_config->log_file);
       exit(EXIT_FAILURE);