Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit f704fe9

Browse files
committed
Remove pid/lock code and associated syscalls
1 parent 18aee9e commit f704fe9

File tree

4 files changed

+0
-76
lines changed

4 files changed

+0
-76
lines changed

omniscidb/OSDependent/Unix/omnisci_fs.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,6 @@ int get_page_size() {
2828
return getpagesize();
2929
}
3030

31-
size_t file_size(const int fd) {
32-
struct stat buf;
33-
int err = fstat(fd, &buf);
34-
CHECK_EQ(0, err);
35-
return buf.st_size;
36-
}
37-
38-
int open(const char* path, int flags, int mode) {
39-
return ::open(path, flags, mode);
40-
}
41-
42-
void close(const int fd) {
43-
::close(fd);
44-
}
45-
4631
::FILE* popen(const char* command, const char* type) {
4732
return ::popen(command, type);
4833
}
@@ -51,8 +36,4 @@ int32_t pclose(::FILE* fh) {
5136
return ::pclose(fh);
5237
}
5338

54-
int32_t ftruncate(const int32_t fd, int64_t length) {
55-
return ::ftruncate(fd, length);
56-
}
57-
5839
} // namespace omnisci

omniscidb/OSDependent/Windows/omnisci_fs.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,6 @@
3030

3131
namespace omnisci {
3232

33-
size_t file_size(const int fd) {
34-
struct _stat64i32 buf;
35-
const auto err = _fstat64i32(fd, &buf);
36-
CHECK_EQ(0, err);
37-
return buf.st_size;
38-
}
39-
40-
int open(const char* path, int flags, int mode) {
41-
return _open(path, flags, mode);
42-
}
43-
44-
void close(const int fd) {
45-
_close(fd);
46-
}
47-
4833
::FILE* popen(const char* command, const char* type) {
4934
return _popen(command, type);
5035
}
@@ -57,7 +42,4 @@ int get_page_size() {
5742
return 4096; // TODO: reasonable guess for now
5843
}
5944

60-
int32_t ftruncate(const int32_t fd, int64_t length) {
61-
return _chsize_s(fd, length);
62-
}
6345
} // namespace omnisci

omniscidb/OSDependent/omnisci_fs.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,10 @@
2222

2323
namespace omnisci {
2424

25-
size_t file_size(const int fd);
26-
27-
int open(const char* path, int flags, int mode);
28-
29-
void close(const int fd);
30-
3125
::FILE* popen(const char* command, const char* type);
3226

3327
int32_t pclose(::FILE* fh);
3428

3529
int get_page_size();
3630

37-
int32_t ftruncate(const int32_t fd, int64_t length);
3831
} // namespace omnisci

omniscidb/Utils/CommandLineOptions.cpp

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -315,38 +315,6 @@ void CommandLineOptions::validate() {
315315
"'");
316316
}
317317

318-
{
319-
const auto lock_file = boost::filesystem::path(base_path) / "omnisci_server_pid.lck";
320-
auto pid = std::to_string(getpid());
321-
322-
int pid_fd = omnisci::open(lock_file.string().c_str(), O_RDWR | O_CREAT, 0644);
323-
if (pid_fd == -1) {
324-
auto err = std::string("Failed to open PID file ") + lock_file.string().c_str() +
325-
". " + strerror(errno) + ".";
326-
throw std::runtime_error(err);
327-
}
328-
// TODO: support lock on Windows
329-
#ifndef _WIN32
330-
if (lockf(pid_fd, F_TLOCK, 0) == -1) {
331-
omnisci::close(pid_fd);
332-
auto err = std::string("Another OmniSci Server is using data directory ") +
333-
base_path + ".";
334-
throw std::runtime_error(err);
335-
}
336-
#endif
337-
if (omnisci::ftruncate(pid_fd, 0) == -1) {
338-
omnisci::close(pid_fd);
339-
auto err = std::string("Failed to truncate PID file ") +
340-
lock_file.string().c_str() + ". " + strerror(errno) + ".";
341-
throw std::runtime_error(err);
342-
}
343-
if (write(pid_fd, pid.c_str(), pid.length()) == -1) {
344-
omnisci::close(pid_fd);
345-
auto err = std::string("Failed to write PID file ") + lock_file.string().c_str() +
346-
". " + strerror(errno) + ".";
347-
throw std::runtime_error(err);
348-
}
349-
}
350318
boost::algorithm::trim_if(db_query_file, boost::is_any_of("\"'"));
351319
if (db_query_file.length() > 0 && !boost::filesystem::exists(db_query_file)) {
352320
throw std::runtime_error("File containing DB queries " + db_query_file +

0 commit comments

Comments
 (0)