Browse Source

shellthread::manager::get_tag_config - check if tag/configuration valid for new shellfilter::log::open calls

master
Julian Noble 2 weeks ago
parent
commit
0428aab877
  1. 6
      src/modules/shellfilter-999999.0a1.0.tm
  2. 16
      src/modules/shellthread-999999.0a1.0.tm

6
src/modules/shellfilter-999999.0a1.0.tm

@ -28,6 +28,9 @@ tcl::namespace::eval shellfilter::log {
variable is_enabled
set is_enabled 1
#'tag' is an identifier for the log source.
#(well.. really it's a common *target* of file and/or syslog host:port which can be written to from any thread that uses the tag)
#the terminology here is kinda ratshit.
# each tag will use it's own thread to write to the configured log target
proc ::shellfilter::log::open {tag {settingsdict {}}} {
upvar ::shellfilter::sources sourcelist
@ -2824,7 +2827,8 @@ namespace eval shellfilter {
#chan configure $inchan -buffering none -blocking 1 ;#test
chan configure $inchan -buffering $inbuffering -blocking 0 ;#we are setting up a readable handler for this - so non-blocking ok
#chan configure $inchan -buffering $inbuffering -blocking 0 ;#we are setting up a readable handler for this - so non-blocking ok
chan configure $inchan -buffering $inbuffering
chan configure $errchan -buffering $errbuffering

16
src/modules/shellthread-999999.0a1.0.tm

@ -485,10 +485,16 @@ namespace eval shellthread::manager {
if {[dict exists $workers $sourcetag]} {
set winfo [dict get $workers $sourcetag]
if {[dict get $winfo tid] ne "noop" && [thread::exists [dict get $winfo tid]]} {
#add our client-info to existing worker thread
# add our client-info to existing worker thread
set existing_settings [get_tag_config $sourcetag]
if {$settingsdict eq $existing_settings} {
#same settings - share the worker
dict lappend winfo list_client_tids $tidclient
dict set workers $sourcetag $winfo ;#writeback
return [dict get $winfo tid]
} else {
error "shellthread::manager::new_worker error: tag $sourcetag already has a worker with a different configuration\nexisting: $existing_settings\nattempted: $settingsdict"
}
}
}
@ -703,6 +709,14 @@ namespace eval shellthread::manager {
}
return $taginfo_list
}
proc get_tag_config {tag} {
variable workers
if {![dict exists $workers $tag]} {
error "shellthread::manager::get_tag_config error no existing tag $tag"
}
set workertid [dict get $workers $tag tid]
set conf [thread::send $workertid {set ::shellthread::worker::settings}]
}
#finalisation
proc shutdown_free_threads {{timeout 2500}} {

Loading…
Cancel
Save