#include "config.h"
#ifdef FEATURE_COOKIE
+#include <fcntl.h>
+#include <sys/file.h>
#include "main.h"
#include "cookiejar.h"
static void cookiejar_changed(SoupCookieJar *self, SoupCookie *old_cookie, SoupCookie *new_cookie)
{
- FLOCK(COOKIEJAR(self)->lock, F_WRLCK);
+ flock(COOKIEJAR(self)->lock, LOCK_EX);
SoupDate *expire;
if (new_cookie) {
/* session-expire-time handling */
}
}
SOUP_COOKIE_JAR_CLASS(cookiejar_parent_class)->changed(self, old_cookie, new_cookie);
- FLOCK(COOKIEJAR(self)->lock, F_UNLCK);
+ flock(COOKIEJAR(self)->lock, LOCK_UN);
}
static void cookiejar_class_init(CookieJarClass *klass)
static void cookiejar_set_property(GObject *self, guint prop_id, const
GValue *value, GParamSpec *pspec)
{
- FLOCK(COOKIEJAR(self)->lock, F_RDLCK);
+ flock(COOKIEJAR(self)->lock, LOCK_SH);
G_OBJECT_CLASS(cookiejar_parent_class)->set_property(self, prop_id, value, pspec);
- FLOCK(COOKIEJAR(self)->lock, F_UNLCK);
+ flock(COOKIEJAR(self)->lock, LOCK_UN);
}
#endif
*/
#include "config.h"
+#include <fcntl.h>
+#include <sys/file.h>
#include "main.h"
#include "history.h"
#include "util.h"
{
FILE *f;
if ((f = fopen(file, "w"))) {
- FLOCK(fileno(f), F_WRLCK);
+ flock(fileno(f), LOCK_EX);
/* overwrite the history file with new unique history items */
for (GList *link = list; link; link = link->next) {
}
}
- FLOCK(fileno(f), F_UNLCK);
+ flock(fileno(f), LOCK_UN);
fclose(f);
}
}
#include "hsts.h"
#include "util.h"
#include "main.h"
+#include <fcntl.h>
+#include <sys/file.h>
#include <string.h>
#include <glib-object.h>
#include <libsoup/soup.h>
HSTSProviderPrivate *priv = HSTS_PROVIDER_GET_PRIVATE(provider);
if ((f = fopen(file, "w"))) {
- FLOCK(fileno(f), F_WRLCK);
+ flock(fileno(f), LOCK_EX);
g_hash_table_iter_init(&iter, priv->whitelist);
while (g_hash_table_iter_next (&iter, (gpointer)&host, (gpointer)&entry)) {
g_free(date);
}
- FLOCK(fileno(f), F_UNLCK);
+ flock(fileno(f), LOCK_UN);
fclose(f);
}
}
#define LENGTH(x) (sizeof x / sizeof x[0])
-#define FLOCK(fd, cmd) { \
- struct flock lock = {.l_type=cmd,.l_start=0,.l_whence=SEEK_SET,.l_len=0}; \
- fcntl(fd, F_SETLKW, &lock); \
-}
#ifdef DEBUG
#define PRINT_DEBUG(...) { \
*/
#include "config.h"
+#include <fcntl.h>
+#include <sys/file.h>
#include <stdio.h>
#include <pwd.h>
#include <ctype.h>
FILE *f;
if ((f = fopen(file, "a+"))) {
- FLOCK(fileno(f), F_WRLCK);
+ flock(fileno(f), LOCK_EX);
va_start(args, format);
vfprintf(f, format, args);
va_end(args);
- FLOCK(fileno(f), F_UNLCK);
+ flock(fileno(f), LOCK_UN);
fclose(f);
return true;
content = util_get_file_contents(file, NULL);
if ((f = fopen(file, "w"))) {
- FLOCK(fileno(f), F_WRLCK);
+ flock(fileno(f), LOCK_EX);
va_start(args, format);
/* write new content to the file */
/* append previous file content */
fputs(content, f);
- FLOCK(fileno(f), F_UNLCK);
+ flock(fileno(f), LOCK_UN);
fclose(f);
res = true;