diff options
author | Jeremy Allison <jra@samba.org> | 2003-04-23 00:19:16 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2003-04-23 00:19:16 +0000 |
commit | c057f9faff14614f24165290bfbf53965063199d (patch) | |
tree | fdc25630db262f825cf2d83c0675b30f8041ed5a /source3/lib | |
parent | 08c2e81a18798a5d66d37e75207816e5934941a7 (diff) | |
download | samba-c057f9faff14614f24165290bfbf53965063199d.tar.gz samba-c057f9faff14614f24165290bfbf53965063199d.tar.bz2 samba-c057f9faff14614f24165290bfbf53965063199d.zip |
Limit the number of outstanding print notify messages for a process to
1000.
Jeremy.
(This used to be commit aabaac05c6adbb510ed27f87115de3e83e27158c)
Diffstat (limited to 'source3/lib')
-rw-r--r-- | source3/lib/messages.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/source3/lib/messages.c b/source3/lib/messages.c index 0615cc1883..8706ede706 100644 --- a/source3/lib/messages.c +++ b/source3/lib/messages.c @@ -304,6 +304,37 @@ BOOL message_send_pid_with_timeout(pid_t pid, int msg_type, const void *buf, siz } /**************************************************************************** + Count the messages pending for a particular pid. Expensive.... +****************************************************************************/ + +unsigned int messages_pending_for_pid(pid_t pid) +{ + TDB_DATA kbuf; + TDB_DATA dbuf; + char *buf; + unsigned int message_count = 0; + + kbuf = message_key_pid(sys_getpid()); + + dbuf = tdb_fetch(tdb, kbuf); + if (dbuf.dptr == NULL || dbuf.dsize == 0) { + SAFE_FREE(dbuf.dptr); + return 0; + } + + for (buf = dbuf.dptr; dbuf.dsize > sizeof(struct message_rec);) { + struct message_rec rec; + memcpy(&rec, buf, sizeof(rec)); + buf += (sizeof(rec) + rec.len); + dbuf.dsize -= (sizeof(rec) + rec.len); + message_count++; + } + + SAFE_FREE(dbuf.dptr); + return message_count; +} + +/**************************************************************************** Retrieve all messages for the current process. ****************************************************************************/ |