EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: RE: Problem with procServ on RHEL6
From: Mark Rivers <[email protected]>
To: "'Ralph Lange'" <[email protected]>, "[email protected]" <[email protected]>
Date: Thu, 14 Jul 2016 20:02:12 +0000
Hi,

I've done a bit more investigating on this problem.

I enabled procServ debugging by setting the environment variable PROCSERV_DEBUG to 1.  I then started procServ twice in 2 different terminal windows.

This is what happens on Centos7.

This is the first time procServ is started:

*************************************************************
[det@ppu071 ~]$ /usr/local/bin/procServ -L /home/det/test.log 30000 /bin/bash
Setting up messages
Checking command file validity
Installing signal handlers
Creating control listener
Bind returned 0
Listening on fd 3
Created new telnet listener (acceptItem 0x22dc260) on port 30000 (read/write)
Adding connection 0x22dc260 to list
Opened file /home/det/test.log for logging
@@@ Restarting child "/bin/bash"
Created process 65033 on /dev/pts/1
@@@ The PID of new child "/bin/bash" is: 65033
@@@ @@@ @@@ @@@ @@@
Created new child connection (processClass 0x22dc290)
Adding connection 0x22dc290 to list
*************************************************************

So bind() returned 0, which is normal, and the procServ is running correctly.

This is the second time procServ is started:

*************************************************************
[det@ppu071 ~]$ /usr/local/bin/procServ -L /home/det/test.log 30000 /bin/bash
Setting up messages
Checking command file validity
Installing signal handlers
Creating control listener
Bind error: Address already in use
~connectionItem()
Caught an exception creating the initial control telnet port: Address already in use
/usr/local/bin/procServ: Exiting with error code: 98
[det@ppu071 ~]$
*************************************************************

This is what I expect.  bind() returns an error because there is already a process listening on that port.


This is what I observe on Centos6.

This is the first time procServ is started:

*************************************************************
det@dec1248:~> /usr/local/bin/procServ -L /home/det/test.log 30000 /bin/bash
Setting up messages
Checking command file validity
Installing signal handlers
Creating control listener
Bind returned 0
Listening on fd 3
Created new telnet listener (acceptItem 0x8d5260) on port 30000 (read/write)
Adding connection 0x8d5260 to list
Opened file /home/det/test.log for logging
@@@ Restarting child "/bin/bash"
Created process 107935 on /dev/pts/2
@@@ The PID of new child "/bin/bash" is: 107935
@@@ @@@ @@@ @@@ @@@
Created new child connection (processClass 0x8d5290)
Adding connection 0x8d5290 to list
*************************************************************

Again bind() returned 0 as expected.  procServ is running normally.

However, this is the second time I started procServ.

*************************************************************
det@dec1248:~> /usr/local/bin/procServ -L /home/det/test.log 30000 /bin/bash
Setting up messages
Checking command file validity
Installing signal handlers
Creating control listener
Bind returned 0
Listening on fd 3
Created new telnet listener (acceptItem 0x1e3d260) on port 30000 (read/write)
Adding connection 0x1e3d260 to list
Opened file /home/det/test.log for logging
@@@ Restarting child "/bin/bash"
Created process 107992 on /dev/pts/3
@@@ The PID of new child "/bin/bash" is: 107992
@@@ @@@ @@@ @@@ @@@
Created new child connection (processClass 0x1e3d290)
Adding connection 0x1e3d290 to list
*************************************************************

This is NOT what I expect.  bind() again returned 0, even though there is already a process listening on port 30000.

If I then telnet to localhost port 30000 I am connected to the second procServ process I created.  I then kill that procServ by exiting bash and typing ^Q.  I then telnet to port 30000 again.  This time I am connected to the first procServ I created.

Why is bind() not returning EADDRINUSE the second time it is called on the same port on Centos6?  Is there some socket option that allows multiple processes to bind to the same port?

Thanks,
Mark



________________________________
From: Mark Rivers
Sent: Thursday, July 14, 2016 12:48 PM
To: 'Ralph Lange'; [email protected]
Subject: Problem with procServ on RHEL6

Hi Ralph,

I have run into what seems to me a bug in procServ 2.6.0 when running on RHEL6/Centos6.  The problem occurs when trying to start another procServ process using the same telnet port as an existing procServ process.

This is what I observe when running on Fedora 15 (Linux version 2.6.43.8-1) or on Centos7 (Linux version 3.10.0-229)

[det@ppu071 linux-x86_64]$ /usr/local/bin/procServ -L /home/det/test.log 30000 /bin/bash
/usr/local/bin/procServ: spawning daemon process: 41899

[det@ppu071 linux-x86_64]$ /usr/local/bin/procServ -L /home/det/test.log 30000 /bin/bash
Caught an exception creating the initial control telnet port: Address already in use
/usr/local/bin/procServ: Exiting with error code: 98

I think this is the correct behavior. procServ should exit with an error if the telnet port is already in use.  This is a protection against accidentally starting the same procServ process twice.

However, on Centos6/RHEL6 (Linux version 2.6.32-431) I observe the following:

det@dec1248:~> /usr/local/bin/procServ -L /home/det/test.log 30000 /bin/bash
/usr/local/bin/procServ: spawning daemon process: 60423

det@dec1248:~> /usr/local/bin/procServ -L /home/det/test.log 30000 /bin/bash
/usr/local/bin/procServ: spawning daemon process: 60555

det@dec1248:~> /usr/local/bin/procServ -L /home/det/test.log 30000 /bin/bash
/usr/local/bin/procServ: spawning daemon process: 60610

So procServ happily creates multiple procServ processes listening on the same telnet port.  These are all running:

det@dec1248:~> ps ax | grep procServ
60423 ?        Ss     0:00 /usr/local/bin/procServ -L /home/det/test.log 30000 /bin/bash
60555 ?        Ss     0:00 /usr/local/bin/procServ -L /home/det/test.log 30000 /bin/bash
60610 ?        Ss     0:00 /usr/local/bin/procServ -L /home/det/test.log 30000 /bin/bash

This seems like a bug to me?  It is definitely inconvenient because if someone accidentally types the command to start a particular procServ without realizing that it is already running it can cause problems.

Is there something I can do to work around this issue?

Thanks,
Mark



Replies:
Re: Problem with procServ on RHEL6 Eric Norum
References:
Problem with procServ on RHEL6 Mark Rivers

Navigate by Date:
Prev: Problem with procServ on RHEL6 Mark Rivers
Next: Re: Problem with procServ on RHEL6 Eric Norum
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Problem with procServ on RHEL6 Mark Rivers
Next: Re: Problem with procServ on RHEL6 Eric Norum
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  <20162017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 15 Jul 2016 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·