]> git.saurik.com Git - apple/syslog.git/blobdiff - syslogd.tproj/daemon.c
syslog-356.200.4.tar.gz
[apple/syslog.git] / syslogd.tproj / daemon.c
index 5c87c222771d61fa765b42e5b39c722123f54c16..746cd4249e985b5793030569b702ec3347f8ef85 100644 (file)
@@ -453,8 +453,6 @@ aslmsg_verify(asl_msg_t *msg, uint32_t source, int32_t *kern_post_level, uid_t *
                }
        }
 
-       if (uid_out != NULL) *uid_out = uid;
-
        gid = -2;
        val = asl_msg_get_val_for_key(msg, ASL_KEY_GID);
        if (val == NULL)
@@ -484,7 +482,6 @@ aslmsg_verify(asl_msg_t *msg, uint32_t source, int32_t *kern_post_level, uid_t *
 
                        break;
                }
-               case SOURCE_UDP_SOCKET:
                case SOURCE_ASL_MESSAGE:
                case SOURCE_LAUNCHD:
                {
@@ -507,6 +504,8 @@ aslmsg_verify(asl_msg_t *msg, uint32_t source, int32_t *kern_post_level, uid_t *
                }
        }
 
+       if (uid_out != NULL) *uid_out = uid;
+
        /* Sender */
        if (sval == NULL) sval = asl_msg_get_val_for_key(msg, ASL_KEY_SENDER);
        if (sval == NULL)
@@ -592,13 +591,6 @@ aslmsg_verify(asl_msg_t *msg, uint32_t source, int32_t *kern_post_level, uid_t *
                asl_msg_set_key_val(msg, ASL_KEY_EXPIRE_TIME, buf);
        }
 
-       /* Set DB Expire Time for Filesystem errors */
-       if (!strcmp(fac, FSLOG_VAL_FACILITY))
-       {
-               snprintf(buf, sizeof(buf), "%llu", (unsigned long long) tick + FS_TTL_SEC);
-               asl_msg_set_key_val(msg, ASL_KEY_EXPIRE_TIME, buf);
-       }
-
        /*
         * special case handling of kernel disaster messages
         */
@@ -927,6 +919,7 @@ void
 process_message(asl_msg_t *msg, uint32_t source)
 {
        int64_t msize = 0;
+       static bool wq_draining = false;
        bool is_control = false;
        asl_msg_t *x;
 
@@ -934,6 +927,21 @@ process_message(asl_msg_t *msg, uint32_t source)
 
        is_control = asl_check_option(msg, ASL_OPT_CONTROL) != 0;
 
+       if ((!is_control) && wq_draining)
+       {
+               if (global.memory_size >= (global.memory_max / 2))
+               {
+                       asldebug("Work queue draining: dropped message.\n");
+                       asl_msg_release(msg);
+                       return;
+               }
+               else
+               {
+                       asldebug("Work queue re-enabled at 1/2 max.  size %lld  max %lld\n", global.memory_size, global.memory_max);
+                       wq_draining = false;
+               }
+       }
+
        __block vproc_transaction_t vt = vproc_transaction_begin(NULL);
 
        for (x = msg; x != NULL; x = x->next) msize += x->mem_size;
@@ -941,12 +949,13 @@ process_message(asl_msg_t *msg, uint32_t source)
        if ((global.memory_size + msize) >= global.memory_max)
        {
                char str[256];
+
+               wq_draining = true;
                asl_msg_release(msg);
 
-               asldebug("Work queue memory limit - dropped message.  msize %lld  size %lld  max %lld\n", msize, global.memory_size + msize, global.memory_max);
-               snprintf(str, sizeof(str), "[Sender syslogd] [Level 2] [PID %u] [Message Received message size %lld overflows work queue limit %lld - dropping message] [UID 0] [UID 0] [Facility syslog]", global.pid, msize, global.memory_max);
+               asldebug("Work queue disabled.  msize %lld  size %lld  max %lld\n", msize, global.memory_size + msize, global.memory_max);
+               snprintf(str, sizeof(str), "[Sender syslogd] [Level 2] [PID %u] [Message Internal memory size limit %lld exceeded - dropping messages] [UID 0] [UID 0] [Facility syslog]", global.pid, global.memory_max);
                msg = asl_msg_from_string(str);
-               for (x = msg; x != NULL; x = x->next) msize += x->mem_size;
        }
 
        OSAtomicAdd64(msize, &global.memory_size);