asyn
asyn copied to clipboard
port driver's connect method is called twice when autoConnect=true and canBlock=true
I observed in an areaDetector driver, the connect method was called twice every 20 seconds if the camera is unplugged.
In the portThread function, line 805-850 deals with connect/disconnect requests, which invokes the first connect call. The traceback is,
#0 ADPylon::connect (this=0x5555556b6890, pasynUser=0x5555556b94e8) at ../ADPylon.cpp:804
#1 0x00007ffff7d31d3a in connect (drvPvt=0x5555556b6890, pasynUser=0x5555556b94e8) at ../../asyn/asynPortDriver/asynPortDriver.cpp:3586
#2 0x00007ffff7d11318 in portConnectProcessCallback (pasynUser=0x5555556b94e8) at ../../asyn/asynDriver/asynManager.c:3092
#3 0x00007ffff7d137ee in portThread (pport=0x5555556b8080) at ../../asyn/asynDriver/asynManager.c:831
#4 0x00007ffff7b39dda in start_routine (arg=0x5555556b9020) at ../osi/os/posix/osdThread.c:441
#5 0x00007ffff797ffd4 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#6 0x00007ffff7a005bc in ?? () from /lib/x86_64-linux-gnu/libc.so.6
And later line 851-856 finds the port is not connected and calls autoConnectDevice, which invokes the second connect call. The traceback is,
#0 ADPylon::connect (this=0x5555556b6890, pasynUser=0x5555556b8438) at ../ADPylon.cpp:804
#1 0x00007ffff7d31d3a in connect (drvPvt=0x5555556b6890, pasynUser=0x5555556b8438) at ../../asyn/asynPortDriver/asynPortDriver.cpp:3586
#2 0x00007ffff7d11ac1 in connectAttempt (pdpCommon=pdpCommon@entry=0x5555556b80a8) at ../../asyn/asynDriver/asynManager.c:770
#3 0x00007ffff7d13947 in autoConnectDevice (pdevice=0x0, pport=0x5555556b8080) at ../../asyn/asynDriver/asynManager.c:711
#4 portThread (pport=0x5555556b8080) at ../../asyn/asynDriver/asynManager.c:852
#5 0x00007ffff7b39dda in start_routine (arg=0x5555556b9020) at ../osi/os/posix/osdThread.c:441
#6 0x00007ffff797ffd4 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#7 0x00007ffff7a005bc in ?? () from /lib/x86_64-linux-gnu/libc.so.6
If canBlock is false, the first call is synchronous and will not enter portThread. If autoConnect is false, autoConnectDevice will skip the second call. This makes me wonder if line 851-856 is necessary at all.