summaryrefslogtreecommitdiff
path: root/lib/lockfile.c
Commit message (Collapse)AuthorAgeFilesLines
* lockfile: Support \-delimited file names in lockfile_name().Alin Serdean2015-03-311-0/+8
| | | | | | | | | | | | | | | | | | | | | | | Currently paths that have only forward slashes like the following "C:/package/binaries/conf.db" work seamlessly. If we try the native windows filepaths i.e. "C:\package\binaries\conf.db" we will hit the following problem: 2015-03-31T15:54:17Z|00001|lockfile|WARN|.c:\package\binaries\conf.db.~lock~: failed to open lock file: Invalid argument 2015-03-31T15:54:17Z|00002|lockfile|WARN|.c:\package\binaries\conf.db.~lock~: failed to lock file: Invalid argument ovsdb-server: I/O error: c:\package\binaries\conf.db: failed to lock lockfile (Invalid argument) In this patch we update the lockfile_name function to also look for backslashes, and also accommodate if we have a mix of backslashes and forward slashes. Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> [blp@nicira.com simplified the code] Signed-off-by: Ben Pfaff <blp@nicira.com>
* lib: Move vlog.h to <openvswitch/vlog.h>Thomas Graf2014-12-151-1/+1
| | | | | | | | A new function vlog_insert_module() is introduced to avoid using list_insert() from the vlog.h header. Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Ben Pfaff <blp@nicira.com>
* lockfile: Modify tests for Windows.Gurucharan Shetty2014-06-241-2/+3
| | | | | | | | | | | | | | | | | As of now, when a process tries to reacquire a lockfile, we return EEXIST on Windows and print a different error message. This means that the unit tests need to look for different error messages too. Linux uses EDEADLK for the same. EDEADLK feels like a good error description for Windows too and this also lets us not change the tests too much. So use it. Some of the tests in test-lockfile.c uses fork to test a child's ability to acquire lock. We do not fork in Windows. We also do not support symlinks on Windows. So, comment out those tests. Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* lockfile: Improve log message when a process tries to relock a file.Ben Pfaff2014-04-071-1/+5
| | | | | | | "Resource deadlock avoided" is a pretty obscure message. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Alex Wang <alexw@nicira.com>
* lockfile: Minor code cleanup.Ben Pfaff2014-03-251-26/+17
| | | | | | | | There were more superficial differences between Windows and non-Windows versions of the code due to naming. This commit reduces those differences. CC: Gurucharan Shetty <shettyg@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* util: Pre-allocate buffer for ovs_lasterror_to_string().Gurucharan Shetty2014-02-141-3/+1
| | | | | | | | This lets us call ovs_lasterror_to_string() and not having to do an extra call of LocalFree() on the returned string. Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* lockfile: Implementation for Windows platform.Gurucharan Shetty2014-02-131-5/+90
| | | | | | | | Start with a simple implementation that does not support symbolic links. Signed-off-by: Gurucharan Shetty <gshetty@nicira.com> Acked-by: Ben Pfaff <blp@nicira.com>
* Remove unused variables and functions.Jarno Rajahalme2013-09-271-1/+0
| | | | | | | | Found by Clang. Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* clang: Add annotations for thread safety check.Ethan Jackson2013-07-301-14/+18
| | | | | | | | | | This commit adds annotations for thread safety check. And the check can be conducted by using -Wthread-safety flag in clang. Co-authored-by: Alex Wang <alexw@nicira.com> Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ethan Jackson <ethan@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* lockfile: Make thread-safe.Ben Pfaff2013-07-221-1/+10
| | | | Signed-off-by: Ben Pfaff <blp@nicira.com>
* Replace all uses of strerror() by ovs_strerror(), for thread safety.Ben Pfaff2013-06-281-5/+6
| | | | Signed-off-by: Ben Pfaff <blp@nicira.com>
* lockfile: Remove calls to time_disable_restart()/time_enable_restart().Ben Pfaff2013-06-051-2/+0
| | | | | | | These calls are not necessary because F_SETLK does not block. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* lockfile: Log more helpful message when locking fails due to a conflict.Ben Pfaff2012-08-311-5/+16
| | | | | | Reported-by: rahim entezari <rahim.entezari@gmail.com> Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* lockfile: Remove lockfile_lock timeout argumentLeo Alterman2012-08-091-35/+11
| | | | | | | | | lockfile_lock() accepts a timeout argument but, aside from unit tests pertaining to timeout, its value is always 0. Since this feature relies on a periodic SIGALRM signal, which is not a given if we're not caching time, the cleanest solution is just to remove it. Signed-off-by: Leo Alterman <lalterman@nicira.com>
* lockfile: Be more forgiving about lockfiles for symlinks.Ben Pfaff2012-08-011-8/+21
| | | | | | | | | | As the database is being transitioned from /etc to /var, there is a symlink from the old to the new location for the database and a symlink for its lockfile. This works OK, but it would be more user-friendly to still work correctly in case the symlink for the lockfile isn't there (since its existence is non-obvious), so this commit implements that behavior. Signed-off-by: Ben Pfaff <blp@nicira.com>
* lockfile: Fix hang locking through a dangling symlink.Ben Pfaff2012-08-011-34/+16
| | | | | | | | | | | | | | | | | open() with O_CREAT|O_EXCL yields EEXIST if the file being opened is a symlink. lockfile_try_lock() interpreted that error code to mean that some other process had created the lock file in the meantime, so it went around its loop again, which found out the same thing, which led to a hang. This commit fixes the problem by dropping O_EXCL. I don't see any reason that it's actually necessary. That means that the loop itself is unnecessary, so this commit drops that too. Debian bug #681880. CC: 681880@bugs.debian.org Reported-by: Bastian Blank <waldi@debian.org> Signed-off-by: Ben Pfaff <blp@nicira.com> Reviewed-by: Simon Horman <horms@verge.net.au>
* Global replace of Nicira Networks.Raju Subramanian2012-05-021-1/+1
| | | | | | | | Replaced all instances of Nicira Networks(, Inc) to Nicira, Inc. Feature #10593 Signed-off-by: Raju Subramanian <rsubramanian@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* lockfile: Don't warn if successful lock takes a little time.Ben Pfaff2011-05-131-8/+3
| | | | | | | | | | | | | This code issues a warning if obtaining a lock takes even 1 millisecond. That's far too aggressive. There's no need to warn if we have to wait a few milliseconds. This function already warns elsewhere if locking takes more than 1 second, which is much more reasonable. This change allows us to test ovsdb-server stderr output more carefully. Before now, the tests had to ignore what ovsdb-server writes to stderr because sometimes it would log a warning that locking took 1 ms (or so). Reviewed-by: Simon Horman <horms@verge.net.au>
* coverage: Make the coverage counters catalog program-specific.Ben Pfaff2010-11-301-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Until now, the collection of coverage counters supported by a given OVS program was not specific to that program. That means that, for example, even though ovs-dpctl does not have anything to do with mac_learning, it still has a coverage counter for it. This is confusing, at best. This commit fixes the problem on some systems, in particular on ones that use GCC and the GNU linker. It uses the feature of the GNU linker described in its manual as: If an orphaned section's name is representable as a C identifier then the linker will automatically see PROVIDE two symbols: __start_SECNAME and __end_SECNAME, where SECNAME is the name of the section. These indicate the start address and end address of the orphaned section respectively. Systems that don't support these features retain the earlier behavior. This commit also fixes the annoyance that files that include coverage counters must be listed on COVERAGE_FILES in lib/automake.mk. This commit also fixes the annoyance that modifying any source file that includes a coverage counter caused all programs that link against libopenvswitch.a to relink, even programs that the source file was not linked into. For example, modifying ofproto/ofproto.c (which includes coverage counters) caused tests/test-aes128 to relink, even though test-aes128 does not link again ofproto.o.
* vlog: Make client supply semicolon for VLOG_DEFINE_THIS_MODULE.Ben Pfaff2010-10-291-1/+1
| | | | | It's kind of odd for VLOG_DEFINE_THIS_MODULE to supply its own semicolon, so this commit switches to the more common form.
* Switch many macros from using CONTAINER_OF to using OBJECT_CONTAINING.Ben Pfaff2010-10-011-2/+2
| | | | | These macros require one fewer argument by switching, which makes code that uses them shorter and more readable.
* vlog: Introduce VLOG_DEFINE_THIS_MODULE for declaring vlog module in use.Ben Pfaff2010-07-211-2/+2
| | | | | | | Adding a macro to define the vlog module in use adds a level of indirection, which makes it easier to change how the vlog module must be defined. A followup commit needs to do that, so getting these widespread changes out of the way first should make that commit easier to review.
* lockfile: Occasionally log a warning when waiting for a lockfile.Ben Pfaff2010-03-081-1/+7
| | | | | | | | Waiting for a lockfile can cause mysterious pauses for users. Logging a warning to the console every so often gives them feedback on what is happening. Reported-by: Justin Pettit <jpettit@nicira.com>
* Merge "master" branch into "db".Ben Pfaff2009-12-021-2/+2
|
* Implement library for lockfiles and use it in cfg code.Ben Pfaff2009-10-291-0/+280
This is useful because the upcoming configuration database also needs a lockfile implementation. Also adds tests.