Commit 4575a9f9 by Serge Hallyn

Revert "api_create and api_start: work toward making them thread-safe"

This should deadlock with daemonized start due to af_unix changes. Do this later, but do it more carefully. This reverts commit 002f3cff.
parent 002f3cff
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include <sys/un.h> #include <sys/un.h>
#include "log.h" #include "log.h"
#include "lxclock.h"
lxc_log_define(lxc_af_unix, lxc); lxc_log_define(lxc_af_unix, lxc);
...@@ -101,9 +100,7 @@ int lxc_af_unix_connect(const char *path) ...@@ -101,9 +100,7 @@ int lxc_af_unix_connect(const char *path)
int fd; int fd;
struct sockaddr_un addr; struct sockaddr_un addr;
process_lock();
fd = socket(PF_UNIX, SOCK_STREAM, 0); fd = socket(PF_UNIX, SOCK_STREAM, 0);
process_unlock();
if (fd < 0) if (fd < 0)
return -1; return -1;
...@@ -116,9 +113,7 @@ int lxc_af_unix_connect(const char *path) ...@@ -116,9 +113,7 @@ int lxc_af_unix_connect(const char *path)
if (connect(fd, (struct sockaddr *)&addr, sizeof(addr))) { if (connect(fd, (struct sockaddr *)&addr, sizeof(addr))) {
int tmp = errno; int tmp = errno;
process_lock();
close(fd); close(fd);
process_unlock();
errno = tmp; errno = tmp;
return -1; return -1;
} }
......
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
#include "mainloop.h" #include "mainloop.h"
#include "af_unix.h" #include "af_unix.h"
#include "config.h" #include "config.h"
#include "lxclock.h"
/* /*
* This file provides the different functions for clients to * This file provides the different functions for clients to
...@@ -283,11 +282,8 @@ static int lxc_cmd(const char *name, struct lxc_cmd_rr *cmd, int *stopped, ...@@ -283,11 +282,8 @@ static int lxc_cmd(const char *name, struct lxc_cmd_rr *cmd, int *stopped,
ret = lxc_cmd_rsp_recv(sock, cmd); ret = lxc_cmd_rsp_recv(sock, cmd);
out: out:
if (!stay_connected || ret <= 0) { if (!stay_connected || ret <= 0)
process_lock();
close(sock); close(sock);
process_unlock();
}
if (stay_connected && ret > 0) if (stay_connected && ret > 0)
cmd->rsp.ret = sock; cmd->rsp.ret = sock;
......
...@@ -665,9 +665,7 @@ static bool create_container_dir(struct lxc_container *c) ...@@ -665,9 +665,7 @@ static bool create_container_dir(struct lxc_container *c)
free(s); free(s);
return false; return false;
} }
process_lock();
ret = mkdir(s, 0755); ret = mkdir(s, 0755);
process_unlock();
if (ret) { if (ret) {
if (errno == EEXIST) if (errno == EEXIST)
ret = 0; ret = 0;
...@@ -1364,15 +1362,11 @@ static bool lxcapi_save_config(struct lxc_container *c, const char *alt_file) ...@@ -1364,15 +1362,11 @@ static bool lxcapi_save_config(struct lxc_container *c, const char *alt_file)
if (lret) if (lret)
return false; return false;
process_lock();
fout = fopen(alt_file, "w"); fout = fopen(alt_file, "w");
process_unlock();
if (!fout) if (!fout)
goto out; goto out;
write_config(fout, c->lxc_conf); write_config(fout, c->lxc_conf);
process_lock();
fclose(fout); fclose(fout);
process_unlock();
ret = true; ret = true;
out: out:
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
#include "parse.h" #include "parse.h"
#include "config.h" #include "config.h"
#include "utils.h" #include "utils.h"
#include "lxclock.h"
#include <lxc/log.h> #include <lxc/log.h>
/* Workaround for the broken signature of alphasort() in bionic. /* Workaround for the broken signature of alphasort() in bionic.
...@@ -91,9 +90,7 @@ int lxc_file_for_each_line(const char *file, lxc_file_cb callback, void *data) ...@@ -91,9 +90,7 @@ int lxc_file_for_each_line(const char *file, lxc_file_cb callback, void *data)
char *line = NULL; char *line = NULL;
size_t len = 0; size_t len = 0;
process_lock();
f = fopen(file, "r"); f = fopen(file, "r");
process_unlock();
if (!f) { if (!f) {
SYSERROR("failed to open %s", file); SYSERROR("failed to open %s", file);
return -1; return -1;
...@@ -107,9 +104,7 @@ int lxc_file_for_each_line(const char *file, lxc_file_cb callback, void *data) ...@@ -107,9 +104,7 @@ int lxc_file_for_each_line(const char *file, lxc_file_cb callback, void *data)
if (line) if (line)
free(line); free(line);
process_lock();
fclose(f); fclose(f);
process_unlock();
return err; return err;
} }
......
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
#include "utils.h" #include "utils.h"
#include "log.h" #include "log.h"
#include "lxclock.h"
lxc_log_define(lxc_utils, lxc); lxc_log_define(lxc_utils, lxc);
...@@ -410,10 +409,7 @@ int sha1sum_file(char *fnam, unsigned char *digest) ...@@ -410,10 +409,7 @@ int sha1sum_file(char *fnam, unsigned char *digest)
if (!fnam) if (!fnam)
return -1; return -1;
process_lock(); if ((f = fopen_cloexec(fnam, "r")) < 0) {
f = fopen_cloexec(fnam, "r");
process_unlock();
if (f < 0) {
SYSERROR("Error opening template"); SYSERROR("Error opening template");
return -1; return -1;
} }
...@@ -443,10 +439,7 @@ int sha1sum_file(char *fnam, unsigned char *digest) ...@@ -443,10 +439,7 @@ int sha1sum_file(char *fnam, unsigned char *digest)
fclose(f); fclose(f);
return -1; return -1;
} }
process_lock(); if (fclose(f) < 0) {
ret = fclose(f);
process_unlock();
if (ret < 0) {
SYSERROR("Failre closing template"); SYSERROR("Failre closing template");
free(buf); free(buf);
return -1; return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment