9 #include <sys/socket.h>
25 namespace loader_talk {
32 bool Init(
const string &socket_path) {
44 unlink((socket_path +
".paused.crashed").c_str());
45 unlink((socket_path +
".paused").c_str());
52 struct sockaddr_un remote;
53 socklen_t socket_size =
sizeof(remote);
57 shutdown(con_fd, SHUT_RDWR);
60 if ((con_fd = accept(
socket_fd_, (
struct sockaddr *)&remote, &socket_size))
68 if (recv(con_fd, &command, 1, 0) > 0) {
69 if ((command ==
'd') || (command ==
'n')) {
75 if (recv(con_fd, &command, 1, 0) > 0) {
76 if ((command !=
'R') && (command !=
'S')) {
81 }
else if ((command !=
'R') && (command !=
'S')) {
89 int retval =
Reload(con_fd, command ==
'S', reload_mode);
91 (void)send(con_fd, &retval,
sizeof(retval),
MSG_NOSIGNAL);
128 int MainReload(
const std::string &socket_path,
const bool stop_and_go,
131 "Connecting to CernVM-FS loader... ");
141 commands[0] = debug ?
'd' :
'n';
142 commands[1] = stop_and_go ?
'S' :
'R';
151 }
while ((retval <= 0) && (errno == EINTR));
159 std::string first_line;
160 bool past_first_line =
false;
161 while ((retval = read(socket_fd, &buf, 1)) == 1) {
165 if (first_line ==
"unknown command") {
168 "Connecting in backwards compatibility mode");
177 past_first_line =
true;
183 if (!past_first_line) {
186 past_first_line =
true;
188 first_line.push_back(buf);
197 "CernVM-FS mountpoints unusable.");
202 if (read(socket_fd, &result,
sizeof(result)) < 0) {
204 "CernVM-FS mountpoints unusable.");
208 "CernVM-FS mountpoints unusable.");
const char * Code2Ascii(const ObjectFetcherFailures::Failures error)
static void * MainTalk(void *data __attribute__((unused)))
int MakeSocket(const std::string &path, const int mode)
Failures Reload(const int fd_progress, const bool stop_and_go, const ReloadMode reload_mode)
void SendMsg2Socket(const int fd, const std::string &msg)
assert((mem||(size==0))&&"Out Of Memory")
void SetLogMicroSyslog(const std::string &filename)
struct cvmcache_object_info __attribute__
static int Init(const loader::LoaderExports *loader_exports)
int MainReload(const std::string &socket_path, const bool stop_and_go, const bool debug)
int ConnectSocket(const std::string &path)
void WritePipe(int fd, const void *buf, size_t nbyte)
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)