]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Shm.pl
wtf forker hacked up from jethro's patch
[infobot.git] / src / Shm.pl
index 3ecf9b930aabbe4403b45240cf112df158d2d841..3ce116c761cd90cd473eab25e85e8147cb587c9e 100644 (file)
@@ -82,12 +82,13 @@ sub shmWrite {
     my $read = &shmRead($key);
     $read =~ s/\0+//g;
     if ($read eq "") {
-       $str = sprintf("%s:%d:%d: ", $param{ircNick}, $bot_pid, time());
+       $str = sprintf("%s:%d:%d: ", $param{ircUser}, $bot_pid, time());
     } else {
        $str = $read ."||". $str;
     }
 
-    if (!shmwrite($key, '', $position, $size)) {
+    if (!shmwrite($key, $str, $position, $size)) {
+       &DEBUG("shmWrite($key, $str)");
        &ERROR("shmWrite: failed: $!");
     }
 }
@@ -142,9 +143,9 @@ sub addForked {
        if ($count > 3) {       # 3 seconds.
            my $list = join(', ', keys %forked);
            if (defined $who) {
-               &msg($who, "exceeded allowed forked count: $list");
+               &msg($who, "exceeded allowed forked count (shm $shm): $list");
            } else {
-               &status("Fork: I ran too many forked processes :) Giving up $name.");
+               &status("Fork: I ran too many forked processes :) Giving up $name. Shm: $shm");
            }
 
            return 0;
@@ -228,13 +229,14 @@ sub shmFlush {
     return if ($$ != $::bot_pid); # fork protection.
 
     if (@_) {
-       &ScheduleThis(5, "shmFlush");
+       &ScheduleThis(15, "shmFlush");
        return if ($_[0] eq "2");
     }
 
     my $time;
     my $shmmsg = &shmRead($shm);
-    $shmmsg =~ s/\0//g;         # remove padded \0's.
+    # remove padded \0's.
+    $shmmsg =~ s/\0//g;
     return if (length($shmmsg) == 0);
     if ($shmmsg =~ s/^(\S+):(\d+):(\d+): //) {
        my $n   = $1;