summaryrefslogtreecommitdiff
path: root/python/ovs/daemon.py
Commit message (Collapse)AuthorAgeFilesLines
* daemon.py: Silence return warning.Ethan Jackson2011-09-161-3/+5
| | | | | | | | | Pychecker complains about __read_pidfile() having too may returns. I personally think the function is fine, but it's easy enough to reduce them. python/ovs/daemon.py:395: Function (__read_pidfile) has too many returns (12)
* daemon.py: Don't shadow built-in 'file' variable.Ethan Jackson2011-09-161-12/+12
| | | | Pychecker considers it bad style.
* daemon.py: Whitespace cleanup.Ethan Jackson2011-09-161-5/+29
| | | | | The python style guide requires two newlines between top level definitions. This patch also removes some trailing whitespace.
* ovs.daemon: Add missing format string argument.Ben Pfaff2011-08-251-1/+1
| | | | Found by pychecker.
* ovs.daemon: Fix name of EALREADY error.Ben Pfaff2011-08-251-1/+1
| | | | Found by pychecker.
* ovs.daemon: Add missing 'global' when setting _pidfile_dev, _pidfile_ino.Ben Pfaff2011-08-251-0/+2
| | | | Found by pychecker.
* daemon: Stylistic improvement for __read_pidfile in Python implementation.Ben Pfaff2011-08-241-4/+4
| | | | Suggested-by: Reid Price <reid@nicira.com>
* daemon: Correct comment in Python implementation.Ben Pfaff2011-08-241-2/+1
| | | | Reported-by: Reid Price <reid@nicira.com>
* python: Use getattr() and setattr() instead of __dict__.Ben Pfaff2011-08-241-2/+1
| | | | | | | | | | | | | | | This leaves one use of __dict__ used for iterating through attributes. I could use dir() instead, but I was put off by this note in its documentation in the Python Library Reference: Because dir() is supplied primarily as a convenience for use at an interactive prompt, it tries to supply an interesting set of names more than it tries to supply a rigorously or consistently defined set of names, and its detailed behavior may change across releases. For example, metaclass attributes are not in the result list when the argument is a class. Suggested-by: Reid Price <reid@nicira.com>
* daemon: Avoid races on pidfile creation.Ben Pfaff2011-04-041-76/+107
| | | | | | | | | | | | | | | | | | Until now, if two copies of one OVS daemon started up at the same time, then due to races in pidfile creation it was possible for both of them to start successfully, instead of just one. This was made worse when a previous copy of the daemon had died abruptly, leaving a stale pidfile. This commit implements a new pidfile creation and removal protocol that I believe closes these races. Now, a pidfile is asserted with "link" instead of "rename", which prevents the race on creation, and a stale pidfile may only be deleted by a process after it has taken a lock on it. This may solve mysterious problems seen occasionally on vswitch restart. I'm still puzzled by these problems, however, because I don't see anything in our tests cases that would actually cause two copies of a daemon to start at the same time, which as far as I can see is a necessary precondition for the problem.
* daemon: Integrate checking for an existing pidfile into daemonize_start().Ben Pfaff2011-04-041-4/+5
| | | | | | | | | | | | Until now, it has been the responsibility of an individual daemon to call die_if_already_running() at an appropriate time. A long time ago, this had to happen *before* daemonizing, because once the process daemonized itself there was no way to report failure to the process that originally started the daemon. With the introduction of daemonize_start(), this is now possible, but we haven't been taking advantage of it. Therefore, this commit integrates the die_if_already_running() call into daemonize_start() and deletes the calls to it from individual daemons.
* daemon: Tolerate EINTR in fork_and_wait_for_startup().Ben Pfaff2011-04-041-4/+9
| | | | | It seems possible that a signal coming in at the wrong time could confuse this code. It's always best to loop on EINTR.
* daemon: Avoid redundant code in already_running().Ben Pfaff2011-03-291-30/+18
| | | | | This function substantially duplicated read_pidfile(), so reuse that code instead.
* daemon: Write "already running" message to log also.Ben Pfaff2011-03-291-2/+4
| | | | | Otherwise it's hard to diagnose later if the daemon failed to start because it thinks that it is already running.
* xenserver: monitor-external-ids should run with --monitorEthan Jackson2010-09-221-0/+7
| | | | | | | | The init script starts monitor-external-ids with --monitor when configured to do so. Also made changes to guarantee that --monitor actually restarts ovs-external-ids. Signed-off-by: Ethan Jackson <ethan@nicira.com>
* daemon: Fix behavior of read_pidfile() for our own pidfile.Ben Pfaff2010-09-231-1/+22
| | | | | | | | Opening a file descriptor and then closing it always discards any locks held on the underlying file, even if the file is still open as another file descriptor. This meant that calling read_pidfile() on the process's own pidfile would discard the lock and make other OVS processes think that the process had died. This commit fixes the problem.
* Implement initial Python bindings for Open vSwitch database.Ben Pfaff2010-08-251-0/+431
These initial bindings pass a few hundred of the corresponding tests for C implementations of various bits of the Open vSwitch library API. The poorest part of them is actually the Python IDL interface in ovs.db.idl, which has not received enough attention yet. It appears to work, but it doesn't yet support writes (transactions) and it is difficult to use. I hope to improve it as it becomes clear what semantics Python applications actually want from an IDL.