]> arthur.barton.de Git - netatalk.git/commitdiff
Fix in logger setup code
authorFrank Lahm <franklahm@googlemail.com>
Thu, 1 Jul 2010 12:53:46 +0000 (14:53 +0200)
committerFrank Lahm <franklahm@googlemail.com>
Thu, 1 Jul 2010 12:53:46 +0000 (14:53 +0200)
libatalk/dsi/dsi_stream.c
libatalk/util/logger.c
libatalk/util/test/logger_test.c

index 2f85ac318d225bd043504b0701e0c77061ae6d1d..71d36953d0f207fe2ef04b2b3245cfbe6014245b 100644 (file)
@@ -80,6 +80,8 @@ static int dsi_buffer(DSI *dsi)
     int    len;
     int    maxfd;
 
+    LOG(log_maxdebug, logtype_dsi, "dsi_buffer: switching to non-blocking IO");
+
     /* non blocking mode */
     if (setnonblock(dsi->socket, 1) < 0) {
         /* can't do it! exit without error it will sleep to death below */
@@ -122,6 +124,9 @@ static int dsi_buffer(DSI *dsi)
             break;
         }
     }
+
+    LOG(log_maxdebug, logtype_dsi, "dsi_buffer: switching back to blocking IO");
+
     if (setnonblock(dsi->socket, 0) < 0) {
         /* can't do it! afpd will fail very quickly */
         LOG(log_error, logtype_dsi, "dsi_buffer: ioctl blocking mode %s", strerror(errno));
@@ -152,6 +157,9 @@ ssize_t dsi_stream_write(DSI *dsi, void *data, const size_t length, int mode)
   
   dsi->in_write++;
   written = 0;
+
+  LOG(log_maxdebug, logtype_dsi, "dsi_stream_write: sending %u bytes", length);
+
   while (written < length) {
       len = send(dsi->socket, (u_int8_t *) data + written, length - written, flags);
       if ((len == 0) || (len == -1 && errno == EINTR))
index 47a7f7caf773488ce211923b7510e74c95615577..ecaced072f2f397e37acd76e5fcc4c619ec74829 100644 (file)
@@ -76,10 +76,9 @@ log_config_t log_config = { 0 };
    0:               set ?
    0:               syslog ?
    -1:              logfiles fd
-   log_maxdebug:    force first LOG call to call make_log_entry which
-                    then calls log_init because "inited" is still 0
+   log_none:        no logging by default
    0:               Display options */
-#define DEFAULT_LOG_CONFIG {0, 0, -1, log_maxdebug, 0}
+#define DEFAULT_LOG_CONFIG {0, 0, -1, log_none, 0}
 
 UAM_MODULE_EXPORT logtype_conf_t type_configs[logtype_end_of_list_marker] = {
     DEFAULT_LOG_CONFIG, /* logtype_default */
@@ -336,8 +335,7 @@ void log_setup(const char *filename, enum loglevels loglevel, enum logtypes logt
         process_uid = geteuid();
         if (process_uid) {
             if (seteuid(OPEN_LOGS_AS_UID) == -1) {
-                /* XXX failing silently */
-                return;
+                process_uid = 0;
             }
         }
         type_configs[logtype].fd = open(filename,
index e1529fced3091538fa3c7db0505cf3d0cd9e49d3..97323a39aeba879f54046f2ebdf44c5dcf48dbed 100644 (file)
@@ -24,15 +24,16 @@ int main(int argc, char *argv[])
   unsetuplog("Default");
 #endif
   /* filelog testing */
-  setuplog("Default LOG_INFO test.log");
-  LOG(log_info, logtype_logger, "This should log.");
-  LOG(log_info, logtype_default, "This should log.");
-  LOG(log_error, logtype_logger, "This should log.");
-  LOG(log_error, logtype_default, "This should log.");
-  LOG(log_debug, logtype_logger, "This should not log.");
-  LOG(log_debug, logtype_default, "This should not log.");
-
-  LOG(log_severe, logtype_logger, "Logging Test finishing");
+
+  setuplog("DSI log_maxdebug test.log");
+  LOG(log_info, logtype_dsi, "This should log.");
+  LOG(log_error, logtype_default, "This should not log.");
+
+  setuplog("Default log_debug test.log");
+  LOG(log_debug, logtype_default, "This should log.");
+  LOG(log_maxdebug, logtype_default, "This should not log.");
+
+  LOG(log_maxdebug, logtype_dsi, "This should still log.");
 
   return 0;
 }