You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2022/11/01 14:33:22 UTC

[GitHub] [ignite-3] isapego commented on a diff in pull request #1272: IGNITE-18007 MacOS support

isapego commented on code in PR #1272:
URL: https://github.com/apache/ignite-3/pull/1272#discussion_r1010490625


##########
modules/platforms/cpp/ignite/network/detail/macos/macos_async_client.cpp:
##########
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "../linux/linux_async_client.h"

Review Comment:
   Let's use the absolute path starting with `"ignite/..."`



##########
modules/platforms/cpp/ignite/schema/CMakeLists.txt:
##########
@@ -19,21 +19,40 @@ project(ignite-schema)
 
 set(TARGET ${PROJECT_NAME})
 
-add_library(${TARGET} STATIC
-    big_decimal.cpp big_decimal.h
-    big_integer.cpp big_integer.h
-    binary_tuple_builder.cpp binary_tuple_builder.h
+set(SOURCES
+    big_decimal.cpp
+    big_integer.cpp
+    binary_tuple_builder.cpp
+    binary_tuple_parser.cpp
+    ignite_type.cpp
+)
+
+set(PUBLIC_HEADERS
+    big_decimal.h
+    big_integer.h
+    binary_tuple_builder.h
     binary_tuple_header.h
-    binary_tuple_parser.cpp binary_tuple_parser.h
+    binary_tuple_parser.h
     binary_tuple_schema.h
     column_info.h
     ignite_date.h
     ignite_date_time.h
     ignite_time.h
     ignite_timestamp.h
-    ignite_type.cpp ignite_type.h
-    types.h)
+    ignite_type.h
+    types.h
+)

Review Comment:
   Why did you make the library public?



##########
modules/platforms/cpp/ignite/network/network.cpp:
##########
@@ -21,17 +21,20 @@
 
 #include <ignite/common/config.h>
 
-#ifdef _WIN32
+#if defined(_WIN32)

Review Comment:
   Why not `#ifdef _WIN32`?



##########
modules/platforms/cpp/tests/test-common/process.cpp:
##########
@@ -30,11 +30,11 @@
 namespace ignite {
 
 std::unique_ptr<CmdProcess> CmdProcess::make(std::string command, std::vector<std::string> args, std::string workDir) {
-#ifdef WIN32
+#if defined(_WIN32)

Review Comment:
   Why?



##########
modules/platforms/cpp/tests/test-common/detail/unix_process.h:
##########
@@ -26,16 +26,19 @@
 #include <string>
 #include <vector>
 
+#if defined(__APPLE__)
+#include <csignal>
+#endif

Review Comment:
   This is a standard C header, no need to use `#ifdef`s here.



##########
modules/platforms/cpp/ignite/network/detail/macos/macos_async_worker_thread.cpp:
##########
@@ -0,0 +1,312 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "../linux/linux_async_worker_thread.h"
+
+#include "../utils.h"
+#include "../linux/linux_async_client_pool.h"

Review Comment:
   Same as above.



##########
modules/platforms/cpp/tests/client-test/main.cpp:
##########
@@ -21,9 +21,30 @@
 
 #include <gtest/gtest.h>
 
+#if defined(__APPLE__)
+#include <csignal>
+#endif
 #include <chrono>
 #include <thread>
 
+namespace {
+/** Shutdown handler that cleans up resources. */
+std::function<void(int)> shutdown_handler;
+
+/**
+ * Receives OS signal and handles it.
+ *
+ * @param signum Signal value.
+ */
+void signal_handler(int signum) {
+    shutdown_handler(signum);
+
+    signal(signum, SIG_DFL);
+
+    kill(getpid(), signum);

Review Comment:
   Will break other platforms as the `<csignal>` header included only for MacOS. Also, kill is a platform-specific call, lets use standard [raise ](https://en.cppreference.com/w/cpp/utility/program/raise) instead.



##########
modules/platforms/cpp/tests/client-test/main.cpp:
##########
@@ -40,9 +52,23 @@ void before_all() {
 }
 
 int main(int argc, char **argv) {
+    // Install signal handlers to clean up resources on early exit.
+    signal(SIGABRT, signal_handler);
+    signal(SIGINT, signal_handler);
+
+    ignite::IgniteRunner runner;
+
+    shutdown_handler = [&](int signal) {
+        std::cout << "Caught signal " << signal << " during tests" << std::endl;
+
+        runner.stop();
+
+        std::cout << "Resources cleanup OK" << std::endl;
+    };

Review Comment:
   Actually, this may be a good idea, as in case tests aborted with `SIGSEGV` (by the way, should add it I guess), IgniteRunner will continue running as a separate process which is really bad. But I don't like how the code looks right now, it should be moved to separate function so the main function looks somehow like this:
   ```
   set_process_abort_handler([&](int signal) {
       std::cout << "Caught signal " << signal << " during tests" << std::endl;
   
       runner.stop();
   };
   ```
   
   Also, we can use the same code for Linux and Windows, not only macOS.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org