bulkmail_record_sent_message

one of the documented procedures in this installation of the ACS
Usage:
bulkmail_record_sent_message   bulkmail_id   user_id   sent_date
What it does:
Record a sent message in the db_flush_queue and in the instance counts
Defined in: /web/philip/tcl/bulkmail-utils.tcl

Source code:


    ns_share bulkmail_db_flush_queue_mutex
    ns_share bulkmail_db_flush_queue
    ns_share bulkmail_db_flush_wait_event
    ns_share bulkmail_instance_mutexes
    ns_share bulkmail_instances_mutex
    ns_share bulkmail_instances
    ns_share bulkmail_finished_instances_mutex
    ns_share bulkmail_finished_instances
    ns_share bulkmail_instance_finished_event

    ns_mutex lock $bulkmail_db_flush_queue_mutex
    catch {
	lappend bulkmail_db_flush_queue [list $bulkmail_id $user_id $sent_date]
    }
    ns_mutex unlock $bulkmail_db_flush_queue_mutex

    # tell the waiting thread that it's time to do its thing
    ns_event set $bulkmail_db_flush_wait_event

    # Next, let's take care of registering this in our instance message count
    set instance_mutex [ns_set get $bulkmail_instance_mutexes $bulkmail_id]

    ns_mutex lock $instance_mutex
    catch {
	ns_mutex lock $bulkmail_instances_mutex
	catch {
	    set instance_stats [ns_set get $bulkmail_instances $bulkmail_id]
	}
	ns_mutex unlock $bulkmail_instances_mutex

	# instance_stats is a two-item list: queued sent
	set queued_count [lindex $instance_stats 0]
	set sent_count [lindex $instance_stats 1]
	incr sent_count
	ns_mutex lock $bulkmail_instances_mutex
	catch {
	    ns_set delkey $bulkmail_instances $bulkmail_id
	    ns_set put $bulkmail_instances $bulkmail_id [list $queued_count $sent_count]
	}
	ns_mutex unlock $bulkmail_instances_mutex
    }
    ns_mutex unlock $instance_mutex

    if { $queued_count == $sent_count } {
	ns_mutex lock $bulkmail_finished_instances_mutex
	catch {
	    ns_set put $bulkmail_finished_instances $bulkmail_id $sent_count
	}
	ns_mutex unlock $bulkmail_finished_instances_mutex
	ns_event set $bulkmail_instance_finished_event
    }


philg@mit.edu