summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNaveen Michaud-Agrawal <naveen.michaudagrawal@gmail.com>2023-11-23 00:50:32 +0000
committerNaveen Michaud-Agrawal <naveen.michaudagrawal@gmail.com>2023-11-23 00:50:32 +0000
commitee4cc9489355cd9a480ae7737bd0cf3c0e893ba0 (patch)
tree7acbb5d02c6a7cd90a91b6fc94e80aaae6b000c0
parentprint: Hack to forward Hex House print requests to folk0 (diff)
downloadfolk-ee4cc9489355cd9a480ae7737bd0cf3c0e893ba0.tar.gz
folk-ee4cc9489355cd9a480ae7737bd0cf3c0e893ba0.zip
Clear mailbox of unmatched processes
-rw-r--r--lib/peer.tcl4
-rw-r--r--lib/process.tcl2
-rw-r--r--main.tcl8
3 files changed, 14 insertions, 0 deletions
diff --git a/lib/peer.tcl b/lib/peer.tcl
index 42297e4a..e8e18be8 100644
--- a/lib/peer.tcl
+++ b/lib/peer.tcl
@@ -34,6 +34,10 @@ proc ::peer {process {dieOnDisconnect false}} {
variable process
Mailbox::receive $process $::thisProcess
}
+ proc clear {} {
+ variable process
+ Mailbox::clear $process $::thisProcess
+ }
proc share {shareStatements} {
variable process
diff --git a/lib/process.tcl b/lib/process.tcl
index faaa5e84..c9adec0a 100644
--- a/lib/process.tcl
+++ b/lib/process.tcl
@@ -115,6 +115,8 @@ proc Start-process {name body} {
}
}
On unmatch {
+ # Clear the mailbox
+ ::Peers::${name}::clear
# Remember to suppress/kill the process if it shows up
# later after we're gone.
dict set ::peersBlacklist $name true
diff --git a/main.tcl b/main.tcl
index 62d0e7d7..500534fc 100644
--- a/main.tcl
+++ b/main.tcl
@@ -556,6 +556,14 @@ namespace eval ::Mailbox {
} pthread_mutex_unlock(&mailbox->mutex);
return ret;
}
+ $cc proc clear {char* from char* to} void {
+ mailbox_t* mailbox = find(from, to);
+ pthread_mutex_lock(&mailbox->mutex); {
+ mailbox->active = 0;
+ mailbox->mail[0] = '\0';
+ mailbox->mailLen = 0;
+ } pthread_mutex_unlock(&mailbox->mutex);
+ }
$cc compile
init
}