[snmp] ListeningContext problems
Birgit Arkesteijn
birgit at westhawk.co.uk
Wed Jul 23 14:15:03 BST 2008
Hi Jeremy,
Sorry for my late response.
Thanks for pointing out those bugs and giving us the solution!
I've added them to the stack and checked the code in.
Thanks, Birgit
On 17/07/08 14:52, Jeremy Stone wrote:
> Have noticed a couple of problem with ListeningContext:
>
> (1) uk.co.westhawk.snmp.stack.ListeningContext destroys itself when
> either the last RawPduListener or the last UnhandledRawPduListener is
> removed - even though there may be a listener of the other type
> registered.
>
>
>
> Suggest following code change:
>
> (a) Add method:
>
> private void destroyIfNoListeners()
>
> {
>
> if (pduSupport.getListenerCount() == 0
>
> && unhandledSupport.getListenerCount() == 0)
>
> {
>
> destroy();
>
> }
>
> }
>
>
>
> (b) Call this from removeUnhandledRawPduListener and
> removeRawPduListener instead of checking the respective listener counts.
>
>
>
> (2) The startListening method sets the value of the soc member before
> it calls soc.create(...). If soc.create fails (e.g. there is another
> process listening on the port), subsequent calls to startListening will
> not throw an IOException (because soc!=null) but will not try to
> re-create the socket. Therefore callers will erroneously assume that the
> socket is created successfully.
>
>
>
> Maybe should only set soc after a successful call to create, i.e:
>
>
>
> protected void startListening() throws java.io.IOException
>
> {
>
> synchronized (SOC_LOCK)
>
> {
>
> if (soc == null)
>
> {
>
> ContextSocketFace tempSoc = AbstractSnmpContext
>
> .getSocket(typeSocket);
>
> tempSoc.create(hostPort, bindAddr);
>
>
>
> soc = tempSoc;
>
>
>
> ......etc as before
>
> }
>
> if (me == null)
>
> {
>
> ......etc as before
>
> }
>
> }
>
> }
>
> This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.
>
> Cyclone Technology Ltd. Registered in England and Wales No 3114265, Registered Office: 1 Church Walk, Tenbury Wells, WR15 8HT
>
> Visit our website at www.cyclone-technology.com
> _______________________________________________
> snmp mailing list
> snmp at snmp.westhawk.co.uk
> http://snmp.westhawk.co.uk/mailman/listinfo/snmp
--
-- Birgit Arkesteijn, birgit at westhawk.co.uk,
-- Westhawk Ltd, Albion Wharf, 19 Albion Street, Manchester M1 5LN, UK
-- Company no: 1769350
-- Registered Office:
-- 15 London Road, Stockton Heath, Warrington WA4 6SJ. UK.
-- tel.: +44 (0)161 237 0660
-- <URL: http://www.westhawk.co.uk>
More information about the snmp
mailing list