[bind10-dev] Question about config channel and another msgq channel
Kazunori Fujiwara
fujiwara at wide.ad.jp
Tue Jun 22 06:34:08 UTC 2010
> From: Jelte Jansen <jelte at isc.org>
> perhaps we should simply make the blocking call nonblocking (or make it
> optional), i think the rest of the code in check_command is already prepared for
> that.
I agree. Adding nonblock parameter for check_command() method is
desirable, I think.
> Furthermore, perhaps i'm not understanding your question here, but I think you
> could simply call check_command in this code where you now do group_recvmsg(),
> and determine what type (config/stats) it is in the callback you provide, or is
> that not possible?
It's possible. This case, we need new check_command method.
For example, " check_command_after_recvfrom(msg, env) ".
It may be check_command() minus "msg, env = self._session.group_recvmsg(False)".
The usage may be:
cc = Session()
cc.subscribe_group("stat_group")
config = ModuleCCSession(SPECFILE, config_handler, command_handler, cc)
config.start()
while true:
r,w,e = select.select([cc._socket], [], [], wait)
for sock in r:
if sock == cc._socket:
data,envelope = cc.group_recvmsg(False)
# parse envelope
if the envelope and data is for config:
config.check_command(data, envelope)
elsif the envelope and data is for statistics:
DO statistics:
This case, socket usage is minimum.
> (check_command blocks but with select you already found there is data, though
> one should also put hasQueuedMsgs() in this loop then, before the select(), and
> handle those if there are any)
Hmm,,, recvmsg(nonblock=False) may block if select detect data from
socket but hasQueuedMsgs() > 0 or has_queued_msgs() > 0 in python ?
Then using nonblock version is better?
And this is two sessions solution.
A program uses two msgq sessions, one is config via ccsession and the
other is another group, then blocking check_command() is OK because
select() detects there is some change before check_command().
cc = Session()
cc.subscribe_group("stat_group")
config = ModuleCCSession(SPECFILE, config_handler, command_handler)
config.start()
while true:
r,w,e = select.select([cc._socket,config._session._socket], [], [], wait)
for sock in r:
if sock == cc._socket:
data,envelope = cc.group_recvmsg(False)
Do statistics
elsif sock == config._session._socket:
config.check_command()
Do you consider using two msgq sessions in one program is OK?
Regards,
--
Kazunori Fujiwara
More information about the bind10-dev
mailing list