aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-12-18 03:04:42 +0000
committerDavid Robillard <d@drobilla.net>2011-12-18 03:04:42 +0000
commit043ab189194dfdfbe0fb5b6926539a44db476a31 (patch)
tree6bba114a989144324a995d7df53cad75aad94738
parentc6b390189d75aa7742a863603e45f9981a2bf050 (diff)
downloadjalv-043ab189194dfdfbe0fb5b6926539a44db476a31.tar.gz
jalv-043ab189194dfdfbe0fb5b6926539a44db476a31.tar.bz2
jalv-043ab189194dfdfbe0fb5b6926539a44db476a31.zip
Use file locking on saves presets manifest.ttl.
git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@3883 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/jalv.c8
-rw-r--r--src/presets.c16
-rw-r--r--wscript5
3 files changed, 25 insertions, 4 deletions
diff --git a/src/jalv.c b/src/jalv.c
index e56c8eb..44b7aae 100644
--- a/src/jalv.c
+++ b/src/jalv.c
@@ -85,10 +85,10 @@ uri_to_id(LV2_URI_Map_Callback_Data callback_data,
static LV2_URI_Map_Feature uri_map = { NULL, &uri_to_id };
static const LV2_Feature uri_map_feature = { NS_EXT "uri-map", &uri_map };
-static LV2_URID_Map map = { NULL, &map_uri };
-static const LV2_Feature map_feature = { NS_EXT "urid#map", &map };
-static LV2_URID_Unmap unmap = { NULL, &unmap_uri };
-static const LV2_Feature unmap_feature = { NS_EXT "urid#unmap", &unmap };
+static LV2_URID_Map map = { NULL, &map_uri };
+static const LV2_Feature map_feature = { NS_EXT "urid#map", &map };
+static LV2_URID_Unmap unmap = { NULL, &unmap_uri };
+static const LV2_Feature unmap_feature = { NS_EXT "urid#unmap", &unmap };
static LV2_Feature instance_feature = { NS_EXT "instance-access", NULL };
#ifdef HAVE_LV2_UI_RESIZE
diff --git a/src/presets.c b/src/presets.c
index a7cd967..b396f56 100644
--- a/src/presets.c
+++ b/src/presets.c
@@ -14,6 +14,9 @@
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#define _POSIX_C_SOURCE 200112L /* for fileno */
+#define _BSD_SOURCE 1 /* for lockf */
+
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -23,6 +26,10 @@
#include "jalv-config.h"
#include "jalv_internal.h"
+#ifdef HAVE_LOCKF
+#include <unistd.h>
+#endif
+
#define NS_LV2 "http://lv2plug.in/ns/lv2core#"
#define NS_PSET "http://lv2plug.in/ns/ext/presets#"
#define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
@@ -274,6 +281,10 @@ jalv_save_preset(Jalv* jalv, const char* label)
goto done;
}
+#ifdef HAVE_LOCKF
+ lockf(fileno(fd), F_LOCK, 0);
+#endif
+
base = serd_node_new_uri_from_string((const uint8_t*)manifest_uri,
NULL, &base_uri);
@@ -308,6 +319,11 @@ jalv_save_preset(Jalv* jalv, const char* label)
serd_writer_free(writer);
serd_env_free(env);
serd_node_free(&base);
+
+#ifdef HAVE_LOCKF
+ lockf(fileno(fd), F_ULOCK, 0);
+#endif
+
fclose(fd);
done:
diff --git a/wscript b/wscript
index df9ef6f..a5cb6ea 100644
--- a/wscript
+++ b/wscript
@@ -60,6 +60,11 @@ def configure(conf):
autowaf.check_pkg(conf, 'lv2-lv2plug.in-ns-ext-ui-resize',
uselib_store='LV2_UI_RESIZE', mandatory=False)
+ conf.check(function_name='lockf',
+ header_name='unistd.h',
+ define_name='HAVE_LOCKF',
+ mandatory=False)
+
if not Options.options.no_jack_session:
autowaf.define(conf, 'JALV_JACK_SESSION', 1)