Refactored the test cases for net_cls cgroups isolation.

Review: https://reviews.apache.org/r/51789/

--- src/tests/containerizer/cgroups_isolator_tests.cpp
+++ src/tests/containerizer/cgroups_isolator_tests.cpp
@@ -24,6 +24,8 @@

 #include "slave/containerizer/mesos/isolators/cgroups/constants.hpp"

+#include "slave/containerizer/mesos/isolators/cgroups/subsystems/net_cls.hpp"
+
 #include "tests/mesos.hpp"
 #include "tests/script.hpp"

@@ -41,6 +43,8 @@
 using mesos::internal::slave::DEFAULT_EXECUTOR_CPUS;
 using mesos::internal::slave::Fetcher;
 using mesos::internal::slave::MesosContainerizer;
+using mesos::internal::slave::NetClsHandle;
+using mesos::internal::slave::NetClsHandleManager;

 using mesos::master::detector::MasterDetector;

@@ -48,6 +52,10 @@
 using process::Owned;
 using process::Queue;

+using process::http::OK;
+using process::http::Response;
+
+using std::set;
 using std::string;
 using std::vector;

@@ -513,6 +521,322 @@
   driver.join();
 }

+
+class NetClsHandleManagerTest : public testing::Test {};
+
+
+// Tests the ability of the `NetClsHandleManager` class to allocate
+// and free secondary handles from a range of primary handles.
+TEST_F(NetClsHandleManagerTest, AllocateFreeHandles)
+{
+  NetClsHandleManager manager(IntervalSet<uint32_t>(
+      (Bound<uint32_t>::closed(0x0002),
+       Bound<uint32_t>::closed(0x0003))));
+
+  Try<NetClsHandle> handle = manager.alloc(0x0003);
+  ASSERT_SOME(handle);
+
+  EXPECT_SOME_TRUE(manager.isUsed(handle.get()));
+
+  ASSERT_SOME(manager.free(handle.get()));
+
+  EXPECT_SOME_FALSE(manager.isUsed(handle.get()));
+}
+
+
+// Make sure allocation of secondary handles for invalid primary
+// handles results in an error.
+TEST_F(NetClsHandleManagerTest, AllocateInvalidPrimary)
+{
+  NetClsHandleManager manager(IntervalSet<uint32_t>(
+      (Bound<uint32_t>::closed(0x0002),
+       Bound<uint32_t>::closed(0x0003))));
+
+  ASSERT_ERROR(manager.alloc(0x0001));
+}
+
+
+// Tests that we can reserve secondary handles for a given primary
+// handle so that they won't be allocated out later.
+TEST_F(NetClsHandleManagerTest, ReserveHandles)
+{
+  NetClsHandleManager manager(IntervalSet<uint32_t>(
+      (Bound<uint32_t>::closed(0x0002),
+       Bound<uint32_t>::closed(0x0003))));
+
+  NetClsHandle handle(0x0003, 0xffff);
+
+  ASSERT_SOME(manager.reserve(handle));
+
+  EXPECT_SOME_TRUE(manager.isUsed(handle));
+}
+
+
+// Tests that secondary handles are allocated only from a given range,
+// when the range is specified.
+TEST_F(NetClsHandleManagerTest, SecondaryHandleRange)
+{
+  NetClsHandleManager manager(
+      IntervalSet<uint32_t>(
+        (Bound<uint32_t>::closed(0x0002),
+         Bound<uint32_t>::closed(0x0003))),
+      IntervalSet<uint32_t>(
+        (Bound<uint32_t>::closed(0xffff),
+         Bound<uint32_t>::closed(0xffff))));
+
+  Try<NetClsHandle> handle = manager.alloc(0x0003);
+  ASSERT_SOME(handle);
+
+  EXPECT_SOME_TRUE(manager.isUsed(handle.get()));
+
+  // Try allocating another handle. This should fail, since we don't
+  // have any more secondary handles left.
+  EXPECT_ERROR(manager.alloc(0x0003));
+
+  ASSERT_SOME(manager.free(handle.get()));
+
+  ASSERT_SOME(manager.reserve(handle.get()));
+
+  EXPECT_SOME_TRUE(manager.isUsed(handle.get()));
+
+  // Make sure you cannot reserve a secondary handle that is out of
+  // range.
+  EXPECT_ERROR(manager.reserve(NetClsHandle(0x0003, 0x0001)));
+}
+
+
+// This tests the create, prepare, isolate and cleanup methods of the
+// 'CgroupNetClsIsolatorProcess'. The test first creates a
+// 'MesosContainerizer' with net_cls cgroup isolator enabled. The
+// net_cls cgroup isolator is implemented in the
+// 'CgroupNetClsIsolatorProcess' class. The test then launches a task
+// in a mesos container and checks to see if the container has been
+// added to the right net_cls cgroup. Finally, the test kills the task
+// and makes sure that the 'CgroupNetClsIsolatorProcess' cleans up the
+// net_cls cgroup created for the container.
+TEST_F(CgroupsIsolatorTest, ROOT_CGROUPS_NET_CLS_Isolate)
+{
+  Try<Owned<cluster::Master>> master = StartMaster();
+  ASSERT_SOME(master);
+
+  uint16_t primary = 0x0012;
+
+  slave::Flags flags = CreateSlaveFlags();
+  flags.isolation = "cgroups/net_cls";
+  flags.cgroups_net_cls_primary_handle = stringify(primary);
+  flags.cgroups_net_cls_secondary_handles = "0xffff,0xffff";
+
+  Fetcher fetcher;
+
+  Try<MesosContainerizer*> _containerizer =
+    MesosContainerizer::create(flags, true, &fetcher);
+
+  ASSERT_SOME(_containerizer);
+
+  Owned<MesosContainerizer> containerizer(_containerizer.get());
+
+  Owned<MasterDetector> detector = master.get()->createDetector();
+
+  Try<Owned<cluster::Slave>> slave = StartSlave(
+      detector.get(),
+      containerizer.get(),
+      flags);
+
+  ASSERT_SOME(slave);
+
+  MockScheduler sched;
+
+  MesosSchedulerDriver driver(
+      &sched,
+      DEFAULT_FRAMEWORK_INFO,
+      master.get()->pid,
+      DEFAULT_CREDENTIAL);
+
+  Future<Nothing> schedRegistered;
+  EXPECT_CALL(sched, registered(_, _, _))
+    .WillOnce(FutureSatisfy(&schedRegistered));
+
+  Future<vector<Offer>> offers;
+  EXPECT_CALL(sched, resourceOffers(_, _))
+    .WillOnce(FutureArg<1>(&offers))
+    .WillRepeatedly(Return());      // Ignore subsequent offers.
+
+  driver.start();
+
+  AWAIT_READY(schedRegistered);
+
+  AWAIT_READY(offers);
+  EXPECT_EQ(1u, offers.get().size());
+
+  // Create a task to be launched in the mesos-container. We will be
+  // explicitly killing this task to perform the cleanup test.
+  TaskInfo task = createTask(offers.get()[0], "sleep 1000");
+
+  Future<TaskStatus> status;
+  EXPECT_CALL(sched, statusUpdate(_, _))
+    .WillOnce(FutureArg<1>(&status));
+
+  driver.launchTasks(offers.get()[0].id(), {task});
+
+  // Capture the update to verify that the task has been launched.
+  AWAIT_READY(status);
+  ASSERT_EQ(TASK_RUNNING, status.get().state());
+
+  // Task is ready.  Make sure there is exactly 1 container in the hashset.
+  Future<hashset<ContainerID>> containers = containerizer->containers();
+  AWAIT_READY(containers);
+  EXPECT_EQ(1u, containers.get().size());
+
+  const ContainerID& containerID = *(containers.get().begin());
+
+  Result<string> hierarchy = cgroups::hierarchy("net_cls");
+  ASSERT_SOME(hierarchy);
+
+  // Check if the net_cls cgroup for this container exists, by
+  // checking for the processes associated with this cgroup.
+  string cgroup = path::join(
+      flags.cgroups_root,
+      containerID.value());
+
+  Try<set<pid_t>> pids = cgroups::processes(hierarchy.get(), cgroup);
+  ASSERT_SOME(pids);
+
+  // There should be at least one TGID associated with this cgroup.
+  EXPECT_LE(1u, pids.get().size());
+
+  // Read the `net_cls.classid` to verify that the handle has been set.
+  Try<uint32_t> classid = cgroups::net_cls::classid(hierarchy.get(), cgroup);
+  EXPECT_SOME(classid);
+
+  if (classid.isSome()) {
+    // Make sure the primary handle is the same as the one set in
+    // `--cgroup_net_cls_primary_handle`.
+    EXPECT_EQ(primary, (classid.get() & 0xffff0000) >> 16);
+
+    // Make sure the secondary handle is 0xffff.
+    EXPECT_EQ(0xffffu, classid.get() & 0xffff);
+  }
+
+  // Isolator cleanup test: Killing the task should cleanup the cgroup
+  // associated with the container.
+  Future<TaskStatus> killStatus;
+  EXPECT_CALL(sched, statusUpdate(_, _))
+    .WillOnce(FutureArg<1>(&killStatus));
+
+  // Wait for the executor to exit. We are using 'gc.schedule' as a proxy event
+  // to monitor the exit of the executor.
+  Future<Nothing> gcSchedule = FUTURE_DISPATCH(
+      _, &slave::GarbageCollectorProcess::schedule);
+
+  driver.killTask(status.get().task_id());
+
+  AWAIT_READY(gcSchedule);
+
+  // If the cleanup is successful the net_cls cgroup for this container should
+  // not exist.
+  ASSERT_FALSE(os::exists(cgroup));
+
+  driver.stop();
+  driver.join();
+}
+
+
+// This test verifies that we are able to retrieve the `net_cls` handle
+// from `/state`.
+TEST_F(CgroupsIsolatorTest, ROOT_CGROUPS_NET_CLS_ContainerStatus)
+{
+  Try<Owned<cluster::Master>> master = StartMaster();
+  ASSERT_SOME(master);
+
+  slave::Flags flags = CreateSlaveFlags();
+  flags.isolation = "cgroups/net_cls";
+  flags.cgroups_net_cls_primary_handle = stringify(0x0012);
+  flags.cgroups_net_cls_secondary_handles = "0x0011,0x0012";
+
+  Fetcher fetcher;
+
+  Try<MesosContainerizer*> _containerizer =
+    MesosContainerizer::create(flags, true, &fetcher);
+
+  ASSERT_SOME(_containerizer);
+
+  Owned<MesosContainerizer> containerizer(_containerizer.get());
+
+  Owned<MasterDetector> detector = master.get()->createDetector();
+
+  Try<Owned<cluster::Slave>> slave = StartSlave(
+      detector.get(),
+      containerizer.get(),
+      flags);
+
+  ASSERT_SOME(slave);
+
+  MockScheduler sched;
+
+  MesosSchedulerDriver driver(
+      &sched,
+      DEFAULT_FRAMEWORK_INFO,
+      master.get()->pid,
+      DEFAULT_CREDENTIAL);
+
+  Future<Nothing> schedRegistered;
+  EXPECT_CALL(sched, registered(_, _, _))
+    .WillOnce(FutureSatisfy(&schedRegistered));
+
+  Future<vector<Offer>> offers;
+  EXPECT_CALL(sched, resourceOffers(_, _))
+    .WillOnce(FutureArg<1>(&offers))
+    .WillRepeatedly(Return());      // Ignore subsequent offers.
+
+  driver.start();
+
+  AWAIT_READY(schedRegistered);
+
+  AWAIT_READY(offers);
+  EXPECT_EQ(1u, offers.get().size());
+
+  // Create a task to be launched in the mesos-container.
+  TaskInfo task = createTask(offers.get()[0], "sleep 1000");
+
+  Future<TaskStatus> status;
+  EXPECT_CALL(sched, statusUpdate(_, _))
+    .WillOnce(FutureArg<1>(&status));
+
+  driver.launchTasks(offers.get()[0].id(), {task});
+
+  AWAIT_READY(status);
+  ASSERT_EQ(TASK_RUNNING, status.get().state());
+
+  // Task is ready. Verify `ContainerStatus` is present in slave state.
+  Future<Response> response = process::http::get(
+      slave.get()->pid,
+      "state",
+      None(),
+      createBasicAuthHeaders(DEFAULT_CREDENTIAL));
+
+  AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
+  AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
+
+  Try<JSON::Object> parse = JSON::parse<JSON::Object>(response.get().body);
+  ASSERT_SOME(parse);
+
+  Result<JSON::Object> netCls = parse->find<JSON::Object>(
+      "frameworks[0].executors[0].tasks[0].statuses[0]."
+      "container_status.cgroup_info.net_cls");
+
+  ASSERT_SOME(netCls);
+
+  uint32_t classid =
+    netCls->values["classid"].as<JSON::Number>().as<uint32_t>();
+
+  // Check the primary and the secondary handle.
+  EXPECT_EQ(0x0012u, classid >> 16);
+  EXPECT_EQ(0x0011u, classid & 0xffff);
+
+  driver.stop();
+  driver.join();
+}
+
 } // namespace tests {
 } // namespace internal {
 } // namespace mesos {


Added Appc provisioner integration test.

Review: https://reviews.apache.org/r/44456/

--- src/tests/containerizer/provisioner_appc_tests.cpp
+++ src/tests/containerizer/provisioner_appc_tests.cpp
@@ -43,6 +43,10 @@
 #include "slave/containerizer/mesos/provisioner/appc/fetcher.hpp"
 #include "slave/containerizer/mesos/provisioner/appc/paths.hpp"
 #include "slave/containerizer/mesos/provisioner/appc/store.hpp"
+
+#include "tests/mesos.hpp"
+
+#include "tests/containerizer/rootfs.hpp"

 using std::list;
 using std::string;
@@ -747,6 +751,166 @@
   ASSERT_SOME_EQ("test", os::read(path::join(imageRootfs, "tmp", "test")));
 }

+
+#ifdef __linux__
+// Test fixture for Appc image provisioner integration tests. It also provides a
+// helper for creating a base linux image bundle.
+class AppcProvisionerIntegrationTest : public MesosTest
+{
+protected:
+  // Prepares a base 'linux' Appc image bundle from host's rootfs.
+  void prepareImageBundle(const string& imageName, const string& mntDir)
+  {
+    // TODO(jojy): Consider parameterizing the labels for image name decoration.
+    const string imageBundleName = imageName + "-latest-linux-amd64.aci";
+
+    const string imagesPath = path::join(mntDir, "images");
+    const string imagePath = path::join(imagesPath, imageBundleName);
+
+    const string manifest = strings::format(
+        R"~(
+        {
+          "acKind": "ImageManifest",
+            "acVersion": "0.6.1",
+            "name": "%s",
+            "labels": [
+            {
+              "name": "version",
+              "value": "latest"
+            },
+            {
+              "name": "arch",
+              "value": "amd64"
+            },
+            {
+              "name": "os",
+              "value": "linux"
+            }
+          ],
+            "annotations": [
+            {
+              "name": "created",
+              "value": "1438983392"
+            }
+          ]
+        })~",
+        imageName).get();
+
+    const string rootfsPath = path::join(imagePath, "rootfs");
+
+    // Setup image on the server.
+    Try<Owned<Rootfs>> rootfs = LinuxRootfs::create(rootfsPath);
+    ASSERT_SOME(rootfs);
+
+    // 'modules' directory is usually very large and is an easy one to exclude.
+    // TODO(jojy): Consider adding directory exclusion filter in LinuxRootfs.
+    Try<Nothing> rmdir = os::rmdir(path::join(rootfsPath, "lib", "modules"));
+    ASSERT_SOME(rmdir);
+
+    Try<Nothing> manifestWrite = os::write(
+        path::join(imagePath, "manifest"),
+        manifest);
+
+    ASSERT_SOME(manifestWrite);
+
+    const string imageBundlePath = path::join(mntDir, imageBundleName);
+
+    Future<Nothing> future = command::tar(
+        Path("."),
+        Path(imageBundlePath),
+        imagePath,
+        command::Compression::GZIP);
+
+    AWAIT_READY_FOR(future, Seconds(120));
+  }
+};
+
+
+// Tests the Appc image provisioner for a single layered Linux image. The
+// image's rootfs is built from local host's file system.
+TEST_F(AppcProvisionerIntegrationTest, ROOT_SimpleLinuxImageTest)
+{
+  const string imageName = "linux";
+
+  // Represents the directory where image bundles would be mounted.
+  const string mntDir = path::join(os::getcwd(), "mnt");
+
+  // Prepare the image bundle at the mount point.
+  prepareImageBundle(imageName, mntDir);
+
+  // Start master.
+  Try<PID<master::Master>> master = StartMaster();
+  ASSERT_SOME(master);
+
+  // Start agent.
+  slave::Flags flags = CreateSlaveFlags();
+  flags.isolation = "filesystem/linux";
+  flags.image_providers = "APPC";
+  flags.appc_simple_discovery_uri_prefix = path::join(mntDir, "");
+
+  Try<PID<slave::Slave>> slave = StartSlave(flags);
+  ASSERT_SOME(slave);
+
+  MockScheduler sched;
+  MesosSchedulerDriver driver(
+      &sched, DEFAULT_FRAMEWORK_INFO, master.get(), DEFAULT_CREDENTIAL);
+
+  EXPECT_CALL(sched, registered(&driver, _, _));
+
+  Future<vector<Offer>> offers;
+  EXPECT_CALL(sched, resourceOffers(&driver, _))
+    .WillOnce(FutureArg<1>(&offers))
+    .WillRepeatedly(Return()); // Ignore subsequent offers.
+
+  driver.start();
+
+  AWAIT_READY(offers);
+  ASSERT_EQ(1u, offers->size());
+
+  const Offer& offer = offers.get()[0];
+
+  TaskInfo task = createTask(
+      offer.slave_id(),
+      Resources::parse("cpus:1;mem:128").get(),
+      "ls -al /");
+
+  // Setup image for task.
+  Image::Appc appc = getAppcImage(imageName);
+
+  Image image;
+  image.set_type(Image::APPC);
+  image.mutable_appc()->CopyFrom(appc);
+
+  ContainerInfo* container = task.mutable_container();
+  container->set_type(ContainerInfo::MESOS);
+  container->mutable_mesos()->mutable_image()->CopyFrom(image);
+
+  Future<TaskStatus> statusRunning;
+  Future<TaskStatus> statusFinished;
+
+  EXPECT_CALL(sched, statusUpdate(&driver, _))
+    .WillOnce(FutureArg<1>(&statusRunning))
+    .WillOnce(FutureArg<1>(&statusFinished));
+
+  driver.launchTasks(offer.id(), {task});
+
+  AWAIT_READY_FOR(statusRunning, Seconds(120));
+  EXPECT_EQ(task.task_id(), statusRunning->task_id());
+  EXPECT_EQ(TASK_RUNNING, statusRunning->state());
+
+  AWAIT_READY(statusFinished);
+  EXPECT_EQ(task.task_id(), statusFinished->task_id());
+  EXPECT_EQ(TASK_FINISHED, statusFinished->state());
+
+  driver.stop();
+  driver.join();
+
+  Shutdown();
+}
+#endif
+
+// TODO(jojy): Add integration test for image with dependencies.
+
 } // namespace tests {
 } // namespace internal {
 } // namespace mesos {


Disable array-bounds diagnostics

Disable array-bounds diagnostics

--- src/theia/image/keypoint_detector/sift_detector.cc
+++ src/theia/image/keypoint_detector/sift_detector.cc
@@ -97,12 +97,15 @@
       if (sift_params_.upright_sift && num_angles > 1) {
         num_angles = 1;
       }
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
       for (int j = 0; j < num_angles; j++) {
         Keypoint keypoint(vl_keypoints[i].x, vl_keypoints[i].y, Keypoint::SIFT);
         keypoint.set_scale(vl_keypoints[i].sigma);
         keypoint.set_orientation(angles[j]);
         keypoints->push_back(keypoint);
       }
+#pragma GCC diagnostic pop
     }
     // Attempt to process the next octave.
     vl_status = vl_sift_process_next_octave(sift_filter_);


fix json parsing

fix json parsing

--- src/rpc.cpp
+++ src/rpc.cpp
@@ -600,13 +600,13 @@
 }

 JSValueRef RPCServer::deserialize_json_value(const json dict) {
-    json oid = dict["id"];
+    json oid = dict.value("id", json());
     if (oid.is_number()) {
         return m_objects[oid.get<RPCObjectID>()];
     }

-    json value = dict["value"];
-    json type = dict["type"];
+    json value = dict.value("value", json());
+    json type = dict.value("type", json());

     if (type.is_string()) {
         std::string type_string = type.get<std::string>();


Don't get tab id until tab window handle is ready.

There are rare cases where the executor manager will DCHECK that the window handle that we ask it to associate to our tab id doesn't have a valid IEFrame parent. This is because we send the request for id <-> handle association before the handle is completely ready... So wait until the tab window handle is valid before sending a mapping event.

BUG=None yet... crbug down for maintenance :-(
TEST=None

Review URL: http://codereview.chromium.org/5632004

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@68607 0039d316-1c4b-4281-b951-d872f2087c98

--- ceee/ie/plugin/bho/browser_helper_object.cc
+++ ceee/ie/plugin/bho/browser_helper_object.cc
@@ -616,6 +616,11 @@
     return true;
   }

+  // We might be called a bit early, and our handle is not quite ready to
+  // be associated to an ID, so no need to ask Chrome Frame for it... yet...
+  if (!::IsWindow(tab_window_))
+    return false;
+
   // We might get here AFTER TearDown if onCreated successfully got deferred
   // yet we never got a valid tab_id_ before we got torn down, and then
   // onRemoved is called AFTER TearDown, which releases chrome_frame_host_.


Management of a special case when epsilon[Im]=1

--- MPP_gen.cpp
+++ MPP_gen.cpp
@@ -1452,17 +1452,29 @@

 		// (Fifth rows)
 		int offset_5r = nConstr_shape + nConstr_shapeIm + 2*nDimOut;
-		for (int i=0; i<nInd; i++) {
-			inputConstrLongMat[offset_5r+i][0] = epsilon;								// Eq/Ineq
-			inputConstrLongMat[offset_5r+i][1+i] = 1;									// i_b
-			inputConstrLongMat[offset_5r+i][nCol_blConstr-1] = -alpha[i];				// Const
+		if (epsilon==1) {		// No constraint => fill this part of the array with "0=0"
+			// Nothing (already initialized with 0s)
+		} else {
+			for (int i=0; i<nInd; i++) {
+				inputConstrLongMat[offset_5r+i][0] = epsilon;								// Eq/Ineq
+				inputConstrLongMat[offset_5r+i][1+i] = 1;									// i_b
+				inputConstrLongMat[offset_5r+i][nCol_blConstr-1] = -alpha[i];				// Const
+			}
 		}

 		// (Sixth rows)
-		for (int i=0; i<nDimOut; i++) {
-			inputConstrLongMat[offset_5r+nInd+i][0] = epsilonIm;						// Eq/Ineq
-			inputConstrLongMat[offset_5r+nInd+i][1+i] = 1;								// i_b
-			inputConstrLongMat[offset_5r+nInd+i][nCol_blConstr-1] = -alphaIm[i];		// Const
+		if (epsilonIm==1) {		// No constraint => fill this part of the array with "0=0"
+			// Nothing (already initialized with 0s)
+		} else {
+			for (int i=0; i<nDimOut; i++) {
+				inputConstrLongMat[offset_5r+nInd+i][0] = epsilonIm;						// Eq/Ineq
+				inputConstrLongMat[offset_5r+nInd+i][1+i] = 1;								// i_b
+
+				// TODO: correct that into i'_b
+
+
+				inputConstrLongMat[offset_5r+nInd+i][nCol_blConstr-1] = -alphaIm[i];		// Const
+			}
 		}

 		polyhedronMPP* polyRet = buildPolyhedron(inputConstrLongMat, nRow_blConstr, 2*nInd, 2*nParam+1);


remove feature supported only in Qt 5.5

remove feature supported only in Qt 5.5

--- cgogn/rendering/examples/picking_viewer.cpp
+++ cgogn/rendering/examples/picking_viewer.cpp
@@ -27,6 +27,7 @@
 #include <qoglviewer.h>
 #include <vec.h>
 #include <QMouseEvent>
+#include <QVector3D>

 #include <core/cmap/cmap2.h>

@@ -70,7 +71,7 @@

 private:
-	void rayClick(QMouseEvent* event, QVector3D& P, QVector3D& Q);
+	void rayClick(QMouseEvent* event, qoglviewer::Vec& P, qoglviewer::Vec& Q);

 	QRect viewport_;
@@ -176,20 +177,10 @@
 }

-void Viewer::rayClick(QMouseEvent* event, QVector3D& P, QVector3D& Q)
-{
-	int vp[4];
-	glGetIntegerv(GL_VIEWPORT, vp);
-	QRect viewport = QRect(vp[0],vp[1],vp[2],vp[3]);
-
-	unsigned int x = event->x()*devicePixelRatio();
-	unsigned int y = (this->height()-event->y())*devicePixelRatio();
-
-	QVector3D wp(x,y,0.01);
-	P = wp.unproject(view_,proj_,viewport);
-	QVector3D wq(x,y,0.99);
-	Q = wq.unproject(view_,proj_,viewport);
-
+void Viewer::rayClick(QMouseEvent* event, qoglviewer::Vec& P, qoglviewer::Vec& Q)
+{
+	P = camera()->unprojectedCoordinatesOf(qoglviewer::Vec(event->x(),event->y(),0.01));
+	Q = camera()->unprojectedCoordinatesOf(qoglviewer::Vec(event->x(),event->y(),0.99));
 }

@@ -218,8 +209,8 @@
 {
 	if (event->modifiers() & Qt::ShiftModifier)
 	{
-		QVector3D P;
-		QVector3D Q;
+		qoglviewer::Vec P;
+		qoglviewer::Vec Q;
 		rayClick(event,P,Q);

 		Vec3 A(P[0],P[1],P[2]);


INTEGRATION: CWS pj83 (1.5.6); FILE MERGED 2007/08/01 07:20:43 pjanik 1.5.6.1: #i80015#: Make chart2 WaE clean.

--- chart2/source/tools/CharacterProperties.cxx
+++ chart2/source/tools/CharacterProperties.cxx
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: CharacterProperties.cxx,v $
  *
- *  $Revision: 1.5 $
- *
- *  last change: $Author: rt $ $Date: 2007-07-25 08:55:28 $
+ *  $Revision: 1.6 $
+ *
+ *  last change: $Author: hr $ $Date: 2007-08-03 12:36:13 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -658,7 +658,7 @@
     aValues[ i++ ]  >>= aResult.Name;
     aValues[ i++ ]  >>= aResult.Pitch;
     aValues[ i++ ]  >>= aResult.StyleName;
-    float fCharHeight;
+    float fCharHeight = 0;
     aValues[ i++ ]  >>= fCharHeight;
     aResult.Height = static_cast< sal_Int16 >( fCharHeight );
     aValues[ i++ ]  >>= aResult.Slant;


Clean up implicit conversions in alu.cpp

--- alc/alu.cpp
+++ alc/alu.cpp
@@ -451,12 +451,11 @@
     };

     const auto Frequency = static_cast<ALfloat>(Device->Frequency);
-    const ALsizei NumSends{Device->NumAuxSends};
-    ASSUME(NumSends >= 0);
+    const auto NumSends = static_cast<ALuint>(Device->NumAuxSends);

     bool DirectChannels{props->DirectChannels != AL_FALSE};
     const ChanMap *chans{nullptr};
-    ALsizei num_channels{0};
+    ALuint num_channels{0};
     bool isbformat{false};
     ALfloat downmix_gain{1.0f};
     switch(voice->mFmtChannels)
@@ -583,7 +582,7 @@
             const ALfloat &scale0 = AmbiScale::FromFuMa[0];
             ComputePanGains(&Device->Dry, coeffs, DryGain*scale0,
                 voice->mChans[0].mDryParams.Gains.Target);
-            for(ALsizei i{0};i < NumSends;i++)
+            for(ALuint i{0};i < NumSends;i++)
             {
                 if(const ALeffectslot *Slot{SendSlots[i]})
                     ComputePanGains(&Slot->Wet, coeffs, WetGain[i]*scale0,
@@ -636,12 +635,12 @@
                 {   0.0f, -V[0]*zscale,  V[1]*zscale, -V[2]*zscale }  // FuMa Z
             };

-            for(ALsizei c{0};c < num_channels;c++)
+            for(ALuint c{0};c < num_channels;c++)
             {
                 ComputePanGains(&Device->Dry, matrix[c], DryGain,
                     voice->mChans[c].mDryParams.Gains.Target);

-                for(ALsizei i{0};i < NumSends;i++)
+                for(ALuint i{0};i < NumSends;i++)
                 {
                     if(const ALeffectslot *Slot{SendSlots[i]})
                         ComputePanGains(&Slot->Wet, matrix[c], WetGain[i],
@@ -657,7 +656,7 @@
          */
         voice->mDirect.Buffer = Device->RealOut.Buffer;

-        for(ALsizei c{0};c < num_channels;c++)
+        for(ALuint c{0};c < num_channels;c++)
         {
             const ALuint idx{GetChannelIdxByName(Device->RealOut, chans[c].channel)};
             if(idx != INVALID_CHANNEL_INDEX)
@@ -667,12 +666,12 @@
         /* Auxiliary sends still use normal channel panning since they mix to
          * B-Format, which can't channel-match.
          */
-        for(ALsizei c{0};c < num_channels;c++)
+        for(ALuint c{0};c < num_channels;c++)
         {
             ALfloat coeffs[MAX_AMBI_CHANNELS];
             CalcAngleCoeffs(chans[c].angle, chans[c].elevation, 0.0f, coeffs);

-            for(ALsizei i{0};i < NumSends;i++)
+            for(ALuint i{0};i < NumSends;i++)
             {
                 if(const ALeffectslot *Slot{SendSlots[i]})
                     ComputePanGains(&Slot->Wet, coeffs, WetGain[i],
@@ -701,7 +700,7 @@
             voice->mChans[0].mDryParams.Hrtf.Target.Gain = DryGain * downmix_gain;

             /* Remaining channels use the same results as the first. */
-            for(ALsizei c{1};c < num_channels;c++)
+            for(ALuint c{1};c < num_channels;c++)
             {
                 /* Skip LFE */
                 if(chans[c].channel == LFE) continue;
@@ -714,12 +713,12 @@
             ALfloat coeffs[MAX_AMBI_CHANNELS];
             CalcDirectionCoeffs({xpos, ypos, zpos}, Spread, coeffs);

-            for(ALsizei c{0};c < num_channels;c++)
+            for(ALuint c{0};c < num_channels;c++)
             {
                 /* Skip LFE */
                 if(chans[c].channel == LFE)
                     continue;
-                for(ALsizei i{0};i < NumSends;i++)
+                for(ALuint i{0};i < NumSends;i++)
                 {
                     if(const ALeffectslot *Slot{SendSlots[i]})
                         ComputePanGains(&Slot->Wet, coeffs, WetGain[i] * downmix_gain,
@@ -733,7 +732,7 @@
              * relative location around the listener, providing "virtual
              * speaker" responses.
              */
-            for(ALsizei c{0};c < num_channels;c++)
+            for(ALuint c{0};c < num_channels;c++)
             {
                 /* Skip LFE */
                 if(chans[c].channel == LFE)
@@ -752,7 +751,7 @@
                 ALfloat coeffs[MAX_AMBI_CHANNELS];
                 CalcAngleCoeffs(chans[c].angle, chans[c].elevation, Spread, coeffs);

-                for(ALsizei i{0};i < NumSends;i++)
+                for(ALuint i{0};i < NumSends;i++)
                 {
                     if(const ALeffectslot *Slot{SendSlots[i]})
                         ComputePanGains(&Slot->Wet, coeffs, WetGain[i],
@@ -779,7 +778,7 @@
                 const ALfloat w0{SPEEDOFSOUNDMETRESPERSEC / (mdist * Frequency)};

                 /* Adjust NFC filters. */
-                for(ALsizei c{0};c < num_channels;c++)
+                for(ALuint c{0};c < num_channels;c++)
                     voice->mChans[c].mDryParams.NFCtrlFilter.adjust(w0);

                 voice->mFlags |= VOICE_HAS_NFC;
@@ -798,7 +797,7 @@
                 CalcAngleCoeffs(ScaleAzimuthFront(az, 1.5f), ev, Spread, coeffs);
             }

-            for(ALsizei c{0};c < num_channels;c++)
+            for(ALuint c{0};c < num_channels;c++)
             {
                 /* Special-case LFE */
                 if(chans[c].channel == LFE)
@@ -814,14 +813,7 @@

                 ComputePanGains(&Device->Dry, coeffs, DryGain * downmix_gain,
                     voice->mChans[c].mDryParams.Gains.Target);
-            }
-
-            for(ALsizei c{0};c < num_channels;c++)
-            {
-                /* Skip LFE */
-                if(chans[c].channel == LFE)
-                    continue;
-                for(ALsizei i{0};i < NumSends;i++)
+                for(ALuint i{0};i < NumSends;i++)
                 {
                     if(const ALeffectslot *Slot{SendSlots[i]})
                         ComputePanGains(&Slot->Wet, coeffs, WetGain[i] * downmix_gain,
@@ -840,13 +832,13 @@
                  */
                 const ALfloat w0{SPEEDOFSOUNDMETRESPERSEC / (Device->AvgSpeakerDist * Frequency)};

-                for(ALsizei c{0};c < num_channels;c++)
+                for(ALuint c{0};c < num_channels;c++)
                     voice->mChans[c].mDryParams.NFCtrlFilter.adjust(w0);

                 voice->mFlags |= VOICE_HAS_NFC;
             }

-            for(ALsizei c{0};c < num_channels;c++)
+            for(ALuint c{0};c < num_channels;c++)
             {
                 /* Special-case LFE */
                 if(chans[c].channel == LFE)
@@ -869,7 +861,7 @@

                 ComputePanGains(&Device->Dry, coeffs, DryGain,
                     voice->mChans[c].mDryParams.Gains.Target);
-                for(ALsizei i{0};i < NumSends;i++)
+                for(ALuint i{0};i < NumSends;i++)
                 {
                     if(const ALeffectslot *Slot{SendSlots[i]})
                         ComputePanGains(&Slot->Wet, coeffs, WetGain[i],
@@ -894,13 +886,13 @@
             lowpass.rcpQFromSlope(gainHF, 1.0f));
         highpass.setParams(BiquadType::LowShelf, gainLF, lfScale,
             highpass.rcpQFromSlope(gainLF, 1.0f));
-        for(ALsizei c{1};c < num_channels;c++)
+        for(ALuint c{1};c < num_channels;c++)
         {
             voice->mChans[c].mDryParams.LowPass.copyParamsFrom(lowpass);
             voice->mChans[c].mDryParams.HighPass.copyParamsFrom(highpass);
         }
     }
-    for(ALsizei i{0};i < NumSends;i++)
+    for(ALuint i{0};i < NumSends;i++)
     {
         const ALfloat hfScale{props->Send[i].HFReference / Frequency};
         const ALfloat lfScale{props->Send[i].LFReference / Frequency};
@@ -917,7 +909,7 @@
             lowpass.rcpQFromSlope(gainHF, 1.0f));
         highpass.setParams(BiquadType::LowShelf, gainLF, lfScale,
             highpass.rcpQFromSlope(gainLF, 1.0f));
-        for(ALsizei c{1};c < num_channels;c++)
+        for(ALuint c{1};c < num_channels;c++)
         {
             voice->mChans[c].mWetParams[i].LowPass.copyParamsFrom(lowpass);
             voice->mChans[c].mWetParams[i].HighPass.copyParamsFrom(highpass);
@@ -931,7 +923,7 @@
     ALeffectslot *SendSlots[MAX_SENDS];

     voice->mDirect.Buffer = Device->Dry.Buffer;
-    for(ALsizei i{0};i < Device->NumAuxSends;i++)
+    for(ALuint i{0};i < static_cast<ALuint>(Device->NumAuxSends);i++)
     {
         SendSlots[i] = props->Send[i].Slot;
         if(!SendSlots[i] && i == 0)
@@ -982,7 +974,7 @@
 void CalcAttnSourceParams(ALvoice *voice, const ALvoicePropsBase *props, const ALCcontext *ALContext)
 {
     const ALCdevice *Device{ALContext->mDevice.get()};
-    const ALsizei NumSends{Device->NumAuxSends};
+    const auto NumSends = static_cast<ALuint>(Device->NumAuxSends);
     const ALlistener &Listener = ALContext->mListener;

     /* Set mixing buffers and get send parameters. */
@@ -992,7 +984,7 @@
     ALfloat DecayDistance[MAX_SENDS];
     ALfloat DecayLFDistance[MAX_SENDS];
     ALfloat DecayHFDistance[MAX_SENDS];
-    for(ALsizei i{0};i < NumSends;i++)
+    for(ALuint i{0};i < NumSends;i++)
     {
         SendSlots[i] = props->Send[i].Slot;
         if(!SendSlots[i] && i == 0)
@@ -1071,7 +1063,7 @@
     ALfloat DryGainHF{1.0f};
     ALfloat DryGainLF{1.0f};
     ALfloat WetGain[MAX_SENDS], WetGainHF[MAX_SENDS], WetGainLF[MAX_SENDS];
-    for(ALsizei i{0};i < NumSends;i++)
+    for(ALuint i{0};i < NumSends;i++)
     {
         WetGain[i] = props->Gain;
         WetGainHF[i] = 1.0f;
@@ -1095,7 +1087,7 @@
             {
                 ALfloat dist = lerp(props->RefDistance, ClampedDist, props->RolloffFactor);
                 if(dist > 0.0f) DryGain *= props->RefDistance / dist;
-                for(ALsizei i{0};i < NumSends;i++)
+                for(ALuint i{0};i < NumSends;i++)
                 {
                     dist = lerp(props->RefDistance, ClampedDist, RoomRolloff[i]);
                     if(dist > 0.0f) WetGain[i] *= props->RefDistance / dist;
@@ -1115,7 +1107,7 @@
                 ALfloat attn = props->RolloffFactor * (ClampedDist-props->RefDistance) /
                                (props->MaxDistance-props->RefDistance);
                 DryGain *= maxf(1.0f - attn, 0.0f);
-                for(ALsizei i{0};i < NumSends;i++)
+                for(ALuint i{0};i < NumSends;i++)
                 {
                     attn = RoomRolloff[i] * (ClampedDist-props->RefDistance) /
                            (props->MaxDistance-props->RefDistance);
@@ -1134,7 +1126,7 @@
             else
             {
                 DryGain *= std::pow(ClampedDist/props->RefDistance, -props->RolloffFactor);
-                for(ALsizei i{0};i < NumSends;i++)
+                for(ALuint i{0};i < NumSends;i++)
                     WetGain[i] *= std::pow(ClampedDist/props->RefDistance, -RoomRolloff[i]);
             }
             break;
@@ -1188,7 +1180,7 @@
     DryGain = minf(DryGain*props->Direct.Gain*Listener.Params.Gain, GAIN_MIX_MAX);
     DryGainHF *= props->Direct.GainHF;
     DryGainLF *= props->Direct.GainLF;
-    for(ALsizei i{0};i < NumSends;i++)
+    for(ALuint i{0};i < NumSends;i++)
     {
         WetGain[i] = clampf(WetGain[i], props->MinGain, props->MaxGain);
         WetGain[i] = minf(WetGain[i]*props->Send[i].Gain*Listener.Params.Gain, GAIN_MIX_MAX);
@@ -1217,7 +1209,7 @@
              * source distance in meters. The initial decay of the reverb
              * effect is calculated and applied to the wet path.
              */
-            for(ALsizei i{0};i < NumSends;i++)
+            for(ALuint i{0};i < NumSends;i++)
             {
                 if(!(DecayDistance[i] > 0.0f))
                     continue;
@@ -1585,17 +1577,17 @@
     return fastf2i(clampf(val*2147483648.0f, -2147483648.0f, 2147483520.0f));
 }
 template<> inline ALshort SampleConv(ALfloat val) noexcept
-{ return fastf2i(clampf(val*32768.0f, -32768.0f, 32767.0f)); }
+{ return static_cast<ALshort>(fastf2i(clampf(val*32768.0f, -32768.0f, 32767.0f))); }
 template<> inline ALbyte SampleConv(ALfloat val) noexcept
-{ return fastf2i(clampf(val*128.0f, -128.0f, 127.0f)); }
+{ return static_cast<ALbyte>(fastf2i(clampf(val*128.0f, -128.0f, 127.0f))); }

 /* Define unsigned output variations. */
 template<> inline ALuint SampleConv(ALfloat val) noexcept
-{ return SampleConv<ALint>(val) + 2147483648u; }
+{ return static_cast<ALuint>(SampleConv<ALint>(val)) + 2147483648u; }
 template<> inline ALushort SampleConv(ALfloat val) noexcept
-{ return SampleConv<ALshort>(val) + 32768; }
+{ return static_cast<ALushort>(SampleConv<ALshort>(val) + 32768); }
 template<> inline ALubyte SampleConv(ALfloat val) noexcept
-{ return SampleConv<ALbyte>(val) + 128; }
+{ return static_cast<ALubyte>(SampleConv<ALbyte>(val) + 128); }

 template<DevFmtType T>
 void Write(const al::span<const FloatBufferLine> InBuffer, ALvoid *OutBuffer, const size_t Offset,


Fix build

Fix build

--- src/user.cc
+++ src/user.cc
@@ -9,7 +9,7 @@
 #include "./json.h"

 #include "Poco/Logger.h"
-#include "Poco/StopWatch.h"
+#include "Poco/Stopwatch.h"

 namespace kopsik {


Updated server settings

Updated server settings

--- src/cache/sources/memory_cache_serversettings.cpp
+++ src/cache/sources/memory_cache_serversettings.cpp
@@ -41,6 +41,10 @@
     QString sGroupServerFolders = "server_folders";
     addNewSetting(new ServerSettHelper(sGroupServerFolders, "server_folder_games", QString("/var/www/html/fhq/files/games/")));
     addNewSetting(new ServerSettHelper(sGroupServerFolders, "server_folder_games_url", QString("https://freehackquest.com/files/games/")));
+    addNewSetting(new ServerSettHelper(sGroupServerFolders, "server_folder_quests", QString("/var/www/html/fhq/files/quests/")));
+    addNewSetting(new ServerSettHelper(sGroupServerFolders, "server_folder_quests_url", QString("https://freehackquest.com/files/quests/")));
+    addNewSetting(new ServerSettHelper(sGroupServerFolders, "server_folder_users", QString("/var/www/html/fhq/files/quests/")));
+    addNewSetting(new ServerSettHelper(sGroupServerFolders, "server_folder_users_url", QString("https://freehackquest.com/files/quests/")));

     QStringList listFoundInDatabase;


Fix utf8::to_previous that could go before the begin iterator

--- src/utf8.hh
+++ src/utf8.hh
@@ -157,7 +157,7 @@
 {
     if (it != begin)
         --it;
-    while (not is_character_start(*it))
+    while (it != begin and not is_character_start(*it))
         --it;
 }
 // returns an iterator to the previous character first byte


Fixed using wrong function ptr. Woops.

Fixed using wrong function ptr. Woops.

--- src/client/intercept/client/sqf/uncategorized.cpp
+++ src/client/intercept/client/sqf/uncategorized.cpp
@@ -6727,7 +6727,7 @@
                     (float)cargo_index_
                 });

-                host::functions.invoke_raw_binary(__sqf::binary__moveincargo__object__object__ret__nothing, unit_, params);
+                host::functions.invoke_raw_binary(__sqf::binary__moveincargo__object__array__ret__nothing, unit_, params);
             }
         }


INTEGRATION: CWS components1 (1.19.72); FILE MERGED 2007/01/25 15:18:18 af 1.19.72.5: RESYNC: (1.22-1.23); FILE MERGED 2006/11/21 16:22:47 af 1.19.72.4: RESYNC: (1.21-1.22); FILE MERGED 2006/11/21 09:39:52 af 1.19.72.3: RESYNC: (1.20-1.21); FILE MERGED 2006/09/25 17:23:02 af 1.19.72.2: RESYNC: (1.19-1.20); FILE MERGED 2006/08/22 11:39:01 af 1.19.72.1: #i68075# Adaption to change of signature of ViewShellBase::Get(Main)ViewShell().

--- sd/source/ui/slidesorter/controller/SlsClipboard.cxx
+++ sd/source/ui/slidesorter/controller/SlsClipboard.cxx
@@ -4,9 +4,9 @@
  *
  *  $RCSfile: SlsClipboard.cxx,v $
  *
- *  $Revision: 1.23 $
- *
- *  last change: $Author: kz $ $Date: 2006-12-12 18:23:00 $
+ *  $Revision: 1.24 $
+ *
+ *  last change: $Author: rt $ $Date: 2007-04-03 16:16:50 $
  *
  *  The Contents of this file are made available subject to
  *  the terms of GNU Lesser General Public License Version 2.1.
@@ -720,7 +720,7 @@
     // is implemented in the ViewShell class and uses the page view of the
     // main edit view.  This is not possible without a DrawViewShell.
     DrawViewShell* pDrawViewShell = dynamic_cast<DrawViewShell*>(
-        mrController.GetViewShell().GetViewShellBase().GetMainViewShell());
+        mrController.GetViewShell().GetViewShellBase().GetMainViewShell().get());
     if (pDrawViewShell != NULL
         && (pDrawViewShell->GetShellType() == ViewShell::ST_IMPRESS
             || pDrawViewShell->GetShellType() == ViewShell::ST_DRAW))


INTEGRATION: CWS presentationengine01 (1.2.12); FILE MERGED 2004/09/30 15:40:22 af 1.2.12.1: #i34242# Added support for help ids.

--- sd/source/ui/toolpanel/controls/MasterPagesPanel.cxx
+++ sd/source/ui/toolpanel/controls/MasterPagesPanel.cxx
@@ -2,9 +2,9 @@
  *
  *  $RCSfile: MasterPagesPanel.cxx,v $
  *
- *  $Revision: 1.2 $
+ *  $Revision: 1.3 $
  *
- *  last change: $Author: rt $ $Date: 2004-07-13 14:44:27 $
+ *  last change: $Author: rt $ $Date: 2004-11-26 20:26:20 $
  *
  *  The Contents of this file are made available subject to the terms of
  *  either of the following licenses
@@ -70,6 +70,8 @@

 #include "strings.hrc"
 #include "sdresid.hxx"
+#include "helpids.h"
+

 namespace sd { namespace toolpanel { namespace controls {

@@ -94,7 +96,8 @@
     pSelector->LateInit();
     pScrollPanel->AddControl (
         ::std::auto_ptr<TreeNode>(pSelector),
-        SdResId(STR_TASKPANEL_CURRENT_MASTER_PAGES_TITLE));
+        SdResId(STR_TASKPANEL_CURRENT_MASTER_PAGES_TITLE),
+        HID_SD_CURRENT_MASTERS);

     // Create a panel with the most recently used master pages.
     pSelector = new controls::RecentMasterPagesSelector (
@@ -104,7 +107,8 @@
     pSelector->LateInit();
     pScrollPanel->AddControl (
         ::std::auto_ptr<TreeNode>(pSelector),
-        SdResId(STR_TASKPANEL_RECENT_MASTER_PAGES_TITLE));
+        SdResId(STR_TASKPANEL_RECENT_MASTER_PAGES_TITLE),
+        HID_SD_RECENT_MASTERS);

     // Create a panel with all available master pages.
     pSelector = new controls::AllMasterPagesSelector (
@@ -115,7 +119,8 @@
     pSelector->LateInit();
     pScrollPanel->AddControl (
         ::std::auto_ptr<TreeNode>(pSelector),
-        SdResId(STR_TASKPANEL_ALL_MASTER_PAGES_TITLE));
+        SdResId(STR_TASKPANEL_ALL_MASTER_PAGES_TITLE),
+        HID_SD_ALL_MASTERS);

     AddControl (::std::auto_ptr<TreeNode>(pScrollPanel));
 }


Update Explorer LOCAL_FIR settings

Update Explorer LOCAL_FIR settings

Move unmask of LOCAL_FIR[23] to exp_omi_init
Unmask LOCAL_FIR[31] during exp_omi_setup
Unmask LOCAL_FIR[32] during exp_omi_setup

Jira:MST-86
Zen:MST-1120
Change-Id: I32fc89abf84903737d3952ccfa57bc743cf1fec9
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/119144
Reviewed-by: STEPHEN GLANCY <7301c4b00f53e5772c2576cd0c5f485155c2ece1@us.ibm.com>
Tested-by: Jenkins Server <8e3f934e4c44875bc48d33da3ea13d93ba9a233f@us.ibm.com>
Reviewed-by: Daniel Melnikov <996bba866ef76500632a8843b7c8dde680dad83e@ibm.com>
Tested-by: FSP CI Jenkins <aa9e4d9ac7cd25905e9c0dd36d4150516e73dd86@us.ibm.com>
Tested-by: Hostboot CI <52521565bd8ea18a2b112942dce4f4220a97c2c8@us.ibm.com>
Dev-Ready: Louis Stermole <a2bef96d502debd02962600aef4d81d949c35039@us.ibm.com>
Reviewed-by: Edgar R Cordero <5d58db94b672b353c4d1fd75b5b35c7e02ea3071@us.ibm.com>
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/119151
Tested-by: Jenkins OP Build CI <e610bd72261d3c0a48f1e8ae36832ab00774d426@us.ibm.com>
Tested-by: Jenkins OP HW <0eb0fff262f74a65a832afbcc7b153e391c9a3fd@us.ibm.com>
Tested-by: Jenkins Combined Simics CI <8312af3886dfc9bb930f549023677220805b137e@us.ibm.com>
Reviewed-by: Nicholas E Bofferding <fb8db48116bc8a69e29dd8cdb037246f232f4af5@us.ibm.com>

--- src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/fir/exp_unmask.C
+++ src/import/chips/ocmb/explorer/procedures/hwp/memory/lib/fir/exp_unmask.C
@@ -262,6 +262,7 @@
              .recoverable_error<EXPLR_TP_MB_UNIT_TOP_LOCAL_FIR_IN1>()
              .recoverable_error<EXPLR_TP_MB_UNIT_TOP_LOCAL_FIR_IN2>()
              .recoverable_error<EXPLR_TP_MB_UNIT_TOP_LOCAL_FIR_IN8>()
+             .recoverable_error<EXPLR_TP_MB_UNIT_TOP_LOCAL_FIR_PCS_GPBC_IRQ_112>()
              .recoverable_error<EXPLR_TP_MB_UNIT_TOP_LOCAL_FIR_IN63>()
              .write(), "Failed to write LOCAL FIR unmasks for %s", mss::c_str(i_target));

@@ -429,9 +430,10 @@
     // Write LOCAL_FIR register per Explorer unmask spec
     FAPI_TRY(l_exp_local_fir_reg.recoverable_error<EXPLR_TP_MB_UNIT_TOP_LOCAL_FIR_PCS_GPBC_IRQ_106>()
              .recoverable_error<EXPLR_TP_MB_UNIT_TOP_LOCAL_FIR_PCS_GPBC_IRQ_111>()
-             .recoverable_error<EXPLR_TP_MB_UNIT_TOP_LOCAL_FIR_PCS_GPBC_IRQ_112>()
              .recoverable_error<EXPLR_TP_MB_UNIT_TOP_LOCAL_FIR_PROC_SS__TOP_FATAL>()
              .recoverable_error<EXPLR_TP_MB_UNIT_TOP_LOCAL_FIR_PROC_SS__TOP_NON_FATAL>()
+             .recoverable_error<EXPLR_TP_MB_UNIT_TOP_LOCAL_FIR_OCMB_DOORBELL_INT_3>()
+             .recoverable_error<EXPLR_TP_MB_UNIT_TOP_LOCAL_FIR_OCMB_DOORBELL_INT_2>()
              .recoverable_error<EXPLR_TP_MB_UNIT_TOP_LOCAL_FIR_FOXHOUND_LANE_7__FATAL>()
              .recoverable_error<EXPLR_TP_MB_UNIT_TOP_LOCAL_FIR_FOXHOUND_LANE_6__FATAL>()
              .recoverable_error<EXPLR_TP_MB_UNIT_TOP_LOCAL_FIR_FOXHOUND_LANE_5__FATAL>()


comments

comments

--- src/vku.hpp
+++ src/vku.hpp
@@ -18,6 +18,8 @@
 #include <fstream>

 // derived from https://github.com/SaschaWillems/Vulkan
+//
+// Many thanks to Sascha, without who this would be a challenge!

 namespace vku {

@@ -55,6 +57,14 @@
   }
 };

+/// This resource class is the base class of most of the vku wrappers.
+/// It wraps a single Vulkan interface plus related interfaces.
+/// The primary Vulkan interface is castable to a Vulkan handle of various kinds.
+///
+/// Exactly one resource object "owns" the resource. I considered using reference counting,
+/// but the overhead is pretty rotten, I may return to this later.
+/// A downside of this is that you cannot put these objects in vectors.
+///
 template <class VulkanType, class ParentClass>
 class resource {
 public:
@@ -67,9 +77,8 @@
   resource(VkDevice dev) : dev_(dev), ownsResource(false) {
   }

-  /*resource(const resource &rhs) : value_(rhs.value_), ownsResource(false), dev_(rhs.dev_) {
-  }*/
-
+  // every resource is moveable transfering ownership of the
+  // object to the copy. The former owner loses ownership.
   void operator=(resource &&rhs) {
     clear();
     value_ = rhs.value_;
@@ -96,12 +105,15 @@
     value_ = nullptr; ownsResource = false;
   }
 private:
+  // resources have a value, a device and an ownership flag.
   VulkanType value_ = nullptr;
+  VkDevice dev_ = nullptr;
   bool ownsResource = false;
-  VkDevice dev_ = nullptr;
 };

+/// Device wrapper.
+/// This incorporates a VkDevice along with the physical device and a number of queues.
 class device {
 public:
   device() {


If a collection cannot be dropped during restore, truncate it.

--- arangod/RestHandler/RestReplicationHandler.cpp
+++ arangod/RestHandler/RestReplicationHandler.cpp
@@ -2193,12 +2193,12 @@
                                               errorMsg, 0.0);
       if (res == TRI_ERROR_FORBIDDEN) {
         // some collections must not be dropped
-
-        // instead, truncate them
-        // ...
-        // do a fanout to all shards and truncate them, use col and asyncreq.
-        // return res;
-        return res;
+        res = truncateCollectionOnCoordinator(dbName, name);
+        if (res != TRI_ERROR_NO_ERROR) {
+          errorMsg = "unable to truncate collection (dropping is forbidden): "+
+                     name;
+          return res;
+        }
       }

       if (res != TRI_ERROR_NO_ERROR) {


Return early from getsockopt when errno set

PiperOrigin-RevId: 278908334
Change-Id: Ibe2b5373910c29b47bec7f0831ca745c09246e8c

--- asylo/platform/host_call/trusted/host_calls.cc
+++ asylo/platform/host_call/trusted/host_calls.cc
@@ -1031,11 +1031,13 @@

   int result = output.next<int>();
   int klinux_errno = output.next<int>();
+  Extent opt_received = output.next();
+
   if (result == -1) {
     errno = FromkLinuxErrorNumber(klinux_errno);
-  }
-
-  Extent opt_received = output.next();
+    return -1;
+  }
+
   *optlen = opt_received.size();
   memcpy(optval, opt_received.data(), *optlen);
   return result;


Update MpCodecsPerformanceTest to work with latest changes in codecs.

git-svn-id: 5274dacc98e2a95d0b0452670772bfdffe61ca90@10572 a612230a-c5fa-0310-af8b-88eea846685b

--- sipXmediaLib/src/test/mp/MpCodecsPerformanceTest.cpp
+++ sipXmediaLib/src/test/mp/MpCodecsPerformanceTest.cpp
@@ -26,6 +26,26 @@
 #define ENCODED_FRAME_MAX_SIZE  (FRAME_SIZE*sizeof(MpAudioSample))
 /// Number of RTP packets to encode/decode.
 #define NUM_PACKETS_TO_TEST      3
+/// Maximum number of milliseconds in packet.
+#define MAX_PACKET_TIME          20
+/// Maximum number of samples in packet.
+#define MAX_PACKET_SAMPLES       (MAX_PACKET_TIME*SAMPLE_RATE)/1000
+
+// Setup codec paths..
+static UtlString sCodecPaths[] = {
+#ifdef WIN32
+                                  "bin",
+                                  "..\\bin",
+#elif __pingtel_on_posix__
+                                  "../../../../bin",
+                                  "../../../bin",
+#else
+#                                 error "Unknown platform"
+#endif
+                                  "."
+                                 };
+static size_t sNumCodecPaths = sizeof(sCodecPaths)/sizeof(sCodecPaths[0]);
+

 ///  Unit test for testing performance of supported codecs.
 class MpCodecsPerformanceTest : public CppUnit::TestCase
@@ -65,39 +85,54 @@
    void testCodecsPreformance()
    {
       MpCodecFactory  *pCodecFactory;
-      const UtlString *pCodecMimeTypes;
-      unsigned         codecMimeTypesNum;
+      const MppCodecInfoV1_1 **pCodecInfo;
+      unsigned         codecInfoNum;

       // Get/create codec factory
       pCodecFactory = MpCodecFactory::getMpCodecFactory();
       CPPUNIT_ASSERT(pCodecFactory != NULL);

       // Load all available codecs
-      CPPUNIT_ASSERT_EQUAL(OS_SUCCESS,
-                           pCodecFactory->loadAllDynCodecs(".", CODEC_PLUGINS_FILTER));
-
-      pCodecFactory->getMimeTypes(codecMimeTypesNum, (const UtlString*&)pCodecMimeTypes);
-      CPPUNIT_ASSERT(codecMimeTypesNum>0);
-
-      for (unsigned i=0; i<codecMimeTypesNum; i++)
+      size_t i;
+      for(i = 0; i < sNumCodecPaths; i++)
+      {
+         pCodecFactory->loadAllDynCodecs(sCodecPaths[i],
+                                         CODEC_PLUGINS_FILTER);
+      }
+
+      // Get list of loaded codecs
+      pCodecFactory->getCodecInfoArray(codecInfoNum, pCodecInfo);
+      CPPUNIT_ASSERT(codecInfoNum>0);
+
+      for (unsigned i=0; i<codecInfoNum; i++)
       {
          const char **pCodecFmtps;
          unsigned     codecFmtpsNum;
-         pCodecFactory->getCodecFmtps(pCodecMimeTypes[i], codecFmtpsNum, pCodecFmtps);
+         codecFmtpsNum = pCodecInfo[i]->fmtpsNum;
+         pCodecFmtps = pCodecInfo[i]->fmtps;
          if (codecFmtpsNum == 0)
          {
-            testOneCodecPreformance(pCodecFactory, pCodecMimeTypes[i], "");
+            testOneCodecPreformance(pCodecFactory,
+                                    pCodecInfo[i]->mimeSubtype,
+                                    "",
+                                    pCodecInfo[i]->sampleRate,
+                                    pCodecInfo[i]->numChannels);
          }
          else
          {
-            for (int fmtpNum=0; fmtpNum<codecFmtpsNum; fmtpNum++)
+            for (unsigned fmtpNum=0; fmtpNum<codecFmtpsNum; fmtpNum++)
             {
                testOneCodecPreformance(pCodecFactory,
-                                       pCodecMimeTypes[i],
-                                       pCodecFmtps[fmtpNum]);
+                                       pCodecInfo[i]->mimeSubtype,
+                                       pCodecFmtps[fmtpNum],
+                                       pCodecInfo[i]->sampleRate,
+                                       pCodecInfo[i]->numChannels);
             }
          }
       }
+
+      // Free codec factory
+      MpCodecFactory::freeSingletonHandle();
    }

 protected:
@@ -115,6 +150,7 @@
       MpAudioSample  pOriginal[FRAME_SIZE];
       MpAudioSample  pDecoded[DECODED_FRAME_MAX_SIZE];
       int            encodeFrameNum = 0;
+      int            codecFrameSamples;

       // Create and initialize decoder and encoder
       CPPUNIT_ASSERT_EQUAL(OS_SUCCESS,
@@ -131,13 +167,29 @@
          return;
       }
       CPPUNIT_ASSERT_EQUAL(OS_SUCCESS,
-                           pCodecFactory->createEncoder(codecMime, codecFmtp, 0, pEncoder));
+                           pCodecFactory->createEncoder(codecMime, codecFmtp,
+                                                        sampleRate, numChannels,
+                                                        0, pEncoder));
       CPPUNIT_ASSERT_EQUAL(OS_SUCCESS,
                            pEncoder->initEncode());

+      // Get number of samples we'll pack to get one packet
+      if (pEncoder->getInfo()->getCodecType() == CODEC_TYPE_FRAME_BASED)
+      {
+         codecFrameSamples = pEncoder->getInfo()->getNumSamplesPerFrame();
+      }
+      else if (pEncoder->getInfo()->getCodecType() == CODEC_TYPE_SAMPLE_BASED)
+      {
+         codecFrameSamples = FRAME_SIZE;
+      }
+      else
+      {
+         assert(!"Unknown codec type!");
+      }
+
+
       for (int i=0; i<NUM_PACKETS_TO_TEST; i++)
       {
-         int            maxBytesPerPacket = (pEncoder->getInfo()->getMaxPacketBits() + 7) / 8;
          int            tmpSamplesConsumed;
          int            tmpEncodedSize;
          UtlBoolean     tmpSendNow;
@@ -178,7 +230,8 @@
             samplesInPacket += tmpSamplesConsumed;
             CPPUNIT_ASSERT(payloadSize <= ENCODED_FRAME_MAX_SIZE);
             encodeFrameNum++;
-         } while(! ((tmpSendNow == TRUE) || (maxBytesPerPacket == payloadSize)));
+         } while( (tmpSendNow != TRUE) &&
+                  (samplesInPacket+codecFrameSamples <= MAX_PACKET_SAMPLES));
          pRtpPacket->setPayloadSize(payloadSize);

          // Decode frame, measure time and verify, that we decoded same number of samples.


fix the windows build

fix the windows build

--- src/compiler/rewriter/rules/expand_index_rule.cpp
+++ src/compiler/rewriter/rules/expand_index_rule.cpp
@@ -78,7 +78,7 @@
       expr_t insert_index_uri(new const_expr(fo->get_loc(), uri_item));
       index_insert_args.push_back(insert_index_uri);

-      expr_t insert_index_var(new wrapper_expr(fo->get_loc(), newdot));
+      expr_t insert_index_var(new wrapper_expr(fo->get_loc(), newdot.getp()));
       index_insert_args.push_back(insert_index_var);

       const std::vector<expr_t>& idx_fields(vi->getIndexFieldExpressions());


Another alignment

Another alignment

--- src/core/ext/filters/client_channel/subchannel.cc
+++ src/core/ext/filters/client_channel/subchannel.cc
@@ -1006,7 +1006,7 @@
   grpc_channel_stack* chanstk = subchannel_call->connection->channel_stack();
   return (char*)subchannel_call +
          GPR_ROUND_UP_TO_ALIGNMENT_SIZE(sizeof(grpc_subchannel_call)) +
-         chanstk->call_stack_size;
+         GPR_ROUND_UP_TO_ALIGNMENT_SIZE(chanstk->call_stack_size);
 }

 grpc_call_stack* grpc_subchannel_call_get_call_stack(


evqlctl cluster-remove-server help message typo

--- src/eventql/cli/commands/cluster_remove_server.cc
+++ src/eventql/cli/commands/cluster_remove_server.cc
@@ -134,7 +134,7 @@

   stdout_os->write(
       "Usage: evqlctl cluster-remove-server [OPTIONS]\n"
-      "  --server_name            The name of the server to add.\n"
+      "  --server_name            The name of the server to remove.\n"
       "  --soft                   Enable the soft-leave operation.\n"
       "  --hard                   Enable the hard-leave operation.\n");
 }


fastuidraw/painter/packing: for-loop style cleanups

Change-Id: Ic939a523267e451f6ec234e81dc3885da75aecb7

--- src/fastuidraw/painter/packing/painter_packer.cpp
+++ src/fastuidraw/painter/packing/painter_packer.cpp
@@ -1069,11 +1069,10 @@
     }

   d->m_backend->on_pre_draw(d->m_surface, d->m_clear_color_buffer);
-  for(std::vector<per_draw_command>::iterator iter = d->m_accumulated_draws.begin(),
-        end = d->m_accumulated_draws.end(); iter != end; ++iter)
-    {
-      FASTUIDRAWassert(iter->m_draw_command->unmapped());
-      iter->m_draw_command->draw();
+  for(per_draw_command &cmd : d->m_accumulated_draws)
+    {
+      FASTUIDRAWassert(cmd.m_draw_command->unmapped());
+      cmd.m_draw_command->draw();
     }
   d->m_backend->on_post_draw();
   d->m_accumulated_draws.clear();


Fixes a silly bug in the CC32xx eeprom emulation.

--- src/freertos_drivers/ti/CC32xxEEPROMEmulation.cxx
+++ src/freertos_drivers/ti/CC32xxEEPROMEmulation.cxx
@@ -31,6 +31,10 @@
  * @date 30 December 2016
  */

+//#define LOGLEVEL VERBOSE
+
+#include "utils/logging.h"
+
 #include "freertos_drivers/ti/CC32xxEEPROMEmulation.hxx"
 #include "freertos_drivers/ti/CC32xxHelper.hxx"
 #include "fs.h"
@@ -59,26 +63,32 @@
         int handle = open_file(sector, FS_MODE_OPEN_READ, true);
         if (handle < 0)
         {
+            LOG(VERBOSE, "EEPROM: sector %u: could not open.", sector);
             continue;
         }
         unsigned b = 0xaa55aaaa;
         SlCheckResult(sl_FsRead(handle, 0, (uint8_t *)&b, 4), 4);
         sl_FsClose(handle, nullptr, nullptr, 0);
+        LOG(VERBOSE, "EEPROM: sector %u: version %u.", sector, b);
         if (b >= fileVersion_)
         {
             readSector_ = sector;
+            fileVersion_ = b;
             have_rot = true;
         }
     }

     if (have_rot)
     {
+        LOG(VERBOSE, "EEPROM: read sector %u:", readSector_);
         int handle = open_file(readSector_, FS_MODE_OPEN_READ);
         int ret = sl_FsRead(handle, 4, data_, file_size());
         if (ret < 0)
         {
             SlCheckResult(ret);
         }
+    } else {
+        LOG(VERBOSE, "EEPROM: no read sector");
     }
 }

@@ -96,6 +106,7 @@
     ++readSector_;
     if (readSector_ >= SECTOR_COUNT)
         readSector_ = 0;
+    LOG(VERBOSE, "EEPROM: write sector %u version %u", readSector_, fileVersion_);
     int handle = open_file(readSector_, FS_MODE_OPEN_WRITE, true);
     if (handle < 0)
     {
@@ -128,12 +139,12 @@
     unsigned int index, const void *buf, size_t len)
 {
     // Boundary checks are performed by the EEPROM class.
-    if (isDirty_ || (memcmp(data_ + index, buf, len) != 0))
-    {
-        isDirty_ = 1;
-        memcpy(data_ + index, buf, len);
-        eeprom_updated_notification();
+    if (memcmp(data_ + index, buf, len) == 0) {
+        return;
     }
+    memcpy(data_ + index, buf, len);
+    isDirty_ = 1;
+    eeprom_updated_notification();
 }

 void CC32xxEEPROMEmulation::read(unsigned int index, void *buf, size_t len)


More sensible fallback values for "base" & friends

When setting up the values of special properties like "base", "outer"
and "original", we replaced invalid and undefined values with an empty
array. This is all nice and well for array properties (so that people
can write "base.concat()" without checking base first), but quite absurd
for scalar properties. So for the latter, the only thing we do now is
replace invalid values with undefined ones. The behavior for arrays
stays the same.

Change-Id: Icb3c74927c84025a07e3ef6c9c67b89d95320632
Reviewed-by: Jake Petroules <2d627e1cecd5435752fa500bacbe05f7cc90c369@qt.io>
Reviewed-by: Joerg Bornemann <47777b9406dbddd02a3fdca8341789a013805a11@qt.io>

--- src/lib/corelib/language/evaluatorscriptclass.cpp
+++ src/lib/corelib/language/evaluatorscriptclass.cpp
@@ -98,13 +98,19 @@
     {
         if (!extraScope->isObject())
             *extraScope = scriptClass->engine()->newObject();
-        if (!scriptValue.isValid() || scriptValue.isUndefined()) {
-            // If there's no such value, use an empty array to have the convenience property
-            // still available.
-            extraScope->setProperty(conveniencePropertyName, engine->newArray());
-        } else {
-            extraScope->setProperty(conveniencePropertyName, scriptValue);
-        }
+        const PropertyDeclaration::Type type
+                = itemOfProperty->propertyDeclaration(propertyName->toString()).type();
+        const bool isArray = type == PropertyDeclaration::StringList
+                || type == PropertyDeclaration::PathList
+                || type == PropertyDeclaration::Variant;
+        QScriptValue valueToSet = scriptValue;
+        if (isArray) {
+            if (!valueToSet.isValid() || valueToSet.isUndefined())
+                valueToSet = engine->newArray();
+        } else if (!valueToSet.isValid()) {
+            valueToSet = engine->undefinedValue();
+        }
+        extraScope->setProperty(conveniencePropertyName, valueToSet);
     }

     void pushScope(const QScriptValue &scope)


Fix wrong flag value

Fix wrong flag value

--- src/libidaten/cuda/cudaLayeredTextureResource.cpp
+++ src/libidaten/cuda/cudaLayeredTextureResource.cpp
@@ -63,7 +63,7 @@
             tex_desc.filterMode = cudaFilterModePoint;
             tex_desc.addressMode[0] = cudaAddressModeWrap;
             tex_desc.addressMode[1] = cudaAddressModeWrap;
-            tex_desc.normalizedCoords = 0;
+            tex_desc.normalizedCoords = true;

             checkCudaErrors(cudaCreateTextureObject(&m_tex, &m_resDesc, &tex_desc, nullptr));
         }


C++14で書き直した

C++14で書き直した

--- src/mabinogi_roulette_MC/mabinogi_roulette_mc.cpp
+++ src/mabinogi_roulette_MC/mabinogi_roulette_mc.cpp
@@ -181,7 +181,7 @@
         fillnum.reserve(ROWCOLUMNSIZE);

         // その時点で埋まっているマスを計算するためのラムダ式
-        auto const sum = [](const std::vector< mypair > & vec)
+        auto const sum = [](auto const & vec)
         {
             auto cnt = 0;
             for (auto & e : vec) {


windows now resize upon request

windows now resize upon request

--- Berlin/modules/Desktop/WindowImpl.cc
+++ Berlin/modules/Desktop/WindowImpl.cc
@@ -23,6 +23,7 @@
 #include "Desktop/WindowImpl.hh"
 #include <Berlin/Vertex.hh>
 #include <Prague/Sys/Tracer.hh>
+#include <Warsaw/IO.hh>

 using namespace Prague;

@@ -165,9 +166,21 @@
   unmapper->_dispose();
 }

-// void WindowImpl::needResize()
-// {
-// }
+void WindowImpl::needResize()
+{
+  Trace trace("WindowImpl::needResize");
+  Vertex size = handle->size();
+  Graphic::Requisition r;
+  request(r);
+  if (r.x.minimum <= size.x && r.x.maximum >= size.x && r.y.minimum <= size.y && r.y.maximum >= size.y)
+    needRedraw();
+  else
+    {
+      size.x = min(r.x.maximum, max(r.x.minimum, size.x));
+      size.y = min(r.y.maximum, max(r.y.minimum, size.y));
+      handle->size(size);
+    }
+}

 /*


Delete CJ2015-QUALITIFICATION-B.cpp

Delete CJ2015-QUALITIFICATION-B.cpp

--- CodeJam/CJ2015-QUALITIFICATION-B.cpp
+++ CodeJam/CJ2015-QUALITIFICATION-B.cpp
@@ -1,9 +0,0 @@
-#include <bits/stdc++.h>
-using namespace std;
-
-int  T;
-int main(){
-    int i, j;
-
-    return 0;
-}


[net_processing] Add thread safety annotations

--- src/net_processing.cpp
+++ src/net_processing.cpp
@@ -78,7 +78,7 @@
 void EraseOrphansFor(NodeId peer);

 /** Increase a node's misbehavior score. */
-void Misbehaving(NodeId nodeid, int howmuch, const std::string& message="");
+void Misbehaving(NodeId nodeid, int howmuch, const std::string& message="") EXCLUSIVE_LOCKS_REQUIRED(cs_main);

 /** Average delay between local address broadcasts in seconds. */
 static constexpr unsigned int AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL = 24 * 60 * 60;
@@ -98,22 +98,20 @@
 // Internal stuff
 namespace {
     /** Number of nodes with fSyncStarted. */
-    int nSyncStarted = 0;
+    int nSyncStarted GUARDED_BY(cs_main) = 0;

     /**
      * Sources of received blocks, saved to be able to send them reject
-     * messages or ban them when processing happens afterwards. Protected by
-     * cs_main.
+     * messages or ban them when processing happens afterwards.
      * Set mapBlockSource[hash].second to false if the node should not be
      * punished if the block is invalid.
      */
-    std::map<uint256, std::pair<NodeId, bool>> mapBlockSource;
+    std::map<uint256, std::pair<NodeId, bool>> mapBlockSource GUARDED_BY(cs_main);

     /**
      * Filter for transactions that were recently rejected by
      * AcceptToMemoryPool. These are not rerequested until the chain tip
-     * changes, at which point the entire filter is reset. Protected by
-     * cs_main.
+     * changes, at which point the entire filter is reset.
      *
      * Without this filter we'd be re-requesting txs from each of our peers,
      * increasing bandwidth consumption considerably. For instance, with 100
@@ -129,17 +127,17 @@
      *
      * Memory used: 1.3 MB
      */
-    std::unique_ptr<CRollingBloomFilter> recentRejects;
-    uint256 hashRecentRejectsChainTip;
-
-    /** Blocks that are in flight, and that are in the queue to be downloaded. Protected by cs_main. */
+    std::unique_ptr<CRollingBloomFilter> recentRejects GUARDED_BY(cs_main);
+    uint256 hashRecentRejectsChainTip GUARDED_BY(cs_main);
+
+    /** Blocks that are in flight, and that are in the queue to be downloaded. */
     struct QueuedBlock {
         uint256 hash;
         const CBlockIndex* pindex;                               //!< Optional.
         bool fValidatedHeaders;                                  //!< Whether this block has validated headers at the time of request.
         std::unique_ptr<PartiallyDownloadedBlock> partialBlock;  //!< Optional, used for CMPCTBLOCK downloads
     };
-    std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> > mapBlocksInFlight;
+    std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> > mapBlocksInFlight GUARDED_BY(cs_main);

     /** peercoin: blocks that are waiting to be processed, the key points to previous CBlockIndex entry */
     struct WaitElement {
@@ -149,25 +147,25 @@
     std::map<CBlockIndex*, WaitElement> mapBlocksWait;

     /** Stack of nodes which we have set to announce using compact blocks */
-    std::list<NodeId> lNodesAnnouncingHeaderAndIDs;
+    std::list<NodeId> lNodesAnnouncingHeaderAndIDs GUARDED_BY(cs_main);

     /** Number of preferable block download peers. */
-    int nPreferredDownload = 0;
+    int nPreferredDownload GUARDED_BY(cs_main) = 0;

     /** Number of peers from which we're downloading blocks. */
-    int nPeersWithValidatedDownloads = 0;
+    int nPeersWithValidatedDownloads GUARDED_BY(cs_main) = 0;

     /** Number of outbound peers with m_chain_sync.m_protect. */
-    int g_outbound_peers_with_protect_from_disconnect = 0;
+    int g_outbound_peers_with_protect_from_disconnect GUARDED_BY(cs_main) = 0;

     /** When our tip was last updated. */
     std::atomic<int64_t> g_last_tip_update(0);

-    /** Relay map, protected by cs_main. */
+    /** Relay map */
     typedef std::map<uint256, CTransactionRef> MapRelay;
-    MapRelay mapRelay;
-    /** Expiration-time ordered list of (expire time, relay map entry) pairs, protected by cs_main). */
-    std::deque<std::pair<int64_t, MapRelay::iterator>> vRelayExpiration;
+    MapRelay mapRelay GUARDED_BY(cs_main);
+    /** Expiration-time ordered list of (expire time, relay map entry) pairs. */
+    std::deque<std::pair<int64_t, MapRelay::iterator>> vRelayExpiration GUARDED_BY(cs_main);

     std::atomic<int64_t> nTimeBestReceived(0); // Used only to inform the wallet of when we last received a block

@@ -311,18 +309,17 @@
     }
 };

-/** Map maintaining per-node state. Requires cs_main. */
-static std::map<NodeId, CNodeState> mapNodeState;
-
-// Requires cs_main.
-static CNodeState *State(NodeId pnode) {
+/** Map maintaining per-node state. */
+static std::map<NodeId, CNodeState> mapNodeState GUARDED_BY(cs_main);
+
+static CNodeState *State(NodeId pnode) EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
     std::map<NodeId, CNodeState>::iterator it = mapNodeState.find(pnode);
     if (it == mapNodeState.end())
         return nullptr;
     return &it->second;
 }

-static void UpdatePreferredDownload(CNode* node, CNodeState* state)
+static void UpdatePreferredDownload(CNode* node, CNodeState* state) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 {
     nPreferredDownload -= state->fPreferredDownload;

@@ -353,10 +350,9 @@
     }
 }

-// Requires cs_main.
 // Returns a bool indicating whether we requested this block.
 // Also used if a block was /not/ received and timed out or started with another peer
-static bool MarkBlockAsReceived(const uint256& hash) {
+static bool MarkBlockAsReceived(const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
     std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> >::iterator itInFlight = mapBlocksInFlight.find(hash);
     if (itInFlight != mapBlocksInFlight.end()) {
         CNodeState *state = State(itInFlight->second.first);
@@ -379,10 +375,9 @@
     return false;
 }

-// Requires cs_main.
 // returns false, still setting pit, if the block was already in flight from the same peer
 // pit will only be valid as long as the same cs_main lock is being held
-static bool MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, const CBlockIndex* pindex = nullptr, std::list<QueuedBlock>::iterator** pit = nullptr) {
+static bool MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, const CBlockIndex* pindex = nullptr, std::list<QueuedBlock>::iterator** pit = nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
     CNodeState *state = State(nodeid);
     assert(state != nullptr);

@@ -416,7 +411,7 @@
 }

 /** Check whether the last unknown block a peer advertised is not yet known. */
-static void ProcessBlockAvailability(NodeId nodeid) {
+static void ProcessBlockAvailability(NodeId nodeid) EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
     CNodeState *state = State(nodeid);
     assert(state != nullptr);

@@ -432,7 +427,7 @@
 }

 /** Update tracking information about which blocks a peer is assumed to have. */
-static void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) {
+static void UpdateBlockAvailability(NodeId nodeid, const uint256 &hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
     CNodeState *state = State(nodeid);
     assert(state != nullptr);

@@ -456,7 +451,8 @@
  * lNodesAnnouncingHeaderAndIDs, and keeping that list under a certain size by
  * removing the first element if necessary.
  */
-static void MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid, CConnman* connman) {
+static void MaybeSetPeerAsAnnouncingHeaderAndIDs(NodeId nodeid, CConnman* connman)
+{
     AssertLockHeld(cs_main);
     CNodeState* nodestate = State(nodeid);
     if (!nodestate || !nodestate->fSupportsDesiredCmpctVersion) {
@@ -472,11 +468,13 @@
             }
         }
         connman->ForNode(nodeid, [connman](CNode* pfrom){
+            AssertLockHeld(cs_main);
             uint64_t nCMPCTBLOCKVersion = (pfrom->GetLocalServices() & NODE_WITNESS) ? 2 : 1;
             if (lNodesAnnouncingHeaderAndIDs.size() >= 3) {
                 // As per BIP152, we only get 3 of our peers to announce
                 // blocks using compact encodings.
                 connman->ForNode(lNodesAnnouncingHeaderAndIDs.front(), [connman, nCMPCTBLOCKVersion](CNode* pnodeStop){
+                    AssertLockHeld(cs_main);
                     connman->PushMessage(pnodeStop, CNetMsgMaker(pnodeStop->GetSendVersion()).Make(NetMsgType::SENDCMPCT, /*fAnnounceUsingCMPCTBLOCK=*/false, nCMPCTBLOCKVersion));
                     return true;
                 });
@@ -489,7 +487,7 @@
     }
 }

-static bool TipMayBeStale(const Consensus::Params &consensusParams)
+static bool TipMayBeStale(const Consensus::Params &consensusParams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 {
     AssertLockHeld(cs_main);
     if (g_last_tip_update == 0) {
@@ -498,14 +496,12 @@
     return g_last_tip_update < GetTime() - consensusParams.nPowTargetSpacing * 3 && mapBlocksInFlight.empty();
 }

-// Requires cs_main
-static bool CanDirectFetch(const Consensus::Params &consensusParams)
+static bool CanDirectFetch(const Consensus::Params &consensusParams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 {
     return chainActive.Tip()->GetBlockTime() > GetAdjustedTime() - consensusParams.nPowTargetSpacing * 20;
 }

-// Requires cs_main
-static bool PeerHasHeader(CNodeState *state, const CBlockIndex *pindex)
+static bool PeerHasHeader(CNodeState *state, const CBlockIndex *pindex) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 {
     if (state->pindexBestKnownBlock && pindex == state->pindexBestKnownBlock->GetAncestor(pindex->nHeight))
         return true;
@@ -516,7 +512,8 @@

 /** Update pindexLastCommonBlock and add not-in-flight missing successors to vBlocks, until it has
  *  at most count entries. */
-static void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vector<const CBlockIndex*>& vBlocks, NodeId& nodeStaller, const Consensus::Params& consensusParams) {
+static void FindNextBlocksToDownload(NodeId nodeid, unsigned int count, std::vector<const CBlockIndex*>& vBlocks, NodeId& nodeStaller, const Consensus::Params& consensusParams) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
+{
     if (count == 0)
         return;

@@ -806,10 +803,8 @@

 /**
  * Mark a misbehaving peer to be banned depending upon the value of `-banscore`.
- *
- * Requires cs_main.
  */
-void Misbehaving(NodeId pnode, int howmuch, const std::string& message)
+void Misbehaving(NodeId pnode, int howmuch, const std::string& message) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 {
     if (howmuch == 0)
         return;
@@ -907,10 +902,10 @@

 // All of the following cache a recent block, and are protected by cs_most_recent_block
 static CCriticalSection cs_most_recent_block;
-static std::shared_ptr<const CBlock> most_recent_block;
-static std::shared_ptr<const CBlockHeaderAndShortTxIDs> most_recent_compact_block;
-static uint256 most_recent_block_hash;
-static bool fWitnessesPresentInMostRecentCompactBlock;
+static std::shared_ptr<const CBlock> most_recent_block GUARDED_BY(cs_most_recent_block);
+static std::shared_ptr<const CBlockHeaderAndShortTxIDs> most_recent_compact_block GUARDED_BY(cs_most_recent_block);
+static uint256 most_recent_block_hash GUARDED_BY(cs_most_recent_block);
+static bool fWitnessesPresentInMostRecentCompactBlock GUARDED_BY(cs_most_recent_block);

 /**
  * Maintain state about the best-seen block and fast-announce a compact block
@@ -940,6 +935,8 @@
     }

     connman->ForEachNode([this, &pcmpctblock, pindex, &msgMaker, fWitnessEnabled, &hashBlock](CNode* pnode) {
+        AssertLockHeld(cs_main);
+
         // TODO: Avoid the repeated-serialization here
         if (pnode->nVersion < INVALID_CB_NO_BAN_VERSION || pnode->fDisconnect)
             return;
@@ -1340,7 +1337,7 @@
     }
 }

-static uint32_t GetFetchFlags(CNode* pfrom) {
+static uint32_t GetFetchFlags(CNode* pfrom) EXCLUSIVE_LOCKS_REQUIRED(cs_main) {
     uint32_t nFetchFlags = 0;
     if ((pfrom->GetLocalServices() & NODE_WITNESS) && State(pfrom->GetId())->fHaveWitness) {
         nFetchFlags |= MSG_WITNESS_FLAG;
@@ -3382,6 +3379,8 @@
         LOCK(cs_main);

         connman->ForEachNode([&](CNode* pnode) {
+            AssertLockHeld(cs_main);
+
             // Ignore non-outbound peers, or nodes marked for disconnect already
             if (!IsOutboundDisconnectionCandidate(pnode) || pnode->fDisconnect) return;
             CNodeState *state = State(pnode->GetId());
@@ -3395,6 +3394,8 @@
         });
         if (worst_peer != -1) {
             bool disconnected = connman->ForNode(worst_peer, [&](CNode *pnode) {
+                AssertLockHeld(cs_main);
+
                 // Only disconnect a peer that has been connected to us for
                 // some reasonable fraction of our check-frequency, to give
                 // it time for new information to have arrived.


fix in non-const operator[], where the return value may be used as an lvalue,
set fLast and call Changed(). If you want to access array elements and not
invalidate the sorting, use At() or UncheckedAt().

git-svn-id: acec3fd5b7ea1eb9e79d6329d318e8118ee2e14f@21035 27541ba8-7e3a-0410-8455-c3a389f83636

--- cont/src/TObjArray.cxx
+++ cont/src/TObjArray.cxx
@@ -104,7 +104,11 @@
    // if i is out of bounds. Result may be used as an lvalue.

    int j = i-fLowerBound;
-   if (j >= 0 && j < fSize) return fCont[j];
+   if (j >= 0 && j < fSize) {
+      fLast = TMath::Max(j, GetAbsLast());
+      Changed();
+      return fCont[j];
+   }
    BoundsOk("operator[]", i);
    fLast = -2; // invalidate fLast since the result may be used as an lvalue
    return fCont[0];
@@ -790,4 +794,3 @@
    else
       fCursor = fArray->Capacity() - 1;
 }
-


Fix IS-locks sync via `mempool` p2p command (#3766)

--- src/net_processing.cpp
+++ src/net_processing.cpp
@@ -4158,8 +4158,8 @@
                     CInv islockInv(MSG_ISLOCK, islockHash);
                     pto->filterInventoryKnown.insert(islockHash);

-                    LogPrint(BCLog::NET, "SendMessages -- queued inv: %s  index=%d peer=%d\n", inv.ToString(), vInv.size(), pto->GetId());
-                    vInv.push_back(inv);
+                    LogPrint(BCLog::NET, "SendMessages -- queued inv: %s  index=%d peer=%d\n", islockInv.ToString(), vInv.size(), pto->GetId());
+                    vInv.push_back(islockInv);
                     if (vInv.size() == MAX_INV_SZ) {
                         LogPrint(BCLog::NET, "SendMessages -- pushing inv's: count=%d peer=%d\n", vInv.size(), pto->GetId());
                         connman->PushMessage(pto, msgMaker.Make(NetMsgType::INV, vInv));


rename model change event in cmd line app

--- src/ui/cmdline/main.cc
+++ src/ui/cmdline/main.cc
@@ -46,14 +46,14 @@
         return ss.str();
     }

-    void on_view_item_change(kopsik_api_result result,
+    void on_model_change(kopsik_api_result result,
             char *err_string,
             int unsigned err_len,
             KopsikModelChange *change) {
         if (KOPSIK_API_SUCCESS != result) {
             std::string err("");
             err.append(err_string, err_len);
-            std::cerr << "on_view_item_change error! "
+            std::cerr << "on_model_change error! "
                 << err << std::endl;
             free(err_string);
             return;
@@ -198,7 +198,7 @@

         if ("listen" == args[0]) {
             std::cout << "Listening to websocket.. " << std::endl;
-            kopsik_set_change_callback(ctx, on_view_item_change);
+            kopsik_set_change_callback(ctx, on_model_change);
             if (KOPSIK_API_SUCCESS != kopsik_websocket_start(ctx, err, ERRLEN)) {
                 std::cerr << "Error starting websocket: "
                     << err << std::endl;


Add wtxids to recentRejects instead of txids

Previously, we only added txids to recentRejects if we were sure that the
transaction couldn't have had the wrong witness (either because the witness was
malleated or stripped).

In preparation for wtxid-based relay, we can observe that txid == wtxid for
transactions that have no witness, and add the wtxid of rejected transactions,
provided the transaction wasn't a witness-stripped one. This means that we now
add more data to the filter (as prior to this commit, any transaction with a
witness that failed to be accepted was being skipped for inclusion in the
filter) but witness malleation should still not interfere with relay of a valid
segwit transaction, because the txid of a segwit transaction would not be added
to the filter after failing validation.

In the future, having wtxids in the recent rejects filter will allow us to
skip downloading the same wtxid multiple times, once our peers use wtxids for
transaction relay.

--- src/net_processing.cpp
+++ src/net_processing.cpp
@@ -2005,12 +2005,12 @@
             // Has inputs but not accepted to mempool
             // Probably non-standard or insufficient fee
             LogPrint(BCLog::MEMPOOL, "   removed orphan tx %s\n", orphanHash.ToString());
-            if (!orphanTx.HasWitness() && orphan_state.GetResult() != TxValidationResult::TX_WITNESS_MUTATED) {
+            if (orphanTx.HasWitness() || orphan_state.GetResult() != TxValidationResult::TX_WITNESS_MUTATED) {
                 // Do not use rejection cache for witness transactions or
                 // witness-stripped transactions, as they can have been malleated.
                 // See https://github.com/bitcoin/bitcoin/issues/8279 for details.
                 assert(recentRejects);
-                recentRejects->insert(orphanHash);
+                recentRejects->insert(orphanTx.GetWitnessHash());
             }
             EraseOrphanTx(orphanHash);
             done = true;
@@ -2908,14 +2908,15 @@
                 // We will continue to reject this tx since it has rejected
                 // parents so avoid re-requesting it from other peers.
                 recentRejects->insert(tx.GetHash());
+                recentRejects->insert(tx.GetWitnessHash());
             }
         } else {
-            if (!tx.HasWitness() && state.GetResult() != TxValidationResult::TX_WITNESS_MUTATED) {
+            if (tx.HasWitness() || state.GetResult() != TxValidationResult::TX_WITNESS_MUTATED) {
                 // Do not use rejection cache for witness transactions or
                 // witness-stripped transactions, as they can have been malleated.
                 // See https://github.com/bitcoin/bitcoin/issues/8279 for details.
                 assert(recentRejects);
-                recentRejects->insert(tx.GetHash());
+                recentRejects->insert(tx.GetWitnessHash());
                 if (RecursiveDynamicUsage(*ptx) < 100000) {
                     AddToCompactExtraTransactions(ptx);
                 }


ref #15 beautification

ref #15 beautification

--- source/Buffer.cpp
+++ source/Buffer.cpp
@@ -23,7 +23,6 @@
 : Object(id, ownsGLObject)
 , _target(target)
 {
-
 }

 GLuint Buffer::genBuffer()


Shard: Do not do autocommit during RESTORE

--- src/database/shard.cc
+++ src/database/shard.cc
@@ -677,12 +677,13 @@
 	L_CALL("Shard::autocommit({})", shard ? shard->__repr__() : "null");

 	if (
-		shard->database &&
-		!shard->is_transactional() &&
-		!shard->is_closed() &&
-		shard->is_modified() &&
-		shard->is_writable() &&
-		shard->is_local()
+		shard->database &&              // Autocommit only if there is a database
+		!shard->is_transactional() &&   // Autocommit only if there's no transaction active (like during replication)
+		!shard->is_closed() &&          // Autocommit only if database is not closed
+		shard->is_modified() &&         // Autocommit only modified databases
+		shard->is_writable() &&         // Autocommit only writable databases
+		shard->is_local() &&            // Autocommit only local databases
+		!shard->is_restore()            // Data RESTORE doesn't do autocommit
 	) {
 		// Auto commit only on modified writable databases
 		committer()->debounce(shard->endpoint, std::weak_ptr<Shard>(shard));


Rename configtest.h and move it to the 'inc' directory

--- test/configtest.cpp
+++ test/configtest.cpp
@@ -18,7 +18,7 @@
 #include <unistd.h>
 #include <stdio.h>
 #include <gtest/gtest.h>
-#include "configtest.hpp"
+#include "inc/configtest.hpp"

 #include "../inc/config.hpp"


Rewrite SetStartupFlags()

Rewrite SetStartupFlags()

This piece of code was so poorly written that I was scared to change it
in fear that it actually did some magic that I couldn't fathom.

Spoiler alert: it didn't.

--- src/ui/src/ui_main.cpp
+++ src/ui/src/ui_main.cpp
@@ -1369,50 +1369,26 @@

 void SetStartupFlags()
 {
-    int i, j;
-
-    i = 0;
-    j = 0;
-
-    while (List1[i])
-    {
+    for (int i = 0; List1[i]; ++i)
         if (stricmp(List1[i], gUBuffer) == 0)
-            j++;
-
-        i++;
-    }
-
-    if (j)
-        gUI_Tracking_Flag |= _UI_TRACK_FLAG00;
-
-    i = 0;
-    j = 0;
-
-    while (List2[i])
-    {
+        {
+            gUI_Tracking_Flag |= _UI_TRACK_FLAG00;
+            break;
+        }
+
+    for (int i = 0; List2[i]; ++i)
         if (stricmp(List2[i], gUBuffer) == 0)
-            j++;
-
-        i++;
-    }
-
-    if (j)
-        gUI_Tracking_Flag |= _UI_TRACK_FLAG01;
-
-    i = 0;
-    j = 0;
-
-    while (List3[i])
-    {
+        {
+            gUI_Tracking_Flag |= _UI_TRACK_FLAG01;
+            break;
+        }
+
+    for (int i = 0; List3[i]; ++i)
         if (stricmp(List3[i], gUBuffer) == 0)
-            j++;
-
-        i++;
-    }
-
-    if (j)
-        gUI_Tracking_Flag |= _UI_TRACK_FLAG02;
-
+        {
+            gUI_Tracking_Flag |= _UI_TRACK_FLAG02;
+            break;
+        }
 }

 void StartCommsQueue()


Replace LockAssertion with a proper thread safety annotations

Summary:
This is a backport of [[https://github.com/bitcoin/bitcoin/pull/19979 | core#19979]] [2/3]
https://github.com/bitcoin/bitcoin/pull/19979/commits/ab2a44297fd0796bf5797ae2a477e8e56d9c3c12

This partially revert D10161
Depends on D10171

Test Plan:
With TSAN:
`ninja all check-all`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D10172

--- src/net_processing.cpp
+++ src/net_processing.cpp
@@ -820,8 +820,9 @@
             return;
         }
     }
-    connman.ForNode(nodeid, [&connman](CNode *pfrom) {
-        LockAssertion lock(::cs_main);
+    connman.ForNode(nodeid, [&connman](CNode *pfrom) EXCLUSIVE_LOCKS_REQUIRED(
+                                ::cs_main) {
+        AssertLockHeld(::cs_main);
         uint64_t nCMPCTBLOCKVersion = 1;
         if (lNodesAnnouncingHeaderAndIDs.size() >= 3) {
             // As per BIP152, we only get 3 of our peers to announce
@@ -1665,29 +1666,32 @@
         most_recent_compact_block = pcmpctblock;
     }

-    m_connman.ForEachNode([this, &pcmpctblock, pindex, &msgMaker,
-                           &hashBlock](CNode *pnode) {
-        LockAssertion lock(::cs_main);
-
-        // TODO: Avoid the repeated-serialization here
-        if (pnode->GetCommonVersion() < INVALID_CB_NO_BAN_VERSION ||
-            pnode->fDisconnect) {
-            return;
-        }
-        ProcessBlockAvailability(pnode->GetId());
-        CNodeState &state = *State(pnode->GetId());
-        // If the peer has, or we announced to them the previous block already,
-        // but we don't think they have this one, go ahead and announce it.
-        if (state.fPreferHeaderAndIDs && !PeerHasHeader(&state, pindex) &&
-            PeerHasHeader(&state, pindex->pprev)) {
-            LogPrint(BCLog::NET, "%s sending header-and-ids %s to peer=%d\n",
-                     "PeerManager::NewPoWValidBlock", hashBlock.ToString(),
-                     pnode->GetId());
-            m_connman.PushMessage(
-                pnode, msgMaker.Make(NetMsgType::CMPCTBLOCK, *pcmpctblock));
-            state.pindexBestHeaderSent = pindex;
-        }
-    });
+    m_connman.ForEachNode(
+        [this, &pcmpctblock, pindex, &msgMaker,
+         &hashBlock](CNode *pnode) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
+            AssertLockHeld(::cs_main);
+
+            // TODO: Avoid the repeated-serialization here
+            if (pnode->GetCommonVersion() < INVALID_CB_NO_BAN_VERSION ||
+                pnode->fDisconnect) {
+                return;
+            }
+            ProcessBlockAvailability(pnode->GetId());
+            CNodeState &state = *State(pnode->GetId());
+            // If the peer has, or we announced to them the previous block
+            // already, but we don't think they have this one, go ahead and
+            // announce it.
+            if (state.fPreferHeaderAndIDs && !PeerHasHeader(&state, pindex) &&
+                PeerHasHeader(&state, pindex->pprev)) {
+                LogPrint(BCLog::NET,
+                         "%s sending header-and-ids %s to peer=%d\n",
+                         "PeerManager::NewPoWValidBlock", hashBlock.ToString(),
+                         pnode->GetId());
+                m_connman.PushMessage(
+                    pnode, msgMaker.Make(NetMsgType::CMPCTBLOCK, *pcmpctblock));
+                state.pindexBestHeaderSent = pindex;
+            }
+        });
 }

 /**
@@ -5023,8 +5027,9 @@
     NodeId worst_peer = -1;
     int64_t oldest_block_announcement = std::numeric_limits<int64_t>::max();

-    m_connman.ForEachNode([&](CNode *pnode) {
-        LockAssertion lock(::cs_main);
+    m_connman.ForEachNode([&](CNode *pnode) EXCLUSIVE_LOCKS_REQUIRED(
+                              ::cs_main) {
+        AssertLockHeld(::cs_main);

         // Ignore non-outbound peers, or nodes marked for disconnect already
         if (!pnode->IsOutboundOrBlockRelayConn() || pnode->fDisconnect) {
@@ -5056,31 +5061,33 @@
         return;
     }

-    bool disconnected = m_connman.ForNode(worst_peer, [&](CNode *pnode) {
-        LockAssertion lock(::cs_main);
-
-        // Only disconnect a peer that has been connected to us for some
-        // reasonable fraction of our check-frequency, to give it time for new
-        // information to have arrived.
-        // Also don't disconnect any peer we're trying to download a block from.
-        CNodeState &state = *State(pnode->GetId());
-        if (time_in_seconds - pnode->nTimeConnected > MINIMUM_CONNECT_TIME &&
-            state.nBlocksInFlight == 0) {
-            LogPrint(BCLog::NET,
-                     "disconnecting extra outbound peer=%d (last block "
-                     "announcement received at time %d)\n",
-                     pnode->GetId(), oldest_block_announcement);
-            pnode->fDisconnect = true;
-            return true;
-        } else {
-            LogPrint(BCLog::NET,
-                     "keeping outbound peer=%d chosen for eviction "
-                     "(connect time: %d, blocks_in_flight: %d)\n",
-                     pnode->GetId(), pnode->nTimeConnected,
-                     state.nBlocksInFlight);
-            return false;
-        }
-    });
+    bool disconnected = m_connman.ForNode(
+        worst_peer, [&](CNode *pnode) EXCLUSIVE_LOCKS_REQUIRED(::cs_main) {
+            AssertLockHeld(::cs_main);
+
+            // Only disconnect a peer that has been connected to us for some
+            // reasonable fraction of our check-frequency, to give it time for
+            // new information to have arrived. Also don't disconnect any peer
+            // we're trying to download a block from.
+            CNodeState &state = *State(pnode->GetId());
+            if (time_in_seconds - pnode->nTimeConnected >
+                    MINIMUM_CONNECT_TIME &&
+                state.nBlocksInFlight == 0) {
+                LogPrint(BCLog::NET,
+                         "disconnecting extra outbound peer=%d (last block "
+                         "announcement received at time %d)\n",
+                         pnode->GetId(), oldest_block_announcement);
+                pnode->fDisconnect = true;
+                return true;
+            } else {
+                LogPrint(BCLog::NET,
+                         "keeping outbound peer=%d chosen for eviction "
+                         "(connect time: %d, blocks_in_flight: %d)\n",
+                         pnode->GetId(), pnode->nTimeConnected,
+                         state.nBlocksInFlight);
+                return false;
+            }
+        });

     if (disconnected) {
         // If we disconnected an extra peer, that means we successfully


Allowed assignment a=b of PetscVector instances where a is parallel and b is ghosted.

git-svn-id: ffc1bc5b3feaf8644044862cc38c386ade156493@3867 434f946d-2f3d-0410-ba4c-cb9f52fb0dbf

--- src/numerics/petsc_vector.C
+++ src/numerics/petsc_vector.C
@@ -574,39 +574,54 @@
 {
   this->_restore_array();
   v._restore_array();
-  libmesh_assert (this->_type == v._type);
+
   libmesh_assert (this->size() == v.size());
   libmesh_assert (this->local_size() == v.local_size());
-  libmesh_assert (this->_global_to_local_map ==
-                  v._global_to_local_map);
-
   libmesh_assert (v.closed());
   this->_is_closed = true;

-  if (v.size() != 0)
-    {
-      int ierr = 0;
-      if(this->type() != GHOSTED)
+  int ierr = 0;
+
+  if((this->type()==PARALLEL) && (v.type()==GHOSTED))
+    {
+      /* Allow assignment of a ghosted to a parallel vector since this
+	 causes no difficulty.  See discussion in libmesh-devel of
+	 June 24, 2010.  */
+      ierr = VecCopy (v._vec, this->_vec);
+      CHKERRABORT(libMesh::COMM_WORLD,ierr);
+    }
+  else
+    {
+      /* In all other cases, we assert that both vectors are of equal
+	 type.  */
+      libmesh_assert (this->_type == v._type);
+      libmesh_assert (this->_global_to_local_map ==
+		      v._global_to_local_map);
+
+      if (v.size() != 0)
 	{
-	  ierr = VecCopy (v._vec, this->_vec);
-	  CHKERRABORT(libMesh::COMM_WORLD,ierr);
-	}
-      else
-	{
-	  Vec loc_vec;
-	  Vec v_loc_vec;
-	  ierr = VecGhostGetLocalForm (_vec,&loc_vec);
-	  CHKERRABORT(libMesh::COMM_WORLD,ierr);
-	  ierr = VecGhostGetLocalForm (v._vec,&v_loc_vec);
-	  CHKERRABORT(libMesh::COMM_WORLD,ierr);
-
-	  ierr = VecCopy (v_loc_vec, loc_vec);
-	  CHKERRABORT(libMesh::COMM_WORLD,ierr);
-
-	  ierr = VecGhostRestoreLocalForm (v._vec,&v_loc_vec);
-	  CHKERRABORT(libMesh::COMM_WORLD,ierr);
-	  ierr = VecGhostRestoreLocalForm (_vec,&loc_vec);
-	  CHKERRABORT(libMesh::COMM_WORLD,ierr);
+	  if(this->type() != GHOSTED)
+	    {
+	      ierr = VecCopy (v._vec, this->_vec);
+	      CHKERRABORT(libMesh::COMM_WORLD,ierr);
+	    }
+	  else
+	    {
+	      Vec loc_vec;
+	      Vec v_loc_vec;
+	      ierr = VecGhostGetLocalForm (_vec,&loc_vec);
+	      CHKERRABORT(libMesh::COMM_WORLD,ierr);
+	      ierr = VecGhostGetLocalForm (v._vec,&v_loc_vec);
+	      CHKERRABORT(libMesh::COMM_WORLD,ierr);
+
+	      ierr = VecCopy (v_loc_vec, loc_vec);
+	      CHKERRABORT(libMesh::COMM_WORLD,ierr);
+
+	      ierr = VecGhostRestoreLocalForm (v._vec,&v_loc_vec);
+	      CHKERRABORT(libMesh::COMM_WORLD,ierr);
+	      ierr = VecGhostRestoreLocalForm (_vec,&loc_vec);
+	      CHKERRABORT(libMesh::COMM_WORLD,ierr);
+	    }
 	}
     }


additional error message

additional error message

--- source/Canvas.cpp
+++ source/Canvas.cpp
@@ -93,7 +93,11 @@
 void Canvas::initializeGL(const QSurfaceFormat & format)
 {
     m_context->setFormat(format);
-    m_context->create();
+    if (!m_context->create())
+	{
+		qCritical() << "Errors during creation of OpenGL context.";
+		return;
+	}

     m_context->makeCurrent(this);
     if (!initializeOpenGLFunctions())


Bitcoin: 41a46cbb31f1622f7d1ff54c7a1c1ca701c1e754 (Speed up deriveaddresses for large ranges).

--- src/rpc/misc.cpp
+++ src/rpc/misc.cpp
@@ -672,8 +672,8 @@
         range_end = range.second;
     }

-    FlatSigningProvider provider;
-    auto desc = Parse(desc_str, provider, /* require_checksum = */ true);
+    FlatSigningProvider key_provider;
+    auto desc = Parse(desc_str, key_provider, /* require_checksum = */ true);
     if (!desc) {
         throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Invalid descriptor"));
     }
@@ -689,8 +689,9 @@
     UniValue addresses(UniValue::VARR);

     for (int i = range_begin; i <= range_end; ++i) {
+        FlatSigningProvider provider;
         std::vector<CScript> scripts;
-        if (!desc->Expand(i, provider, scripts, provider)) {
+        if (!desc->Expand(i, key_provider, scripts, provider)) {
             throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, strprintf("Cannot derive script without private keys"));
         }


Remove redundant void argument

Remove redundant void argument

--- src/db/Connection.hpp
+++ src/db/Connection.hpp
@@ -39,10 +39,10 @@

 public:
     explicit Connection(const std::string &connectionString);
-    void beginTransaction(void);
+    void beginTransaction();
     auto query(const std::string &query) -> pqxx::result;
-    void commitTransaction(void);
-    void rollbackTransaction(void);
+    void commitTransaction();
+    void rollbackTransaction();

     template<typename T> inline auto quote(const T &t) const -> std::string {
         return internalConnection->quote(t);


tes

tes

git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@153748 0039d316-1c4b-4281-b951-d872f2087c98

--- chrome/browser/fast_shutdown_browsertest.cc
+++ chrome/browser/fast_shutdown_browsertest.cc
@@ -13,9 +13,6 @@
 #include "chrome/browser/ui/tab_contents/tab_contents.h"
 #include "chrome/common/chrome_switches.h"
 #include "chrome/common/chrome_notification_types.h"
-#include "chrome/test/automation/automation_proxy.h"
-#include "chrome/test/automation/browser_proxy.h"
-#include "chrome/test/automation/tab_proxy.h"
 #include "chrome/test/base/in_process_browser_test.h"
 #include "chrome/test/base/ui_test_utils.h"
 #include "content/public/browser/browser_thread.h"


speed things up a bit

speed things up a bit

git-svn-id: 3ad904ec35b89a071badd9cb0113dfe58093e920@304 726aef4b-f618-498e-8847-2d620e286838

--- modules/stickychan.cpp
+++ modules/stickychan.cpp
@@ -60,6 +60,7 @@
 					pChan->SetKey( it->second );
 				m_pUser->AddChan( pChan );
 				PutModule( "Joining [" + it->first + "]" );
+				PutIRC( "JOIN " + it->first + ( it->second.empty() ? "" : it->second ) );
 			}
 		}
 	}


minor fix

minor fix

--- cc/hidb.cc
+++ cc/hidb.cc
@@ -660,9 +660,10 @@
         return found;
     }
     catch (NotFound& err) {
-        std::cerr << "ERROR: not found " << err.what() << std::endl;
-        if (report_if_not_found)
+        if (report_if_not_found) {
+            std::cerr << "ERROR: serum not found in hidb " << err.what() << std::endl;
             std::cerr << report(find_sera(aSerum.full_name()), "  ") << std::endl;
+        }
         throw;
     }


[net processing] Add Peer

[net processing] Add Peer

Peer is a struct for holding per-peer data. This structure is not
protected by cs_main since it does not contain validation-critical data.

--- src/net_processing.cpp
+++ src/net_processing.cpp
@@ -471,6 +471,43 @@
     return &it->second;
 }

+/**
+ * Data structure for an individual peer. This struct is not protected by
+ * cs_main since it does not contain validation-critical data.
+ *
+ * Memory is owned by shared pointers and this object is destructed when
+ * the refcount drops to zero.
+ *
+ * TODO: move most members from CNodeState to this structure.
+ * TODO: move remaining application-layer data members from CNode to this structure.
+ */
+struct Peer {
+    /** Same id as the CNode object for this peer */
+    const NodeId m_id{0};
+
+    Peer(NodeId id) : m_id(id) {}
+};
+
+using PeerRef = std::shared_ptr<Peer>;
+
+/**
+ * Map of all Peer objects, keyed by peer id. This map is protected
+ * by the global g_peer_mutex. Once a shared pointer reference is
+ * taken, the lock may be released. Individual fields are protected by
+ * their own locks.
+ */
+Mutex g_peer_mutex;
+static std::map<NodeId, PeerRef> g_peer_map GUARDED_BY(g_peer_mutex);
+
+/** Get a shared pointer to the Peer object.
+ *  May return nullptr if the Peer object can't be found. */
+static PeerRef GetPeerRef(NodeId id)
+{
+    LOCK(g_peer_mutex);
+    auto it = g_peer_map.find(id);
+    return it != g_peer_map.end() ? it->second : nullptr;
+}
+
 static void UpdatePreferredDownload(const CNode& node, CNodeState* state) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 {
     nPreferredDownload -= state->fPreferredDownload;
@@ -838,6 +875,11 @@
         LOCK(cs_main);
         mapNodeState.emplace_hint(mapNodeState.end(), std::piecewise_construct, std::forward_as_tuple(nodeid), std::forward_as_tuple(addr, pnode->IsInboundConn(), pnode->IsManualConn()));
     }
+    {
+        PeerRef peer = std::make_shared<Peer>(nodeid);
+        LOCK(g_peer_mutex);
+        g_peer_map.emplace_hint(g_peer_map.end(), nodeid, std::move(peer));
+    }
     if(!pnode->IsInboundConn())
         PushNodeVersion(*pnode, *connman, GetTime());
 }
@@ -865,6 +907,10 @@
 void PeerLogicValidation::FinalizeNode(NodeId nodeid, bool& fUpdateConnectionTime) {
     fUpdateConnectionTime = false;
     LOCK(cs_main);
+    {
+        LOCK(g_peer_mutex);
+        g_peer_map.erase(nodeid);
+    }
     CNodeState *state = State(nodeid);
     assert(state != nullptr);