Merge branch 'master' into fix_out_of_files_in_encoding
This commit is contained in:
commit
797a4adf70
|
@ -124,7 +124,7 @@ Monitor::MonitorLink::MonitorLink(unsigned int p_id, const char *p_name) :
|
|||
|
||||
#if ZM_MEM_MAPPED
|
||||
map_fd = -1;
|
||||
snprintf(mem_file, sizeof(mem_file), "%s/zm.mmap.%u", staticConfig.PATH_MAP.c_str(), id);
|
||||
mem_file = stringtf("%s/zm.mmap.%u", staticConfig.PATH_MAP.c_str(), id);
|
||||
#else // ZM_MEM_MAPPED
|
||||
shm_id = 0;
|
||||
#endif // ZM_MEM_MAPPED
|
||||
|
@ -150,9 +150,9 @@ bool Monitor::MonitorLink::connect() {
|
|||
|
||||
Debug(1, "link.mem.size=%jd", mem_size);
|
||||
#if ZM_MEM_MAPPED
|
||||
map_fd = open(mem_file, O_RDWR, (mode_t)0600);
|
||||
map_fd = open(mem_file.c_str(), O_RDWR, (mode_t)0600);
|
||||
if ( map_fd < 0 ) {
|
||||
Debug(3, "Can't open linked memory map file %s: %s", mem_file, strerror(errno));
|
||||
Debug(3, "Can't open linked memory map file %s: %s", mem_file.c_str(), strerror(errno));
|
||||
disconnect();
|
||||
return false;
|
||||
}
|
||||
|
@ -165,13 +165,13 @@ bool Monitor::MonitorLink::connect() {
|
|||
|
||||
struct stat map_stat;
|
||||
if ( fstat(map_fd, &map_stat) < 0 ) {
|
||||
Error("Can't stat linked memory map file %s: %s", mem_file, strerror(errno));
|
||||
Error("Can't stat linked memory map file %s: %s", mem_file.c_str(), strerror(errno));
|
||||
disconnect();
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( map_stat.st_size == 0 ) {
|
||||
Error("Linked memory map file %s is empty: %s", mem_file, strerror(errno));
|
||||
Error("Linked memory map file %s is empty: %s", mem_file.c_str(), strerror(errno));
|
||||
disconnect();
|
||||
return false;
|
||||
} else if ( map_stat.st_size < mem_size ) {
|
||||
|
@ -182,7 +182,7 @@ bool Monitor::MonitorLink::connect() {
|
|||
|
||||
mem_ptr = (unsigned char *)mmap(nullptr, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, map_fd, 0);
|
||||
if ( mem_ptr == MAP_FAILED ) {
|
||||
Error("Can't map file %s (%jd bytes) to memory: %s", mem_file, mem_size, strerror(errno));
|
||||
Error("Can't map file %s (%jd bytes) to memory: %s", mem_file.c_str(), mem_size, strerror(errno));
|
||||
disconnect();
|
||||
return false;
|
||||
}
|
||||
|
@ -905,23 +905,23 @@ bool Monitor::connect() {
|
|||
}
|
||||
Debug(3, "Connecting to monitor. Purpose is %d", purpose);
|
||||
#if ZM_MEM_MAPPED
|
||||
snprintf(mem_file, sizeof(mem_file), "%s/zm.mmap.%u", staticConfig.PATH_MAP.c_str(), id);
|
||||
mem_file = stringtf("%s/zm.mmap.%u", staticConfig.PATH_MAP.c_str(), id);
|
||||
if (purpose != CAPTURE) {
|
||||
map_fd = open(mem_file, O_RDWR);
|
||||
map_fd = open(mem_file.c_str(), O_RDWR);
|
||||
} else {
|
||||
map_fd = open(mem_file, O_RDWR|O_CREAT, (mode_t)0660);
|
||||
map_fd = open(mem_file.c_str(), O_RDWR|O_CREAT, (mode_t)0660);
|
||||
}
|
||||
|
||||
if (map_fd < 0) {
|
||||
Error("Can't open memory map file %s: %s", mem_file, strerror(errno));
|
||||
Error("Can't open memory map file %s: %s", mem_file.c_str(), strerror(errno));
|
||||
return false;
|
||||
} else {
|
||||
Debug(3, "Success opening mmap file at (%s)", mem_file);
|
||||
Debug(3, "Success opening mmap file at (%s)", mem_file.c_str());
|
||||
}
|
||||
|
||||
struct stat map_stat;
|
||||
if (fstat(map_fd, &map_stat) < 0) {
|
||||
Error("Can't stat memory map file %s: %s, is the zmc process for this monitor running?", mem_file, strerror(errno));
|
||||
Error("Can't stat memory map file %s: %s, is the zmc process for this monitor running?", mem_file.c_str(), strerror(errno));
|
||||
close(map_fd);
|
||||
map_fd = -1;
|
||||
return false;
|
||||
|
@ -931,7 +931,7 @@ bool Monitor::connect() {
|
|||
if (purpose == CAPTURE) {
|
||||
// Allocate the size
|
||||
if (ftruncate(map_fd, mem_size) < 0) {
|
||||
Error("Can't extend memory map file %s to %jd bytes: %s", mem_file, mem_size, strerror(errno));
|
||||
Error("Can't extend memory map file %s to %jd bytes: %s", mem_file.c_str(), mem_size, strerror(errno));
|
||||
close(map_fd);
|
||||
map_fd = -1;
|
||||
return false;
|
||||
|
@ -954,18 +954,18 @@ bool Monitor::connect() {
|
|||
mem_ptr = (unsigned char *)mmap(nullptr, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_LOCKED, map_fd, 0);
|
||||
if (mem_ptr == MAP_FAILED) {
|
||||
if (errno == EAGAIN) {
|
||||
Debug(1, "Unable to map file %s (%jd bytes) to locked memory, trying unlocked", mem_file, mem_size);
|
||||
Debug(1, "Unable to map file %s (%jd bytes) to locked memory, trying unlocked", mem_file.c_str(), mem_size);
|
||||
#endif
|
||||
mem_ptr = (unsigned char *)mmap(nullptr, mem_size, PROT_READ|PROT_WRITE, MAP_SHARED, map_fd, 0);
|
||||
Debug(1, "Mapped file %s (%jd bytes) to unlocked memory", mem_file, mem_size);
|
||||
Debug(1, "Mapped file %s (%jd bytes) to unlocked memory", mem_file.c_str(), mem_size);
|
||||
#ifdef MAP_LOCKED
|
||||
} else {
|
||||
Error("Unable to map file %s (%jd bytes) to locked memory (%s)", mem_file, mem_size, strerror(errno));
|
||||
Error("Unable to map file %s (%jd bytes) to locked memory (%s)", mem_file.c_str(), mem_size, strerror(errno));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if ((mem_ptr == MAP_FAILED) or (mem_ptr == nullptr)) {
|
||||
Error("Can't map file %s (%jd bytes) to memory: %s(%d)", mem_file, mem_size, strerror(errno), errno);
|
||||
Error("Can't map file %s (%jd bytes) to memory: %s(%d)", mem_file.c_str(), mem_size, strerror(errno), errno);
|
||||
close(map_fd);
|
||||
map_fd = -1;
|
||||
mem_ptr = nullptr;
|
||||
|
@ -1072,8 +1072,8 @@ bool Monitor::disconnect() {
|
|||
mem_ptr = nullptr;
|
||||
shared_data = nullptr;
|
||||
|
||||
if (purpose == CAPTURE and (unlink(mem_file) < 0) ) {
|
||||
Warning("Can't unlink '%s': %s", mem_file, strerror(errno));
|
||||
if (purpose == CAPTURE and (unlink(mem_file.c_str()) < 0) ) {
|
||||
Warning("Can't unlink '%s': %s", mem_file.c_str(), strerror(errno));
|
||||
}
|
||||
#else // ZM_MEM_MAPPED
|
||||
struct shmid_ds shm_data;
|
||||
|
|
|
@ -211,7 +211,7 @@ protected:
|
|||
|
||||
#if ZM_MEM_MAPPED
|
||||
int map_fd;
|
||||
char mem_file[PATH_MAX];
|
||||
std::string mem_file;
|
||||
#else // ZM_MEM_MAPPED
|
||||
int shm_id;
|
||||
#endif // ZM_MEM_MAPPED
|
||||
|
@ -364,7 +364,7 @@ protected:
|
|||
|
||||
#if ZM_MEM_MAPPED
|
||||
int map_fd;
|
||||
char mem_file[PATH_MAX];
|
||||
std::string mem_file;
|
||||
#else // ZM_MEM_MAPPED
|
||||
int shm_id;
|
||||
#endif // ZM_MEM_MAPPED
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <condition_variable>
|
||||
#include <list>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
|
||||
class ZMPacket;
|
||||
class ZMLockedPacket;
|
||||
|
|
|
@ -936,7 +936,8 @@ function initPage() {
|
|||
editBtn.prop('disabled', !canEdit.Events);
|
||||
exportBtn.prop('disabled', !canView.Events);
|
||||
downloadBtn.prop('disabled', !canView.Events);
|
||||
deleteBtn.prop('disabled', !canEdit.Events);
|
||||
deleteBtn.prop('disabled', !(!eventData.Archived && canEdit.Events));
|
||||
deleteBtn.prop('title', eventData.Archived ? "You cannot delete an archived event." : "");
|
||||
|
||||
// Don't enable the back button if there is no previous zm page to go back to
|
||||
backBtn.prop('disabled', !document.referrer.length);
|
||||
|
@ -979,14 +980,14 @@ function initPage() {
|
|||
|
||||
// Manage the UNARCHIVE button
|
||||
bindButton('#unarchiveBtn', 'click', null, function onUnarchiveClick(evt) {
|
||||
if ( ! canEdit.Events ) {
|
||||
if (!canEdit.Events) {
|
||||
enoperm();
|
||||
return;
|
||||
}
|
||||
evt.preventDefault();
|
||||
$j.getJSON(thisUrl + '?request=events&task=unarchive&eids[]='+eventData.Id)
|
||||
.done( function(data) {
|
||||
//FIXME: update the status of the unarchive button reather than reload the whole page
|
||||
//FIXME: update the status of the unarchive button rather than reload the whole page
|
||||
window.location.reload(true);
|
||||
})
|
||||
.fail(logAjaxFail);
|
||||
|
|
Loading…
Reference in New Issue